Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_frame():
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)
if clicked_quit:
exit(1)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
if imgui.begin_menu("File", True):
clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)
if clicked_quit:
exit(1)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
imgui.render()
self.imgui.render(imgui.get_draw_data())
clicked, metadata["type"] = imgui.combo(
"Attribute Type##type-"+attr,
metadata["type"],
DB.type_name
)
clicked, metadata["is_list"] = imgui.checkbox("Is List", bool(metadata.get("is_list")))
if metadata["type"] == 2:
imgui.text("Leave -1s to allow an arbitrary string.")
changed, metadata["num_limits"] = imgui.input_int2('Int Limits##'+attr, *metadata["num_limits"])
elif metadata["type"] == 3:
imgui.text("Leave -1s to allow an arbitrary string.")
changed, metadata["num_limits"] = imgui.input_float2('Float Limits##'+attr, *metadata["num_limits"])
elif metadata["type"] == 1:
imgui.text("Leave blank to allow an arbitrary string.")
changed, strings = imgui.input_text(
"Allowed Strings##" + attr,
','.join(metadata["allowed_strings"]),
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
metadata["allowed_strings"] = list(filter(lambda x: len(x), strings.split(",")))
elif metadata["type"] == 0:
imgui.text("All entities allowed")
imgui.unindent()
if imgui.button("Add New Attribute Metadata"):
imgui.open_popup("new-attribute-meta")
new_name = draw_ok_cancel_popup("new-attribute-meta", "Attribute Name:")
if new_name:
new_name = new_name.lower().replace(" ", "_").replace("-", "_")
elif metadata["type"] == 3:
imgui.text("Leave -1s to allow an arbitrary string.")
changed, metadata["num_limits"] = imgui.input_float2('Float Limits##'+attr, *metadata["num_limits"])
elif metadata["type"] == 1:
imgui.text("Leave blank to allow an arbitrary string.")
changed, strings = imgui.input_text(
"Allowed Strings##" + attr,
','.join(metadata["allowed_strings"]),
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
metadata["allowed_strings"] = list(filter(lambda x: len(x), strings.split(",")))
elif metadata["type"] == 0:
imgui.text("All entities allowed")
imgui.unindent()
if imgui.button("Add New Attribute Metadata"):
imgui.open_popup("new-attribute-meta")
new_name = draw_ok_cancel_popup("new-attribute-meta", "Attribute Name:")
if new_name:
new_name = new_name.lower().replace(" ", "_").replace("-", "_")
DB.attribute_metadata[new_name] = {
"description": "",
"type": 5,
"num_limits": (0,0),
"is_list": False,
"allowed_strings": []
}
attr_expanded[new_name] = False
imgui.end()
def main():
pygame.init()
size = 800, 600
pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)
io = imgui.get_io()
io.fonts.add_font_default()
io.display_size = size
renderer = PygameRenderer()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
renderer.process_event(event)
imgui.new_frame()
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
def run():
global DB, database_name, TICK_INTERVAL, show_meta_attr, show_rules_db, show_eav_db, show_table_db
font_extra = imgui.get_io().fonts.add_font_from_file_ttf(
"Fonts/Roboto-Light.ttf", 20
)
font_extra2 = imgui.get_io().fonts.add_font_from_file_ttf(
"Fonts/RobotoMono-Light.ttf", 20
)
window, gl_context = impl_pysdl2_init()
renderer = SDL2Renderer(window)
running = True
event = SDL_Event()
show_save_as = False
show_load_db = False
TICK_INTERVAL = 30
next_time = SDL_GetTicks() + TICK_INTERVAL;
io = imgui.get_io()
while running:
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)
if clicked_quit:
exit(1)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
impl.render(imgui.get_draw_data())
glfw.swap_buffers(window)
impl.shutdown()
glfw.terminate()
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)
if clicked_quit:
exit(1)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
SDL_GL_SwapWindow(window)
renderer.shutdown()
SDL_GL_DeleteContext(gl_context)
SDL_DestroyWindow(window)
SDL_Quit()
on_exit()
try:
sys.exit()
except SystemExit as e:
time.sleep(0.5)
# sys.exit()
# sys.terminate()
os._exit(1)
pygame_renderer.process_event(event)
imgui.new_frame()
if params.provide_default_window:
imgui.set_next_window_position(0, 0)
imgui.set_next_window_size(win_size[0], win_size[1])
imgui.begin("Default window")
gui_loop_function()
if params.provide_default_window:
imgui.end()
ImGuiImageLister._heartbeat()
# note: cannot use screen.fill((1, 1, 1)) because pygame's screen
# does not support fill() on OpenGL surfaces
gl.glClearColor(1, 1, 1, 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
pygame_renderer.render(imgui.get_draw_data())
pygame.display.flip()
imgui_cv._clear_all_cv_textures()
imgui_ext.__clear_all_unique_labels()
def on_frame():
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)
if clicked_quit:
exit(1)
imgui.end_menu()
imgui.end_main_menu_bar()
imgui.show_test_window()
imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()