예제 #1
0
def sma():
    with dpg.child(width=200, height=70):
        item = dpg.add_button(label='SMA')
        dpg.set_item_theme(dpg.last_item(), button_themes[5])
        dpg.add_same_line()
        i = dpg.add_input_int(default_value=3, label='', width=70)
        dpg.add_button(label='SMA200')
        dpg.set_item_theme(dpg.last_item(), button_themes[4])
        with dpg.tooltip(dpg.last_item()):
            dpg.add_text('Media Movel de 200 dias')
        with dpg.drag_payload(parent=dpg.last_item(),
                              drag_data=('SMA', 200),
                              payload_type='candle_plot'):
            dpg.add_text('SMA200')
        dpg.add_same_line()
        dpg.add_button(label='SMA50')
        dpg.set_item_theme(dpg.last_item(), button_themes[3])
        with dpg.drag_payload(parent=dpg.last_item(),
                              drag_data=('SMA', 50),
                              payload_type='candle_plot'):
            dpg.add_text('SMA50')
        dpg.add_same_line()
        dpg.add_button(label='SMA7')
        dpg.set_item_theme(dpg.last_item(), button_themes[2])
        with dpg.drag_payload(parent=dpg.last_item(),
                              drag_data=('SMA', 7),
                              payload_type='candle_plot'):
            dpg.add_text('SMA7')
    with dpg.drag_payload(parent=item,
                          drag_data=('SMA', dpg.get_value(i)),
                          payload_type='candle_plot'):
        dpg.add_text('SMA')
예제 #2
0
    def submit(self, parent):

        dpg.add_button(label=self.label, parent=parent, width=-1)
        dpg.set_item_theme(dpg.last_item(), _source_theme)

        with dpg.drag_payload(parent=dpg.last_item(), drag_data=(self, self._generator, self._data)):
            dpg.add_text(f"Name: {self.label}")
예제 #3
0
    def testBindDragPayload(self):
        def testy(sender, app, user):
            print(f"Sender: {dpg.get_item_type(sender)} {sender}, App Data: {app}, User Data:{user}")

        for item in self.test_bind_items:
            # uncomment these to find where it fails
            #print(f'[TestDragDrop] Attempting bind {dpg.get_item_type(item)}')
            dpg.configure_item(item, payload_type="str", drop_callback=testy, drag_callback=testy)
            with dpg.drag_payload(parent=item, drop_data="dropped", drag_data="dragged", user_data="user data", payload_type="str"):
                dpg.add_text(dpg.get_item_type(item))
                dpg.add_text(f"Item ID: {item}")
예제 #4
0
def rlines():
    with dpg.child(width=200, height=90):
        item = dpg.add_button(label='RLINES')
        dpg.set_item_theme(dpg.last_item(), button_themes[5])
        with dpg.tooltip(dpg.last_item()):
            dpg.add_text('Linhas de Resistencia')
        s = dpg.add_slider_float(label='%',
                                 default_value=2,
                                 min_value=0.1,
                                 max_value=5)
        i = dpg.add_input_int(default_value=0, label='')
    with dpg.drag_payload(parent=item,
                          drag_data=('RLINES', s, i),
                          payload_type='candle_plot'):
        dpg.add_text('RLINES')
예제 #5
0
파일: main.py 프로젝트: filipecn/maldives
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))
예제 #6
0
def rsi():
    with dpg.child(width=200, height=90):
        item = dpg.add_button(label='RSI')
        dpg.set_item_theme(dpg.last_item(), button_themes[5])
        i = dpg.add_slider_int(default_value=14,
                               label='',
                               min_value=3,
                               max_value=200)
        j = dpg.add_slider_float(default_value=24,
                                 label='',
                                 min_value=3,
                                 max_value=200)
    with dpg.drag_payload(parent=item,
                          drag_data=('RSI', i, j),
                          payload_type='volume_plot'):
        dpg.add_text('RSI')
예제 #7
0
def bbands():
    with dpg.child(width=200, height=95):
        item = dpg.add_button(label='BOLLINGER BANDS')
        dpg.set_item_theme(dpg.last_item(), button_themes[5])
        i = dpg.add_slider_int(default_value=10,
                               label='',
                               min_value=3,
                               max_value=200)
        j = dpg.add_slider_float(default_value=5,
                                 label='',
                                 min_value=1,
                                 max_value=5)
    with dpg.drag_payload(parent=item,
                          drag_data=('BOLLINGER_BANDS', dpg.get_value(i),
                                     dpg.get_value(j)),
                          payload_type='candle_plot'):
        dpg.add_text('BOLLINGER BANDS')
예제 #8
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()