Пример #1
0
def run_gui(csr_csv, port):
    import dearpygui.dearpygui as dpg

    bus = RemoteClient(csr_csv=csr_csv, port=port)
    bus.open()

    def reboot_callback():
        bus.regs.ctrl_reset.write(1)
        bus.regs.ctrl_reset.write(0)

    dpg.create_context()
    dpg.create_viewport(title="LiteX CLI GUI",
                        max_width=800,
                        always_on_top=True)
    dpg.setup_dearpygui()

    with dpg.window(autosize=True):
        dpg.add_text("Control/Status")
        dpg.add_button(label="Reboot", callback=reboot_callback)

        def filter_callback(sender, filter_str):
            dpg.set_value("csr_filter", filter_str)

        dpg.add_input_text(label="CSR Filter (inc, -exc)",
                           callback=filter_callback)
        dpg.add_text("CSR Registers:")
        with dpg.filter_set(id="csr_filter"):

            def reg_callback(tag, data):
                for name, reg in bus.regs.__dict__.items():
                    if (tag == name):
                        try:
                            reg.write(int(data, 0))
                        except:
                            pass

            for name, reg in bus.regs.__dict__.items():
                dpg.add_input_text(indent=16,
                                   label=f"0x{reg.addr:08x} - {name}",
                                   tag=name,
                                   filter_key=name,
                                   callback=reg_callback,
                                   on_enter=True,
                                   width=200)

    def timer_callback(refresh=1e-1):
        while True:
            for name, reg in bus.regs.__dict__.items():
                value = reg.read()
                dpg.set_value(item=name, value=f"0x{reg.read():x}")
            time.sleep(refresh)

    timer_thread = threading.Thread(target=timer_callback)
    timer_thread.start()

    dpg.show_viewport()
    dpg.start_dearpygui()
    dpg.destroy_context()

    bus.close()
Пример #2
0
    def run(self, app):
        title = "celestine - PyPI"
        dpg.create_context()
        dpg.create_viewport(title=title,
                            small_icon="celestine_small.ico",
                            large_icon="celestine_large.ico",
                            width=1920,
                            height=1080,
                            x_pos=256,
                            y_pos=256,
                            min_width=640,
                            max_width=3840,
                            min_height=480,
                            max_height=2160,
                            resizable=True,
                            vsync=True,
                            always_on_top=False,
                            decorated=True,
                            clear_color=(0, 0, 0))

        with dpg.texture_registry(show=False):
            app.setup(self)

        with dpg.window(tag="primary_window"):
            app.view(self)

        dpg.setup_dearpygui()
        dpg.show_viewport(minimized=False, maximized=False)
        dpg.set_primary_window("primary_window", True)
        dpg.start_dearpygui()
        dpg.destroy_context()
Пример #3
0
def on_end_graph(sender, data):
    """
    Kill all running processes (except the one running the gui). Also shows a progress bar while waiting for processes
    to die. They need a ct.HEARTBEAT_RATE * ct.HEARTBEATS_TO_DEATH seconds to die.
    :param sender: Not used
    :param data: Not used
    :return: Nothing
    """
    global forwarders

    for n in nodes_list:
        n.stop_com_process()

    if platform.system() == 'Windows':
        forwarders.send_signal(signal.CTRL_BREAK_EVENT)
    elif platform.system() == 'Linux':
        forwarders.terminate()

    with dpg.window(label='Progress bar', pos=[500, 400], width=400, height=80) as progress_bar:
        killing_proc_bar = dpg.add_progress_bar(label='Killing processes', parent=progress_bar, width=400, height=40,
                                                overlay='Closing worker_exec processes')
        t = 0
        while t < ct.HEARTBEAT_RATE * ct.HEARTBEATS_TO_DEATH:
            dpg.set_value(killing_proc_bar, t / (ct.HEARTBEAT_RATE * ct.HEARTBEATS_TO_DEATH))
            t = t + 0.1
            time.sleep(0.1)
        dpg.delete_item(killing_proc_bar)
    update_control_graph_buttons(False)
    dpg.delete_item(progress_bar)

    forwarders.kill()
    del forwarders
Пример #4
0
 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)
