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("-", "_")
def draw_query(binds):
imgui.columns(2, "QueryBinds")
imgui.text("Variable Name")
imgui.next_column()
imgui.text("Value")
imgui.next_column()
imgui.separator()
for (k, v) in binds.items():
imgui.text(str(k))
imgui.next_column()
if isinstance(v, list):
imgui.text(str([e[1] for e in v]))
else:
imgui.text(str(v))
imgui.next_column()
imgui.columns(1)
def draw_query(binds):
imgui.columns(2, "QueryBinds")
imgui.text("Variable Name")
imgui.next_column()
imgui.text("Value")
imgui.next_column()
imgui.separator()
for (k, v) in binds.items():
imgui.text(str(k))
imgui.next_column()
if isinstance(v, list):
imgui.text(str([e[1] for e in v]))
else:
imgui.text(str(v))
imgui.next_column()
imgui.columns(1)
search_query["entity"],
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
changed, search_query["attribute"] = imgui.input_text(
"Search Attribute##search-2",
search_query["attribute"],
26,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
sqa = search_query["attribute"]
attributes = [a for a in DB.attributes if len(sqa) == 0 or (sqa in a or a in sqa)]
imgui.columns(len(attributes) + 1, "TblDBAttributes")
imgui.separator()
imgui.text("entity id")
imgui.next_column()
for a in attributes:
imgui.text(a)
imgui.next_column()
imgui.separator()
changes = []
sqe = search_query["entity"]
entities = [e for e in DB.entities if len(sqe) == 0 or (sqe in e or e in sqe)]
for e in entities:
imgui.text(e)
imgui.next_column()
for a in attributes:
res = DB.get_value(e, a)
if res:
change = draw_eav_value(DB, e, a, res)
def draw_ok_cancel_popup(ide, message="Type a Thing:"):
if imgui.begin_popup(ide):
if not ide in popup_registry:
popup_registry[ide] = ""
imgui.text(message)
changed, popup_registry[ide] = imgui.input_text(
"##" + ide,
popup_registry[ide],
26,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
if changed or imgui.button("OK"):
imgui.close_current_popup()
val = popup_registry[ide]
popup_registry[ide] = ""
imgui.end_popup()
return val
imgui.same_line()
if imgui.button("Cancel"):
imgui.close_current_popup()
popup_registry[ide] = ""
"""
If the setting menu not is selected, most likely the user is in his keyboard layout
We first want to check if the user is using the setting menu. After that we check
if the user uses its keyboard. If so we render the keyboard.
"""
# Check if the setting page is toggled
if not self.setting_toggle:
# Render keyboard
self.krender()
# If the setting page is active show the setting page instead of rendering the keyboard
else:
self.srender()
# Command line
imgui.text("Keyboard: {} | Shift: {} | SYS: {}".format(self.keyboard_toggled, self.CAPS, self.SYS))
# Give a style to the button
imgui.push_style_color(imgui.COLOR_BUTTON, *self.KEY_COLOR_LGRAY)
# Create a button "Import"
if imgui.button("Import", width=200, height=60):
# Toggle Keyboard if not already
if not self.keyboard_toggled:
self.keyboard_toggled = True
#self.input = "https://pastebin.com/"
self.input = "dpaste:>>"
# push style
imgui.pop_style_color(1)
imgui.same_line()
# Give a style to the button