Beispiel #1
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()
Beispiel #2
0
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
                dpg.add_line_series(x_coords[:len(deltas)], deltas, label=f'{name}', parent=dpg.last_item(), id=f'{name}_deltas')


    log_lock = RLock()
Beispiel #3
0
                # 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=)
                #     dpg.add_button(label="OK", width=75, user_data=modal_id, callback=_period)
                dpg.add_radio_button(("1y", '6m', '1m', '1w', '1d'), callback=_period, horizontal=True)
                dpg.add_same_line()
                dpg.add_text(' on intervals of: ')
                dpg.add_same_line()
                dpg.add_radio_button(("15m", '30m', '1h', '1d'), callback=_interval, horizontal=True)

                # with dpg.menu(label='date'):
                #     dpg.add_time_picker(default_value={'hour': 14, 'min': 32, 'sec': 23})
                with dpg.plot(label="Candle Series", height=400, width=-1, drop_callback=_candle_plot_drop,
                              payload_type='candle_plot', no_title=True, anti_aliased=True) as window_data.candle_plot:
                    dpg.add_plot_legend()
                    window_data.candle_xaxis = dpg.add_plot_axis(dpg.mvXAxis, label="", time=True)
                    window_data.candle_yaxis = dpg.add_plot_axis(dpg.mvYAxis, label="BRL")
                with dpg.plot(label='volume_plot', height=300, width=-1, no_title=True, payload_type='volume_plot',
                              drop_callback=_volume_plot_drop, callback=_volume_plot_drop) as window_data.volume_plot:
                    dpg.add_plot_legend()
                    window_data.volume_xaxis = dpg.add_plot_axis(dpg.mvXAxis, label="", time=True)
                    window_data.volume_yaxis = dpg.add_plot_axis(dpg.mvYAxis, label="VOL")

                _node_editor()

            with dpg.child(label='column_2', width=200, height=500):
                left_parent = dpg.last_item()
        # footer
        with dpg.child(label='footer', height=200):
Beispiel #4
0
# 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)

dpg.start_dearpygui()
Beispiel #5
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()
    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")


def resize_group( sender, data, user ):
    dpg.configure_item('Ploter', height = data[1], width = data[0] ) 
Beispiel #7
0
    def custom(self):

        with dpg.plot(height=400, width=400, no_title=True):
            dpg.add_plot_axis(dpg.mvXAxis, label="", id=self.x_axis)
            dpg.add_plot_axis(dpg.mvYAxis, label="", id=self.y_axis)
Beispiel #8
0
def plot_perf(plot_axis):
    (names, series) = load_perf("game.log")

    index = 1 + 3 * len(names)
    for (name, data) in series.items():
        xs = [pair[0] for pair in data]
        ys = [pair[1] + (index / 2) for pair in data]
        dpg.add_line_series(xs, ys, label=name, parent=plot_axis) #, weight=2, fill=[255, 0, 0, 100])
        index -= 3

def plot_callback(sender, data):
    plot_perf(plot_axis)

dpg.setup_viewport()
width = dpg.get_viewport_width()
height = dpg.get_viewport_height()

with dpg.window(label="RRL Performance", width=width, height=height, no_move=True, no_collapse=True, no_title_bar=True) as window:

    dpg.add_text("Performance Plot")
    dpg.add_button(label="Reload file", callback=plot_callback)

    with dpg.plot(label="Perf", width=width - 40, height=height - 120):
        dpg.add_plot_legend()
        dpg.add_plot_axis(dpg.mvXAxis, label='x')
        plot_axis = dpg.add_plot_axis(dpg.mvYAxis, label='y')

    plot_perf(plot_axis)

dpg.start_dearpygui()