Пример #5
0
def start_dpg():
    """
    The outside loop runs forever and blocks when the dpg.start_dearpygui() is called.
    When the plot_callback() calls dpg.stop_dearpygui() then it continues running forever until the
    visualisation_on turns on at which point the start_dearpygui is called again and this blocks
    :return: Nothing
    """
    global visualisation_type
    global visualiser_showing
    global is_dearpygui_running
    global dpg_ids
    global initialised_plots

    is_dearpygui_running = True
    initialised_plots = False

    dpg.create_context()
    dpg.create_viewport(title='Visualising', width=330, height=280)

    with dpg.window(label="Visualisation",
                    show=True) as dpg_ids['Visualisation']:
        if visualisation_type == 'Value':
            dpg_ids['Text'] = dpg.add_text(default_value='__start__',
                                           label='Value')
            dpg.set_item_width(dpg_ids['Visualisation'], 300)
            dpg.set_item_height(dpg_ids['Visualisation'], 250)
        elif visualisation_type == 'Single Pane Plot':
            dpg.set_viewport_width(1050)
            dpg.set_viewport_height(770)
            dpg.set_item_width(dpg_ids['Visualisation'], 1050)
            dpg.set_item_height(dpg_ids['Visualisation'], 770)
            with dpg.plot(label="Plot",
                          height=700,
                          width=1000,
                          show=True,
                          pan_button=True,
                          fit_button=True) as dpg_ids['Plot 0']:
                dpg_ids['x_axis'] = dpg.add_plot_axis(dpg.mvXAxis,
                                                      label="Data index")
                dpg_ids['y_axis'] = dpg.add_plot_axis(dpg.mvYAxis,
                                                      label="Data")

        elif visualisation_type == 'Multi Pane Plot':
            dpg.set_viewport_width(1050)
            dpg.set_viewport_height(850)
            dpg.set_item_width(dpg_ids['Visualisation'], 1050)
            dpg.set_item_height(dpg_ids['Visualisation'], 820)

    dpg.set_viewport_resize_callback(on_resize_viewport)
    dpg.setup_dearpygui()
    dpg.show_viewport()

    visualiser_showing = True
    if data is not None:
        update_dpg_gui()

    dpg.start_dearpygui()
    dpg.destroy_context()
Пример #6
0
    def setUp(self):

        with dpg.window() as self.window_id:

            self.item1 = dpg.add_button(label="item1")
            self.item2 = dpg.add_button(label="item2")
            self.item3 = dpg.add_button(label="item3")
            self.item4 = dpg.add_button(label="item4")
            self.item5 = dpg.add_button(label="item5")

        dpg.setup_dearpygui()
Пример #7
0
    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
                        )
Пример #8
0
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)
Пример #9
0
    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()
Пример #10
0
def try_dpg_children(_dpg_def: DpgDef, _all_dpg_defs: t.List[DpgDef]):

    dpg.create_context()
    dpg.create_viewport()
    dpg.setup_dearpygui()

    with dpg.window(label="Dear PyGui Demo", width=800, height=800,
                    pos=(100, 100), tag="__demo_id") as w1:

        _ret = []
        if _dpg_def.is_container:
            with _dpg_def.fn() as _dpg_id:
                for _child_dpg_def in _all_dpg_defs:
                    try:
                        _child_dpg_def.fn_fake_call(parent=_dpg_id)
                        _ret.append(_child_dpg_def)
                    except Exception:
                        ...

    dpg.show_viewport()
    dpg.start_dearpygui()
    dpg.destroy_context()

    return _ret
Пример #11
0
def create_node_selector_window():
    with dpg.window(label='Node Selector', pos=[10, 60], width=300, height=890) as node_selector:
        # Create the window of the Node selector

        node_tree = generate_node_tree()
        base_id = node_tree[0][0]
        base_name = node_tree[0][1]
        with dpg.tree_node(label=base_name, parent=node_selector, default_open=True, id=base_id, open_on_arrow=True):

            # Read what *_com files exist in the Heron/Operations dir and sub dirs and create the correct
            # tree_node widget
            for parent_id, parent, node_id, node in node_tree:
                with dpg.tree_node(label=node, parent=parent_id, default_open=True, id=node_id):
                    for op in operations_list:
                        if node == op.parent_dir:
                            colour = gu.choose_color_according_to_operations_type(node)
                            button = dpg.add_button(label=op.name, width=200, height=30, callback=on_add_node)
                            with dpg.theme() as theme_id:
                                with dpg.theme_component(0):
                                    dpg.add_theme_color(dpg.mvThemeCol_Button, colour, category=dpg.mvThemeCat_Core)
                                    dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 5, category=dpg.mvThemeCat_Core)

                            dpg.bind_item_theme(button, theme_id)
        return node_selector
