Skip to content

Commit

Permalink
[#65965] gui_init: Add resize and copy handlers
Browse files Browse the repository at this point in the history
Signed-off-by: Andrii Chmutov <[email protected]>
  • Loading branch information
AndrewChmutov authored and glatosinski committed Sep 24, 2024
1 parent 43c0f48 commit 3c9d6ae
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions raviewer/gui/gui_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,36 @@ def init_mouse_handlers(self):
button=Controls.remove_annotation_button,
callback=self.events.remove_annotation)

def init_item_handlers(self):
# Update text wrapping for error modal
with dpg.item_handler_registry(tag=items.registries.error_size):
dpg.add_item_resize_handler(callback=self.events.update_error_wrap)
dpg.bind_item_handler_registry(items.windows.error,
items.registries.error_size)

# Copy error text
with dpg.item_handler_registry(tag=items.registries.error_copy):
dpg.add_item_clicked_handler(callback=self.events.copy_error_text)
dpg.add_item_visible_handler(
callback=self.events.set_error_tooltip)
dpg.bind_item_handler_registry(items.static_text.error,
items.registries.error_copy)

def init_error_modal(self):
with dpg.window(label="Error",
tag=items.windows.error,
modal=True,
show=False,
width=400,
height=200,
no_resize=True):
dpg.add_text(default_value="An error occurred",
tag=items.static_text.error,
wrap=350)
min_size=(400, 200),
on_close=self.events.update_error_size):
dpg.add_text(default_value="An error has occurred",
tag=items.static_text.error)
with dpg.tooltip(parent=items.static_text.error,
tag=items.tooltips.error):
dpg.add_text(default_value="Click to copy",
tag=items.static_text.error_tooltip)

def init_styles(self):
dpg.bind_theme(items.theme.general)
Expand All @@ -175,6 +194,7 @@ def create_gui_widgets(self, args):
self.init_file_dialogs()
self.init_mouse_handlers()
self.init_error_modal()
self.init_item_handlers()
self.init_loading_indicator()

if args["FILE_PATH"] != None:
Expand Down

0 comments on commit 3c9d6ae

Please sign in to comment.