def _show_gui(self): with dpg.window( tag=PRIMARY_WINDOW, width=MAIN_WINDOW_WIDTH, height=MAIN_WINDOW_HEIGHT, ): with dpg.group(horizontal=True): with dpg.child_window( width=CONTACT_LIST_WIDTH, height=MAIN_WINDOW_HEIGHT ): dpg.add_listbox( tag=CONTACT_LIST, items=self.data.histories, width=-1, num_items=len(self.data.contacts), callback=self.call_list, ) with dpg.group(horizontal=False): with dpg.group(width=-1, horizontal=True): with dpg.child_window( tag=MESSAGE_GROUP, width=-1, height=MESSAGE_WINDOW_HEIGHT ): dpg.add_text("No message yet") dpg.add_text(tag=STATUS_LABEL, label="", color=COLOR_ACCENT) dpg.add_input_text( default_value="", multiline=True, label="", tag=MESSAGE_INPUT, width=-1, height=MESSAGE_INPUT_HEIGHT, hint="Write...", callback=self.call_write, ) with dpg.group(horizontal=True): dpg.add_button( label="Send", width=100, callback=self.call_send_button, user_data=False, ) dpg.add_button( label="Send To All", width=100, callback=self.call_send_button, user_data=True, # send all )
def create_error_window(error_text, spacer): with dpg.window(label="Error Window", modal=True, show=True, id="modal_error_id", no_title_bar=True, popup=True): dpg.add_text(error_text) dpg.add_separator() with dpg.group(horizontal=True): dpg.add_spacer(width=spacer) dpg.add_button(label="OK", width=75, callback=delete_error_popup_aliases)
def custom(self): with dpg.group(width=150): dpg.add_input_float(label="Expected Value", step=0.0, id=self.expected_id, default_value=10) dpg.add_input_float(label="Max Tolerance", step=0.0, id=self.max_id, default_value=.05) dpg.add_input_float(label="Min Tolerance", step=0.0, id=self.min_id, default_value=.05) dpg.add_radio_button(items=["Status"], id=self.status_id) dpg.set_item_theme(self.status_id, self.neutral)
def create(self): with dpg.group(): dpg.add_text(self._title) for i, item in enumerate(self._items): item_label = self._item_show_cb(item) gui_item = dpg.add_text(item_label) self._gui_items.append(gui_item) self.select_other(0)
def __init__(self, parent=None): self.log_level = 0 self._auto_scroll = True self.filter_id = None if parent: self.window_id = parent else: self.window_id = dpg.add_window(label="mvLogger", pos=(10, 150), width=800, height=200) self.count = 0 self.flush_count = 1000 with dpg.group(horizontal=True, parent=self.window_id): dpg.add_checkbox(label="Auto-scroll", default_value=True, callback=lambda sender: self.auto_scroll( dpg.get_value(sender))) dpg.add_button(label="Clear", callback=lambda: dpg.delete_item( self.filter_id, children_only=True)) dpg.add_input_text(label="Filter", callback=lambda sender: dpg.set_value( self.filter_id, dpg.get_value(sender)), parent=self.window_id) self.child_id = dpg.add_child(parent=self.window_id, autosize_x=True, autosize_y=True) self.filter_id = dpg.add_filter_set(parent=self.child_id) with dpg.theme() as self.trace_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (0, 255, 0, 255)) with dpg.theme() as self.debug_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (64, 128, 255, 255)) with dpg.theme() as self.info_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 255, 255)) with dpg.theme() as self.warning_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 0, 255)) with dpg.theme() as self.error_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255)) with dpg.theme() as self.critical_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))
def start(self): dpg.setup_registries() dpg.setup_viewport() dpg.set_viewport_title("Simple Data Flow") node_editor = NodeEditor() with dpg.window() as main_window: with dpg.menu_bar(): with dpg.menu(label="Operations"): dpg.add_menu_item(label="Reset", callback=lambda: dpg.delete_item(node_editor.uuid, children_only=True)) with dpg.menu(label="Plugins"): for plugin in self.plugins: dpg.add_menu_item(label=plugin[0], callback=plugin[1]) with dpg.group(horizontal=True) as group: # left panel with dpg.group(id=self.left_panel): self.data_set_container.submit(self.left_panel) self.modifier_container.submit(self.left_panel) # center panel node_editor.submit(group) # right panel with dpg.group(id=self.right_panel): self.inspector_container.submit(self.right_panel) self.tool_container.submit(self.right_panel) dpg.set_primary_window(main_window, True) dpg.start_dearpygui()
def edit_ssh_info(): global ssh_table global parent_id with dpg.window(label='ssh info editor', width=800, height=500, on_close=on_close): with dpg.group(horizontal=True): dpg.add_button(label='Add ssh server', callback=add_ssh_server_row) dpg.add_button(label='Remove ssh server', callback=remove_ssh_server_rows) ssh_table = Table( 'ssh info editor', ['', 'ID', 'Name', 'IP', 'Port', 'username', 'password'], parent_id)
def _ticker_list(parent_id): # dpg.add_text("TICKER LIST") with dpg.filter_set(parent=parent_id) as filter_id: filter_container = dpg.last_container() for ticker in tickers: with dpg.group(filter_key=ticker, horizontal=True): item = dpg.last_item() dpg.add_button(label=ticker, user_data=ticker, callback=lambda s, a, u: logger.log_info(u)) dpg.set_item_theme(dpg.last_item(), button_themes[2]) tick = exchange.symbol_ticker(ticker)[ticker] dpg.add_text("%.2f %s" % (float(tick.current), tick.currency)) with dpg.drag_payload(parent=item, drag_data=ticker, payload_type='main_window'): dpg.add_text('asdfasf') dpg.add_input_text(parent=parent_id, label="", before=filter_container, user_data=filter_container, callback=lambda s, a, u: dpg.set_value(u, a))
def init(self, parent): self.window_id = parent with dpg.group(horizontal=True, parent=self.window_id): dpg.add_checkbox(label="Auto-scroll", default_value=True, callback=lambda sender: self.auto_scroll( dpg.get_value(sender))) dpg.add_same_line() dpg.add_button(label="Clear", callback=lambda: dpg.delete_item( self.filter_id, children_only=True)) dpg.add_same_line() dpg.add_input_text(label="Filter", callback=lambda sender: dpg.set_value( self.filter_id, dpg.get_value(sender))) self.child_id = dpg.add_child(parent=self.window_id, autosize_x=True, autosize_y=True) self.filter_id = dpg.add_filter_set(parent=self.child_id)
def __init__(self): self.log_level = 0 self._auto_scroll = True self.filter_id = None self.window_id = dpg.add_window(label="mvLogger", pos=(200, 200), width=500, height=500) self.count = 0 self.flush_count = 1000 self.level_options = {"Trace": 0, "Debug": 1, "Info": 2, "Warning": 3, "Error": 4, "Critical": 5} with dpg.group(horizontal=True, parent=self.window_id): dpg.add_checkbox(label="Auto-scroll", default_value=True, callback=lambda sender: self.auto_scroll(dpg.get_value(sender))) dpg.add_button(label="Clear", callback=lambda: dpg.delete_item(self.filter_id, children_only=True)) dpg.add_input_text(label="Filter", callback=lambda sender: dpg.set_value(self.filter_id, dpg.get_value(sender)), parent=self.window_id) dpg.add_radio_button(list(self.level_options.keys()), parent=self.window_id, callback=lambda sender: self.set_level(self.level_options[dpg.get_value(sender)])) dpg.add_same_line(parent=self.window_id) self.child_id = dpg.add_child(parent=self.window_id, autosize_x=True, autosize_y=True) self.filter_id = dpg.add_filter_set(parent=self.child_id) with dpg.theme() as self.trace_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (0, 255, 0, 255)) with dpg.theme() as self.debug_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (64, 128, 255, 255)) with dpg.theme() as self.info_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 255, 255)) with dpg.theme() as self.warning_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 0, 255)) with dpg.theme() as self.error_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255)) with dpg.theme() as self.critical_theme: dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))
import dearpygui.dearpygui as dpg dpg.create_context() with dpg.window(label="Tutorial"): dpg.add_button(label="Button 1") dpg.add_button(label="Button 2") with dpg.group(): dpg.add_button(label="Button 3") dpg.add_button(label="Button 4") with dpg.group() as group1: pass dpg.add_button(label="Button 6", parent=group1) dpg.add_button(label="Button 5", parent=group1) dpg.create_viewport(title='Custom Title', width=600, height=400) dpg.setup_dearpygui() dpg.show_viewport() dpg.start_dearpygui() dpg.destroy_context()
def main(port): # Should be configurable or whatever, for the other pad protocols serial = SerialProtoGF('/dev/ttyACM0') # Fetch the pad config / base settings # [panel no] = list[sensor indices] panel_mapping = get_panel_mapping(serial) trigger_values = serial.command_get_trigger_values() schmitt_values = serial.command_get_trigger_schmitt_values() dpg.create_context() dpg.create_viewport(title="ITGaz's Awesome Pad GUI", width=800, height=600, resizable=False, decorated=True) dpg.setup_dearpygui() vals_raw = [0 for x in trigger_values] with dpg.window(label="", width=800, height=600, no_resize=True, no_title_bar=True, no_move=True): dpg.add_text("LEFT:") with dpg.group(horizontal=True): for s in panel_mapping[PANEL_P1LEFT]: dpg.add_slider_float(no_input=True, vertical=False, tag=f"sensorbar_{s}", width=300) dpg.add_checkbox(tag=f"sensortriggered_{s}") dpg.add_text("DOWN:") with dpg.group(horizontal=True): for s in panel_mapping[PANEL_P1DOWN]: dpg.add_slider_float(no_input=True, vertical=False, tag=f"sensorbar_{s}", width=300) dpg.add_checkbox(tag=f"sensortriggered_{s}") dpg.add_text("UP:") with dpg.group(horizontal=True): for s in panel_mapping[PANEL_P1UP]: dpg.add_slider_float(no_input=True, vertical=False, tag=f"sensorbar_{s}", width=300) dpg.add_checkbox(tag=f"sensortriggered_{s}") dpg.add_text("RIGHT:") with dpg.group(horizontal=True): for s in panel_mapping[PANEL_P1RIGHT]: dpg.add_slider_float(no_input=True, vertical=False, tag=f"sensorbar_{s}", width=300) dpg.add_checkbox(tag=f"sensortriggered_{s}") dpg.show_viewport() # dpg.start_dearpygui() while dpg.is_dearpygui_running(): vals_raw = serial.command_get_values_raw() vals_raw_min = serial.command_get_values_raw_min() vals_filtered = serial.command_get_values_filtered() triggered = serial.command_get_triggered() for s, v in enumerate(vals_filtered): slider_tag = f"sensorbar_{s}" triggered_tag = f"sensortriggered_{s}" # slider_config = dpg.get_item_configuration(tag) slider_min = 0 slider_max = 1024 # slider_min = min(slider_config['min_value'], vals_raw_min[s]) # slider_max = max(slider_config['max_value'], vals_raw[s]) dpg.configure_item(slider_tag, min_value=slider_min, max_value=slider_max) dpg.set_value(slider_tag, v) dpg.set_value(triggered_tag, triggered[s]) # render_ui(panel_mapping, trigger_values, schmitt_values, vals_raw, vals_raw_min, vals_filtered, triggered) dpg.render_dearpygui_frame() time.sleep(0.05) dpg.destroy_context()
def ShowInfo(self): with dpg.group(parent=self.window_id): dpg.add_text(f'DataPath: {self.DataPath}') dpg.add_text(f'DataStartDate: {self.DataStartDate}')
def setUp(self): dpg.create_context() with dpg.window() as self.window_id: def testy(sender, app, user): print(f"Sender: {dpg.get_item_type(sender)} {sender}, App Data: {app}, User Data:{user}") # Menus with dpg.menu_bar() as menu_bar: dpg.add_menu_item(label="menu item", payload_type="str", drop_callback=testy) with dpg.menu(label="menu", payload_type="str", drop_callback=testy): dpg.add_menu_item(label="menu item") # basic with dpg.collapsing_header(label="basic") as basic: dpg.add_image(dpg.mvFontAtlas) dpg.add_image_button(dpg.mvFontAtlas) dpg.add_text("this is a text widget") dpg.add_checkbox(label="checkbox") dpg.add_button(label="button") dpg.add_input_float(label="input float") dpg.add_input_floatx(label="input floatx") dpg.add_drag_int(label="drag int") dpg.add_drag_intx(label="drag intx") dpg.add_input_text(label="input text") dpg.add_slider_float(label="slider float") dpg.add_slider_floatx(label="slider floatx") dpg.add_listbox(label="listbox") dpg.add_selectable(label="selectable") dpg.add_radio_button(["item 1", "item 2"],label="radio button") # color with dpg.collapsing_header(label="color") as color: with dpg.group() as color: dpg.add_color_button([255,0,0,255]) dpg.add_color_edit([255,0,0,255]) dpg.add_colormap_button(label="Colormap Button 1") dpg.add_color_picker((255, 0, 255, 255), label="Color Picker", width=200) dpg.add_colormap_slider(label="Colormap Slider 1", default_value=0.5, payload_type="str", drop_callback=testy) dpg.add_colormap_scale(label="Colormap Spectral", min_scale=-100, max_scale=150, payload_type="str", drop_callback=testy) # containers with dpg.collapsing_header(label="containers"): with dpg.group() as containers: with dpg.collapsing_header(): btn = dpg.add_button() with dpg.group(width=150): dpg.add_button() with dpg.tree_node(): dpg.add_button() with dpg.child_window(width=150, height=100, payload_type="str", drop_callback=testy): pass # tab stuff with dpg.collapsing_header(label="tab bars"): with dpg.tab_bar(): with dpg.tab(label="tab", payload_type="str", drop_callback=testy): pass dpg.add_tab_button(label="tab button", payload_type="str", drop_callback=testy, drag_callback=testy) with dpg.drag_payload(parent=dpg.last_item(), drop_data="dropped", drag_data="dragged", user_data="user data", payload_type="str"): dpg.add_text(dpg.get_item_type(dpg.last_item())) dpg.add_text(f"Item ID: {dpg.last_item()}") # custom with dpg.collapsing_header(label="custom"): with dpg.group() as custom: dpg.add_date_picker() dpg.add_knob_float() dpg.add_3d_slider() dpg.add_time_picker() dpg.add_loading_indicator(payload_type="str", drop_callback=testy) # misc with dpg.collapsing_header(label="misc"): with dpg.group() as misc: dpg.add_progress_bar(label="progress bar", default_value=.5) # node with dpg.collapsing_header(label="node"): with dpg.node_editor() as node: with dpg.node(pos=[20,20], draggable=False): pass with dpg.node(pos=[100,100], draggable=False): pass # plots with dpg.collapsing_header(label="plot") as plot: with dpg.plot(): dpg.add_plot_legend(payload_type="str", drop_callback=testy) dpg.add_plot_axis(dpg.mvXAxis, label="x", payload_type="str", drop_callback=testy) with dpg.plot_axis(dpg.mvYAxis, label="y", payload_type="str", drop_callback=testy): dpg.add_line_series([0,1,2,3,4,5], [0,1,2,3,4,5], label="data") self.test_bind_items = dpg.get_item_children(basic, slot=1) self.test_bind_items += dpg.get_item_children(color, slot=1) self.test_bind_items += dpg.get_item_children(containers, slot=1) self.test_bind_items += dpg.get_item_children(custom, slot=1) self.test_bind_items += dpg.get_item_children(misc, slot=1) self.test_bind_items += dpg.get_item_children(node, slot=1) self.test_bind_items += dpg.get_item_children(plot, slot=1) dpg.setup_dearpygui()
def custom(self): with dpg.group(width=150): dpg.add_input_float(label="Input Value", step=0, id=self.value, default_value=10)
def custom(self): with dpg.group(width=150): dpg.add_text("Not Calculated", label="Min", show_label=True, id=self.min_id) dpg.add_text("Not Calculated", label="Max", show_label=True, id=self.max_id)
dpg.add_same_line() dpg.add_button(label="Initialize", callback=search_directory) dpg.add_node_editor(label="Editor", id=editor_id) # files window with dpg.window(label="All Files", pos=(75, 65), show=False, no_resize=True, autosize=True, id=all_files_id): dpg.add_listbox(label="Headers", width=200, num_items=15, callback=callback, id=headers_id) dpg.add_same_line() dpg.add_listbox(label="Cpp", width=200, num_items=15, callback=callback, id=cpp_id) dpg.add_same_line() dpg.add_listbox(label="Other", width=200, num_items=15, callback=callback, id=other_id) # ignore options window with dpg.window(label="Ignore Options", pos=(75, 400), show=False, no_resize=True, autosize=True) as ignore_options_id: with dpg.group(): dpg.add_button(label="Ignore File", callback=ignore) dpg.add_same_line() dpg.add_button(label="Unignore File", callback=unignore) dpg.add_listbox(label="Ignore", width=200, num_items=15, id=ignore_id) dpg.add_same_line() dpg.add_listbox(label="Files", width=200, num_items=15, id=files_id) dpg.setup_viewport() dpg.set_viewport_title("Header Analyzer") dpg.set_primary_window(main_id, True) dpg.start_dearpygui()
dpg.add_menu_item(label='distance', callback=lambda: nodes.add_distance(node_editor_id)) dpg.add_menu_item(label='rlines', callback=lambda: nodes.add_rlines(node_editor_id)) nodes.add_symbol(node_editor_id) nodes.add_current_price(node_editor_id) nodes.add_history(node_editor_id) nodes.add_rlines(node_editor_id) with dpg.window(label='Main', no_title_bar=True): core.set_primary_window(dpg.last_item(), True) with dpg.menu_bar(): with dpg.menu(label="File"): dpg.add_menu_item(label="show dpg demo", callback=lambda: show_demo()) dpg.add_menu_item(label="show dpg doc", callback=lambda: dpg.show_documentation()) with dpg.group(): main_parent = dpg.last_item() # menu bar # main with dpg.group(horizontal=True): with dpg.child(label='column_0', width=150, height=500): _candle_indicators() with dpg.child(label='column_1', width=700, height=500, payload_type='main_window', drop_callback=_ticker_drop): window_data.main_window_title = dpg.add_text('Ticker: ') # dpg.add_button(label='Period') # with dpg.popup(dpg.last_item(), modal=True, mousebutton=dpg.mvMouseButton_Left) as modal_id: # period_start = '' # dpg.add_date_picker(level=dpg.mvDatePickerLevel_Day, # default_value={'month_day': 8, 'year': 93, 'month': 5}, # callback=)
def update_image(sender, app_data, user_data): image, controls = user_data kwargs = {} for k, v in controls.items(): kwargs[k] = dpg.get_value(v) dpg.configure_item(image, **kwargs) with dpg.window(label="Main"): dpg.add_text( "This is an example of a image being added to a drawlist and updated", bullet=True) dpg.add_spacing(count=5) dpg.add_separator() dpg.add_spacing() with dpg.group() as control_group: pmin = dpg.add_slider_intx(label="pmin", default_value=[0, 125], max_value=500, size=2) pmax = dpg.add_slider_intx(label="pmax", default_value=[416, 509], max_value=500, size=2) uv_min = dpg.add_slider_floatx(label="uv_min", default_value=[0, 0], max_value=3, min_value=-3, size=2) uv_max = dpg.add_slider_floatx(label="uv_max", default_value=[1, 1],
def extra_input_window(self): attr = 'Extra_Input' attribute_name = attr + '##{}##{}'.format(self.operation.name, self.node_index) with dpg.node_attribute( label=attribute_name, parent=self.id, attribute_type=dpg.mvNode_Attr_Static) as attr_id: image_file = os.path.join( os.path.dirname(os.path.realpath(__file__)), os.path.pardir, 'resources', 'Blue_glass_button_square_34x34.png') width, height, channels, data = dpg.load_image(image_file) with dpg.texture_registry(): texture_id = dpg.add_static_texture(width, height, data) image_button = dpg.add_image_button( texture_tag=texture_id, label='##' + attr + ' Name{}##{}'.format(self.operation.name, self.node_index), callback=self.update_ssh_combo_boxes) with dpg.window( label='##Window#Extra input##{}##{}'.format( self.operation.name, self.node_index), width=450, height=250, pos=[self.coordinates[0] + 400, self.coordinates[1] + 200], show=False, popup=True) as self.extra_window_id: # Add the local ssh input dpg.add_spacer(height=10) with dpg.group(horizontal=True): dpg.add_spacer(width=10) dpg.add_text('SSH local server') dpg.add_spacer(width=80) dpg.add_text('SSH remote server') with dpg.group(horizontal=True): dpg.add_spacer(width=10) id = dpg.add_combo( label='##SSH local server##Extra input##{}##{}'.format( self.operation.name, self.node_index), items=self.ssh_server_id_and_names, width=140, default_value=self.ssh_local_server, callback=self.assign_local_server) self.parameter_inputs_ids['SSH local server'] = id dpg.add_spacer(width=40) id = dpg.add_combo( label='##SSH remote server ##Extra input##{}##{}'. format(self.operation.name, self.node_index), items=self.ssh_server_id_and_names, width=140, default_value=self.ssh_remote_server, callback=self.assign_remote_server) self.parameter_inputs_ids['SSH remote server'] = id dpg.add_spacer(height=10) with dpg.group(horizontal=True): dpg.add_spacer(width=10) dpg.add_text( 'Python script of worker process OR Python.exe and script:' ) with dpg.group(horizontal=True): dpg.add_spacer(width=10) dpg.add_input_text( label='##Worker executable##Extra input##{}##{}'. format(self.operation.name, self.node_index), width=400, default_value=self.worker_executable, callback=self.assign_worker_executable) # Add the verbocity input dpg.add_spacer(height=6) with dpg.group(horizontal=True): dpg.add_spacer(width=10) attr = 'Log file or Verbosity level:' attribute_name = attr + '##{}##{}'.format( self.operation.name, self.node_index) self.verbosity_id = dpg.add_text( label='##' + attr + ' Name{}##{}'.format( self.operation.name, self.node_index), default_value=attr) with dpg.group(horizontal=True): dpg.add_spacer(width=10) dpg.add_input_text( label='##{}'.format(attribute_name), default_value=self.com_verbosity, callback=self.update_verbosity, width=400, hint='Log file name or verbosity level integer.', tag='verb#{}#{}'.format(self.operation.name, self.node_index)) if importlib.util.find_spec('reliquery') is not None: # Create the relic input only if reliquery is present with dpg.group(horizontal=True): dpg.add_spacer(width=10) dpg.add_text(default_value='Save Relic to directory:') with dpg.group(horizontal=True): dpg.add_spacer(width=10) dpg.add_input_text( default_value=self.relic_verbosity, callback=self.update_verbosity, hint= 'The path where the Relic for this worker process will be saved', tag='relic#{}#{}'.format(self.operation.name, self.node_index))
dpg.add_series_value(tag='src') def cb_add_3d_coords(): with dpg.table_row(parent=ID.table1): for n in dpg.get_value(ID.values3): dpg.add_text(label=str(n)) with dpg.theme(tag='__round'): with dpg.theme_component(dpg.mvButton): dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 10) dpg.add_theme_style(dpg.mvStyleVar_FramePadding, 30, 30) with dpg.window(label='basic dpg app', tag='main'): with dpg.group(horizontal=False): dpg.add_3d_slider(tag=ID.values3, scale=.3, callback=lambda: print(dpg.get_value(ID.values3))) dpg.add_button(label='add coords', callback=cb_add_3d_coords) dpg.bind_item_theme(dpg.last_item(), '__round') with dpg.table(tag=ID.table1, source='src'): dpg.add_table_column(label='x') dpg.add_table_column(label='y') dpg.add_table_column(label='z') dpg.set_primary_window('main', True) dpg.show_viewport() dpg.start_dearpygui() dpg.destroy_context()