Пример #12
0
def configure_pygui(renderer, widgets, update=True):
    if not dearpygui_imported:
        raise RuntimeError(
            "Attempted to use DearPyGUI when it isn't imported.")
    if update:
        dpg.delete_item(window)
    else:
        dpg.setup_viewport()
    dpg.set_viewport_title(title=f"Manim Community v{__version__}")
    dpg.set_viewport_width(1015)
    dpg.set_viewport_height(540)

    def rerun_callback(sender, data):
        renderer.scene.queue.put(("rerun_gui", [], {}))

    def continue_callback(sender, data):
        renderer.scene.queue.put(("exit_gui", [], {}))

    def scene_selection_callback(sender, data):
        config["scene_names"] = (dpg.get_value(sender), )
        renderer.scene.queue.put(("rerun_gui", [], {}))

    scene_classes = scene_classes_from_file(Path(config["input_file"]),
                                            full_list=True)
    scene_names = [scene_class.__name__ for scene_class in scene_classes]

    with dpg.window(
            id=window,
            label="Manim GUI",
            pos=[config["gui_location"][0], config["gui_location"][1]],
            width=1000,
            height=500,
    ):
        dpg.set_global_font_scale(2)
        dpg.add_button(label="Rerun", callback=rerun_callback)
        dpg.add_button(label="Continue", callback=continue_callback)
        dpg.add_combo(
            label="Selected scene",
            items=scene_names,
            callback=scene_selection_callback,
            default_value=config["scene_names"][0],
        )
        dpg.add_separator()
        if len(widgets) != 0:
            with dpg.collapsing_header(
                    label=f"{config['scene_names'][0]} widgets",
                    default_open=True):
                for widget_config in widgets:
                    widget_config_copy = widget_config.copy()
                    name = widget_config_copy["name"]
                    widget = widget_config_copy["widget"]
                    if widget != "separator":
                        del widget_config_copy["name"]
                        del widget_config_copy["widget"]
                        getattr(dpg, f"add_{widget}")(name,
                                                      **widget_config_copy)
                    else:
                        dpg.add_separator()

    if not update:
        dpg.start_dearpygui()
Пример #13
0
            with dpg.menu(label='New'):
                dpg.add_menu_item(label='dealer', callback=lambda: nodes.add_dealer(node_editor_id, exchange))
                dpg.add_menu_item(label='current price', callback=lambda: nodes.add_current_price(node_editor_id))
                dpg.add_menu_item(label='symbol', callback=lambda: nodes.add_symbol(node_editor_id))
                dpg.add_menu_item(label='historical period', callback=lambda: nodes.add_history(node_editor_id))
                dpg.add_menu_item(label='rolling mean', callback=lambda: nodes.add_rolling_mean(node_editor_id))
                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: ')
Пример #14
0
# themes applied to plots REQUIRE category to be set to plots
# because plots are containers plots will propagate themes
with dpg.theme() as our_plot_theme:
    dpg.add_theme_color(dpg.mvPlotCol_PlotBg, (100, 0, 0, 50),
                        category=dpg.mvThemeCat_Plots)
    dpg.add_theme_color(dpg.mvPlotCol_Line, (0, 255, 0, 255),
                        category=dpg.mvThemeCat_Plots)
    dpg.add_theme_color(dpg.mvPlotCol_XAxis, (0, 255, 255, 255),
                        category=dpg.mvThemeCat_Plots)

with dpg.theme() as series_theme:
    dpg.add_theme_color(dpg.mvPlotCol_Line, (150, 0, 100, 255),
                        category=dpg.mvThemeCat_Plots)

with dpg.window(label="Tutorial"):

    # create plot
    with dpg.plot(label="Line Series", height=400, width=400) as plot:

        # REQUIRED: create x and y axes
        dpg.add_plot_axis(dpg.mvXAxis, label="x")
        axis_y = dpg.add_plot_axis(dpg.mvYAxis, label="y")

        # series belong to a y axis
        our_series = dpg.add_line_series((0, 1), (.5, .75),
                                         label="straight line",
                                         parent=axis_y)

dpg.set_item_theme(plot, our_plot_theme)
dpg.set_item_theme(our_series, series_theme)
print("texture_data Array:")
print("Array is of type: ", type(texture_data))
print("No. of dimensions: ", texture_data.ndim)
print("Shape of array: ", texture_data.shape)
print("Size of array: ", texture_data.size)
print("Array stores elements of type: ", texture_data.dtype)

with dpg.texture_registry(show=True):
    dpg.add_raw_texture(frame.shape[1],
                        frame.shape[0],
                        texture_data,
                        tag="texture_tag",
                        format=dpg.mvFormat_Float_rgb)

with dpg.window(label="Example Window"):
    dpg.add_text("Hello, world")
    dpg.add_image("texture_tag")

dpg.show_metrics()
dpg.show_viewport()
while dpg.is_dearpygui_running():

    # updating the texture in a while loop the frame rate will be limited to the camera frame rate.
    # commenting out the "ret, frame = vid.read()" line will show the full speed that operations and updating a texture can run at

    ret, frame = vid.read()
    data = np.flip(frame, 2)
    data = data.ravel()
    data = np.asfarray(data, dtype='f')
    texture_data = np.true_divide(data, 255.0)
Пример #16
0
    def log_warning(self, message):
        self._log(message, 3)

    def log_error(self, message):
        self._log(message, 4)

    def log_critical(self, message):
        self._log(message, 5)

    def clear_log(self):
        dpg.delete_item(self.filter_id, children_only=True)
        self.count = 0

    def set_level(self, level):
        self.log_level = level

def log_things(sender, app_data, user_data):
    user_data.log("We can log to a trace level.")
    user_data.log_debug("We can log to a debug level.")
    user_data.log_info("We can log to an info level.")
    user_data.log_warning("We can log to a warning level.")
    user_data.log_error("We can log to a error level.")
    user_data.log_critical("We can log to a critical level.")

with dpg.window():
    logger = MyCustomLogger()
    logger.log("This is my logger. Just like an onion it has many levels.")
    dpg.add_button(label="Log to logger", callback=log_things, user_data=logger)

dpg.start_dearpygui()
    X.append(x_val)
    X.pop(0)
    
    Y.append(y_val)
    Y.pop(0)
    
    Z.append(z_val)
    Z.pop(0)

    dpg.configure_item("X_value", x = t, y = X )
    dpg.configure_item("Y_value", x = t, y = Y )
    dpg.configure_item("Z_value", x = t, y = Z )

    

with dpg.window() as main_window:
    pass

with dpg.window(id='Ploter', label="simple plot", no_resize=True, no_title_bar=True, no_move=True):
    with dpg.plot(id='Graph', label="Plot Acelerometro", height=300, width=400, anti_aliased=True):
        dpg.add_plot_legend()

        dpg.add_plot_axis(dpg.mvXAxis, label="Tempo", id='x_axis')
        dpg.set_axis_limits("x_axis", 0, 2*3.1415)

        dpg.add_plot_axis(dpg.mvYAxis, label="Valores XYZ", id="y_axis")
        #dpg.set_axis_limits('y_axis', -1.25,1.25)
        
        dpg.add_line_series([], [], label="X_value", id="X_value", parent="y_axis")
        dpg.add_line_series([], [], label="Y_value", id="Y_value", parent="y_axis")
        dpg.add_line_series([], [], label="Z_value", id="Z_value", parent="y_axis")
Пример #18
0
    def __init__(self):

        self.bufferSize = 64 * 1024

        self.fileName = find_aes_file(
        )  # Set filnavnet af objektet til senere brug

        with dpg.window(no_resize=True) as self.mainWindow:
            # Laver hovedvindet med alle items
            dpg.add_same_line(spacing=45)
            dpg.add_text("Filnavn:")
            dpg.add_same_line(spacing=5)
            # Laver input textfelt, som selv ændrer WordSaver.filename
            dpg.add_input_text(label='.txt',
                               hint="Filename",
                               width=65,
                               callback=lambda sender: self.set_filename(
                                   dpg.get_value(sender)),
                               no_spaces=True,
                               default_value=self.fileName)
            dpg.add_spacing(count=5)
            dpg.add_same_line(spacing=75)
            dpg.add_button(label="Skriv", callback=self.toggle_write_window)
            dpg.add_same_line(spacing=10)
            dpg.add_button(label="Læs", callback=self.toggle_read_window)
            self.statusGood = dpg.add_text("",
                                           color=[0, 255, 0],
                                           show=False,
                                           pos=[10, 70])  # 2 status textfelter
            self.statusBad = dpg.add_text("",
                                          color=[255, 0, 0],
                                          show=False,
                                          pos=[10, 70])  # forskellige farver
            dpg.add_text("Text der skal krypteres:", pos=[40, 85])
            # Dette textfelt bruges til Input og Output til den krypterede fil
            self.rwfield = dpg.add_input_text(multiline=True,
                                              width=width - 50,
                                              height=90,
                                              pos=[15, 110],
                                              label='')
            dpg.add_button(label="Clear",
                           pos=[100, 203],
                           callback=lambda: dpg.set_value(self.rwfield, ""))

        with dpg.window(label="Skriv",
                        no_collapse=True,
                        show=False,
                        width=200,
                        height=20,
                        pos=[30, 10],
                        no_resize=True,
                        no_move=True) as self.writeWindow:
            # Skaber vinduet til at skrive til krypteringsfilen. Skjult som default.
            dpg.add_same_line(spacing=5)
            dpg.add_text("Kode:")
            dpg.add_same_line(spacing=10)
            # Adgangskodefelt. Kalder samme funktion som "Læs" knappen (show_read_text)
            self.writePW = dpg.add_input_text(password=True,
                                              hint="password",
                                              label="",
                                              on_enter=True,
                                              callback=self.write_text)
            dpg.add_spacing(count=3)
            dpg.add_same_line(spacing=70)
            dpg.add_button(label='Skriv',
                           height=30,
                           width=60,
                           callback=self.write_text)

        with dpg.window(label="Læs",
                        no_collapse=True,
                        show=False,
                        width=200,
                        height=20,
                        pos=[30, 10],
                        no_resize=True,
                        no_move=True) as self.readWindow:
            # Laver vinduet til at læse fra krypteringsfilen. Skjult som default
            dpg.add_same_line(spacing=5)
            dpg.add_text(f"Kode:")
            dpg.add_same_line(spacing=10)
            # Adgangskodefelt. Kalder samme funktion som "Læs" knappen (show_read_text)
            self.readPW = dpg.add_input_text(password=True,
                                             hint="password",
                                             label="",
                                             on_enter=True,
                                             callback=self.read_text)
            dpg.add_spacing(count=3)
            dpg.add_same_line(spacing=70)
            dpg.add_button(label='Læs',
                           height=30,
                           width=60,
                           callback=self.read_text)

        self.fileName = self.fileName + ".txt"  # Sætter rigtige filnavne med typer
        self.encryptetFileName = self.fileName + ".aes"  # .aes er krypteringstypen
Пример #19
0
import dearpygui.dearpygui as dpg

def change_text(sender, app_data):
    handler = sender
    text_item = dpg.get_item_parent(handler)
    dpg.set_value(text_item, f"Mouse Button ID: {app_data}")

with dpg.window(width=500, height=300):
    text_widget = dpg.add_text("Click me with any mouse button")
    dpg.add_clicked_handler(text_widget, callback=change_text, user_data=text_widget)

dpg.start_dearpygui()
                else:
                    with dpg.table_row(parent=TABLE_TAG):
                        for column in row:
                            dpg.add_text(column)
                    if num % 100 == 0:
                        dpg.set_value(value=f'Loaded so far: {num:,}', item=LOADED_FIELD)
            dpg.set_value(value=f'Loaded ALL', item=LOADED_FIELD)


if __name__ == '__main__':
    # os.environ["PYDEVD_USE_CYTHON"] = "YES"
    dpg.create_context()
    dpg.create_viewport(title='CSV reader')

    with dpg.window(
            label='Read CSV', tag=MAIN_WINDOW_TAG, width=1275, height=699
        ):
        dpg.add_text('CSV reader')
        dpg.add_input_text(
            label="Enter CSV file name", default_value='/home/tolic/Temp/10000.csv',
            tag=READ_FILENAME_FIELD
        )
        dpg.add_text('Loaded so far: ', tag=LOADED_FIELD)
        with dpg.group(horizontal=True):
            dpg.add_button(
                label="Read CSV", tag=READ_BUTTON_TAG,
                callback=__read_csv_cars__
            )
            with dpg.tooltip(READ_BUTTON_TAG):
                dpg.add_text("Read csv file")
Пример #21
0
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

with dpg.window(tag='main'):
    dpg.add_progress_bar(label='Progress Bar', tag='progress_bar')

dpg.set_primary_window('main', True)
dpg.show_viewport()

while dpg.is_dearpygui_running():
    dpg.set_value('progress_bar', dpg.get_value('progress_bar') + .001)
    dpg.render_dearpygui_frame()

dpg.destroy_context()
Пример #22
0
    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()
Пример #23
0
color_5_hex = "#F7F2F2"

color_1 = tuple(int(color_1_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_2 = tuple(int(color_2_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_3 = tuple(int(color_3_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_4 = tuple(int(color_4_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_5 = tuple(int(color_5_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))




def save_callback():
    print("Save Clicked")

# dpg.set_main_window_size(500,500)
with dpg.window(label="Main Controls", width=426, height=900) as window_id:
    with dpg.theme() as theme:
        dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 25)
        dpg.add_theme_color(dpg.mvThemeCol_Button, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_ButtonActive, color_4)
        dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_Border, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_FrameBg, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_WindowBg, color_1)


        # dpg.add_theme_style(dpg.mvStyleVar_FramePadding, i*3, i*3)

    master_toggle = dpg.add_checkbox(label="Master")
    autoclicker_toggle = dpg.add_checkbox(label="Autoclicker")
    timer_toggle = dpg.add_checkbox(label="Timer")
with dpg.texture_registry():
    image_id = dpg.add_static_texture(100,
                                      100, [],
                                      file='SpriteMapExample.png')


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)
Пример #25
0
# You can use the style editor to test themes at runtime and find the right constants for colors and styles
dpg.show_style_editor()

# Create a theme container and color and styles
with dpg.theme() as our_theme:

    dpg.add_theme_color(dpg.mvThemeCol_Button, (0, 255, 0, 255))
    dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, (0, 255, 255, 255))
    dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))

    # Some styles use only one variable "x" and some use 2 "x,"y" looking at the style editor can help
    dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 20)
    dpg.add_theme_style(dpg.mvStyleVar_FramePadding, 10, 10)

with dpg.window(label="Tutorial", width=500, height=500):
    dpg.add_button(label="Default Theme")

    # Setting theme at start up
    our_button = dpg.add_button(label="Set At Start-up")
    dpg.set_item_theme(our_button, our_theme)

    # Themes can be set at runtime using a lambda
    dpg.add_button(
        label="Set Theme at Runtime",
        callback=lambda sender: dpg.set_item_theme(sender, our_theme))

    # Themes can be set to all items of a specific type at runtime using a callback
    def set_theme():
        dpg.set_item_type_theme(dpg.mvButton, our_theme)
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()
Пример #27
0
https://hub.fastgit.org/Pcothren/DearPyGui-Examples
"""
dpg.show_style_editor()


def save_callback(sender, app_data, user_data):
    print(dpg)
    print("Save Clicked")
    for i in dpg.get_all_items():
        print(i)
    print(sender, app_data, user_data, dpg.get_value(2))
    print(sender, app_data, user_data, dpg.get_value(3))
    print(sender, app_data, user_data, dpg.get_value(4))
    print(sender, app_data, user_data, dpg.get_value(21))


with dpg.window(id=0, label="Example Window By LC", width=500, height=500):
    dpg.add_text(id=1, label="Hello world Hello LC", show_label=True)
    # label – 覆盖“name”作为标签。
    # id – 用于以编程方式引用项目的唯一 id。如果标签未使用,这将是标签
    text_input = dpg.add_input_text(id=2, label="MyInput")
    text_slider = dpg.add_slider_float(id=3, label="MySlider")
    text_input2 = dpg.add_input_text(id=4, label="name", default_value="LC")
    dpg.add_button(id=5,
                   label="Save",
                   callback=save_callback,
                   user_data=text_input)

dpg.setup_viewport()
dpg.start_dearpygui()
Пример #28
0
                                with dpg.theme_component(0):
                                    dpg.add_theme_color(dpg.mvThemeCol_Button, colour, category=dpg.mvThemeCat_Core)
                                    dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 5, category=dpg.mvThemeCat_Core)

                            dpg.bind_item_theme(button, theme_id)
        return node_selector


dpg.create_context()
dpg.create_viewport(title='Heron', width=1700, height=1000, x_pos=350, y_pos=0)

with dpg.font_registry():
    # add font (set as default for entire app)
    default_font = dpg.add_font(os.path.join(heron_path, 'resources', 'fonts', 'SF-Pro-Rounded-Regular.ttf'), 18)

with dpg.window(width=1700, height=1000, pos=[0, 0]) as main_window:
    dpg.set_primary_window(main_window, True)
    # The Start Graph button that starts all processes
    with dpg.group(horizontal=True):
        start_graph_button_id = dpg.add_button(label="Start Graph", callback=on_start_graph)
        end_graph_button_id = dpg.add_button(label="End Graph", callback=on_end_graph)
    update_control_graph_buttons(False)

    dpg.bind_font(default_font)

    with dpg.menu_bar(label='Menu Bar'):
        with dpg.menu(label='File'):
            dpg.add_menu_item(label='New', callback=clear_editor)
            dpg.add_menu_item(label='Save', callback=save_graph)
            dpg.add_menu_item(label='Load', callback=load_graph)
        with dpg.menu(label='Local Network') as menu:
Пример #29
0
from sensor_msgs.msg import JointState as JointStateMsg

x_coords = list(range(5000))

all_deltas = {'r_shoulder_pan_joint': [],
              'r_shoulder_lift_joint': [],
              'r_upper_arm_roll_joint': [],
              'r_elbow_flex_joint': [],
              'r_wrist_flex_joint': [],
              'r_forearm_roll_joint': [],
              'r_wrist_roll_joint': []}
last_command  = {}


if __name__ == '__main__':
    with dpg.window(label="Test"):

        for name, deltas in all_deltas.items():
            # create plot
            with dpg.plot(label=f"{name} deltas", height=200, width=900):

                # optionally create legend
                dpg.add_plot_legend()

                # REQUIRED: create x and y axes
                dpg.add_plot_axis(dpg.mvXAxis, label="x")
                dpg.set_axis_limits(dpg.last_item(), 0, len(x_coords))
                dpg.add_plot_axis(dpg.mvYAxis, label="y")
                dpg.set_axis_limits(dpg.last_item(), -1, 1)

                # series belong to a y axis
    debug = create_nobilia_shelf(km, Path('nobilia'), origin_pose)

    km.clean_structure()
    km.dispatch_events()

    shelf = km.get_data('nobilia')

    shelf_pos = shelf.joints['hinge'].position

    world = km.get_active_geometry({shelf_pos
                                    }.union(gm.free_symbols(origin_pose)))

    params = debug.tuning_params

    with dpg.window(label='Parameter settings'):
        for s, p in debug.tuning_params.items():

            def update_param(sender, value, symbol):
                params[symbol] = value
                draw_shelves(shelf, params, world, vis, steps=5)

            slider = dpg.add_slider_float(label=f'{s}',
                                          id=f'{s}',
                                          callback=update_param,
                                          user_data=s,
                                          min_value=p - 0.1,
                                          max_value=p + 0.1,
                                          width=200,
                                          default_value=p)