コード例 #1
0
ファイル: indicators.py プロジェクト: filipecn/maldives
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 update_internal(self) -> bool:
        # remove text
        if self.text_id != 0:
            dpg.delete_item(self.text_id)
            self.text_id = 0

        if self.dealer is None or self.symbols is None:
            return True

        if not self.dealer.good() or not self.symbols.good():
            return True

        self.current_prices = self.dealer.binance.symbol_ticker(
            self.symbols.symbols)

        # add plot if needed
        if self.text_id == 0:
            self.text_id = dpg.add_node_attribute(
                parent=self.node_id, attribute_type=dpg.mvNode_Attr_Static)
            for s in self.current_prices:
                dpg.add_text(
                    s + ' R$ %.2f' % float(self.current_prices[s].current),
                    parent=self.text_id)

        return True
コード例 #3
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}")
コード例 #4
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()
コード例 #5
0
ファイル: confgui.py プロジェクト: leandrocoding/sudoku
def setupconfig():
    dpg.set_main_window_size(600, 300)
    dpg.set_main_window_title("Sudoku Config")

    dpg.add_text(name="Sudoku Config")
    dpg.add_slider_int(name="Basesize",
                       default_value=c.basesize,
                       min_value=2,
                       max_value=5,
                       callback="updateconfig")
    dpg.add_slider_float(name="Delay in ms",
                         default_value=c.sleeptime * 1000,
                         min_value=0,
                         max_value=400,
                         callback="updateconfig")

    # dpg.add_button(name="Print Values",callback="butcallback")

    dpg.add_button(name="Start Solver", callback="startPygame")
    dpg.add_same_line()
    dpg.add_button(name="Stop Pygame", callback="stopSudoku")

    dpg.add_button(name="Reset Grid", callback="resetGrid")

    dpg.add_same_line()
    dpg.add_button(name="Set a Grid", callback="setGridone")
コード例 #6
0
ファイル: editor.py プロジェクト: georgedimitriadis/Heron
 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)
コード例 #7
0
ファイル: gui_utils.py プロジェクト: diogo-aos/logwork
 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)
コード例 #8
0
def _add_inputs_and_outputs(obj, layout: {}):
    for attr in layout['inputs']:
        with dpg.node_attribute(label=attr[0],
                                attribute_type=dpg.mvNode_Attr_Input):
            setattr(obj, attr[0] + '_id', dpg.last_item())
            dpg.add_text(attr[1])
    for attr in layout['outputs']:
        with dpg.node_attribute(label=attr[0],
                                attribute_type=dpg.mvNode_Attr_Output):
            dpg.add_text(attr[1])
コード例 #9
0
ファイル: simple_tests.py プロジェクト: mqt635/DearPyGui
    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}")
コード例 #10
0
def add_dealer(parent, dealer):
    pid = dpg.generate_uuid()
    with dpg.node(label="Dealer",
                  pos=[10, 10],
                  parent=parent,
                  user_data=DealerNode(pid, dealer),
                  id=pid):
        with dpg.node_attribute(attribute_type=dpg.mvNode_Attr_Static):
            dpg.add_text('BINANCE')
        _add_inputs_and_outputs(dpg.get_item_user_data(pid),
                                node_layouts[DealerNode])
コード例 #11
0
    def add_row(self, row_content: list[any]):
        self.ssh_info[row_content[1]] = {}
        with dpg.table_row(parent=self.id):
            for i, item in enumerate(row_content):
                item_name = f"##{self.name}_{self.row}_{self.column}"

                if i > 1:
                    self.ssh_info[row_content[1]][self.header[i]] = item
                if type(item) is str:
                    self.rows_ids[item_name] = dpg.add_input_text(
                        label=item_name,
                        default_value=item,
                        width=-1,
                        callback=self.on_edit)
                if type(item) is int:
                    self.rows_ids[item_name] = dpg.add_input_int(
                        label=item_name,
                        default_value=item,
                        width=-1,
                        step=0,
                        callback=self.on_edit)
                if type(item) is float:
                    self.rows_ids[item_name] = dpg.add_input_float(
                        label=item_name,
                        default_value=item,
                        width=-1,
                        step=0,
                        callback=self.on_edit)
                if type(item) is bool:
                    self.rows_ids[item_name] = dpg.add_checkbox(
                        label=item_name, default_value=False)
                if i == 1:
                    dpg.configure_item(self.rows_ids[item_name], enabled=False)
                if i == 6:
                    with dpg.tooltip(self.rows_ids[item_name]):
                        dpg.add_text(
                            "If the password is 'None' for the local machine\'s IP then the \n"
                            'local machine does not need to run an SSH server and the \n'
                            'communication between computers happens through normal sockets. \n'
                            'If there is a password other than "None" then Heron assumes an \n'
                            'SSH server is running on the local machine and all data and \n'
                            'parameters are passed through SSH tunnels.\nWARNING! '
                            'The SSH tunneling is slow and results in constant dropping of\n'
                            'data packets!')
                self.column += 1

            with dpg.table_row(parent=self.id):
                sep_name = f"##{self.name}_{self.row}_sep"
                self.rows_ids[sep_name] = dpg.add_separator(label=sep_name)

        self.num_of_rows += 1
        self.row += 1
        self.column = 0
コード例 #12
0
ファイル: indicators.py プロジェクト: filipecn/maldives
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')
コード例 #13
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
                        )
コード例 #14
0
    def _log(self, message, level):

        if level < self.log_level:
            return

        self.count += 1

        if self.count > self.flush_count:
            self.clear_log()

        theme = self.info_theme

        if level == 0:
            message = "[TRACE]\t\t" + message
            theme = self.trace_theme
        elif level == 1:
            message = "[DEBUG]\t\t" + message
            theme = self.debug_theme
        elif level == 2:
            message = "[INFO]\t\t" + message
        elif level == 3:
            message = "[WARNING]\t\t" + message
            theme = self.warning_theme
        elif level == 4:
            message = "[ERROR]\t\t" + message
            theme = self.error_theme
        elif level == 5:
            message = "[CRITICAL]\t\t" + message
            theme = self.critical_theme

        new_log = dpg.add_text(message, parent=self.filter_id, filter_key=message)
        dpg.set_item_theme(new_log, theme)
        if self._auto_scroll:
            scroll_max = dpg.get_y_scroll_max(self.child_id)
            dpg.set_y_scroll(self.child_id, -1.0)
コード例 #15
0
def update():
    global _text, _cell
    dpg.delete_item(_text)

    _text = dpg.add_text(
        parent=_cell,
        default_value=f"hiiiiiiii {np.random.randint(324214234)}")
コード例 #16
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))
コード例 #17
0
ファイル: indicators.py プロジェクト: filipecn/maldives
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')
コード例 #18
0
ファイル: indicators.py プロジェクト: filipecn/maldives
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')
コード例 #19
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()
コード例 #20
0
ファイル: header_analyzer.py プロジェクト: mqt635/DearPyGui
    def create_ui_node(self, parent):

        y = IncludeNode.levels[self.level]
        IncludeNode.levels[self.level] += 80

        with dpg.node(label=self.name, pos=(250*self.level, y), parent=editor_id):
            if self.level > 0:
                with dpg.node_attribute(label=self.name + "-in") as node_from_id:
                    dpg.add_text("from")
            if len(self.links) > 0:
                with dpg.node_attribute(label=self.name + "-out", attribute_type=dpg.mvNode_Attr_Output) as node_out_id:
                    dpg.add_text("Includes:")

            if parent != 0:
                dpg.add_node_link(parent, node_from_id, parent=editor_id)

        for i in range(0, len(self.links)):
            self.links[i].create_ui_node(node_out_id)
コード例 #21
0
ファイル: main.py プロジェクト: filipecn/maldives
def _node_editor():
    dpg.add_separator(label='BOT')
    dpg.add_text('STRATEGY ALGORITHM')
    with dpg.node_editor(callback=_link_node, delink_callback=_delink_node, menubar=True, height=500) as node_editor_id:
        with dpg.menu_bar():
            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)
コード例 #22
0
 def show_history_messages(self, history: History):
     dpg.delete_item(MESSAGE_GROUP, children_only=True)
     width = dpg.get_item_width(MESSAGE_GROUP)
     for message in history.messages:
         if message.is_sent_by_me():
             dpg.add_text(
                 message.as_string(),
                 parent=MESSAGE_GROUP,
                 indent=MESSAGE_INDENT,
                 wrap=width - MESSAGE_INDENT,
                 color=COLOR_MESSAGE_OTHERS,
             )
         else:
             dpg.add_text(
                 message.as_string(),
                 parent=MESSAGE_GROUP,
                 indent=0,
                 wrap=width - MESSAGE_INDENT,
                 color=COLOR_MESSAGE_ME,
             )
コード例 #23
0
def __read_csv_cars__():
    if dpg.does_alias_exist(TABLE_TAG):
        dpg.delete_item(TABLE_TAG, children_only=False)
    if dpg.does_alias_exist(TABLE_TAG):
        dpg.remove_alias(TABLE_TAG)
    with dpg.table(header_row=True, resizable=True, tag=TABLE_TAG, parent=MAIN_WINDOW_TAG):
        with open(dpg.get_value(READ_FILENAME_FIELD)) as f:
            csv_reader = csv.reader(f, delimiter=',')
            # f'Table of {f.name}'
            for num, row in enumerate(csv_reader):
                if num == 0:
                    for column in row:
                        dpg.add_table_column(label=column, parent=TABLE_TAG)
                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)
コード例 #24
0
    def update_internal(self) -> bool:
        if self.data_id:
            dpg.delete_item(self.data_id)
            self.data_id = 0

        if self.series is None or self.reference_prices is None:
            return True
        if not self.series.good() or not self.reference_prices.good():
            return True

        self.data['res'] = {}
        self.data['sup'] = {}

        for s in self.series.symbols.symbols:
            self.data['res'][s] = self.series.prices[s][
                'ta'].resistance_lines_for_price(
                    float(self.reference_prices.current_prices[s].current),
                    self.min_strength, self.threshold)
            self.data['sup'][s] = self.series.prices[s][
                'ta'].support_lines_for_price(
                    float(self.reference_prices.current_prices[s].current),
                    self.min_strength, self.threshold)

        if self.data_id == 0:
            self.data_id = dpg.add_node_attribute(
                parent=self.node_id, attribute_type=dpg.mvNode_Attr_Static)
            for s in self.data['res']:
                dpg.add_text('%s %d res lines' % (s, len(self.data['res'][s])),
                             parent=self.data_id)
                if len(self.data['res'][s]):
                    dpg.add_text(
                        'closest %.2f (%d)' %
                        (self.data['res'][s][0][0], self.data['res'][s][0][1]),
                        parent=self.data_id)

                dpg.add_text('%s %d sup lines' % (s, len(self.data['sup'][s])),
                             parent=self.data_id)
                if len(self.data['sup'][s]):
                    dpg.add_text(
                        'closest %.2f (%d)' %
                        (self.data['sup'][s][0][0], self.data['sup'][s][0][1]),
                        parent=self.data_id)

        return True
コード例 #25
0
    def update_internal(self) -> bool:
        if self.text_id:
            dpg.delete_item(self.text_id)
            self.text_id = 0

        if self.a is None or self.b is None:
            return True

        if not self.a.good() or not self.b.good():
            return True

        def get_values(data):
            values = {}
            if type(data) is CurrentPriceNode:
                for s in data.current_prices:
                    values[s] = float(data.current_prices[s].current)
            elif type(data) is RollingMeanNode:
                for s in data.data:
                    values[s] = float(data.data[s].to_list()[-1])
            return values

        a_values = get_values(self.a)
        b_values = get_values(self.b)

        self.data = {}
        self.data_pct = {}
        for a in a_values:
            if a in b_values:
                self.data[a] = b_values[a] - a_values[a]
                self.data_pct[a] = b_values[a] / a_values[a]

        if self.text_id == 0:
            self.text_id = dpg.add_node_attribute(
                parent=self.node_id, attribute_type=dpg.mvNode_Attr_Static)
            for s in self.data:
                dpg.add_text('a = %.2f' % a_values[s], parent=self.text_id)
                dpg.add_text('b = %.2f' % b_values[s], parent=self.text_id)
                dpg.add_text('b - a = %.2f' % self.data[s],
                             parent=self.text_id)
                dpg.add_text('a -> b = %.2f%%' %
                             ((self.data_pct[s] - 1) * 100),
                             parent=self.text_id)
                break
        return True
コード例 #26
0
ファイル: Logger.py プロジェクト: mugen8085/Bonus
    def _log(self, message, level):

        if level < self.log_level:
            return

        self.count += 1

        if self.count > self.flush_count:
            self.clear_log()

        theme = self.info_theme

        LocalTime = time.localtime()
        TimeStr = str(LocalTime.tm_year) + "-" + str(
            LocalTime.tm_mon).zfill(2) + "-" + str(
                LocalTime.tm_mday).zfill(2) + " " + str(
                    LocalTime.tm_hour).zfill(2) + ":" + str(
                        LocalTime.tm_min).zfill(2) + ":" + str(
                            LocalTime.tm_sec).zfill(2)

        if level == 0:
            message = TimeStr + " [TRACE] " + message
            theme = self.trace_theme
        elif level == 1:
            message = TimeStr + " [DEBUG] " + message
            theme = self.debug_theme
        elif level == 2:
            message = TimeStr + " [INFO] " + message
        elif level == 3:
            message = TimeStr + " [WARNING] " + message
            theme = self.warning_theme
        elif level == 4:
            message = TimeStr + " [ERROR] " + message
            theme = self.error_theme
        elif level == 5:
            message = TimeStr + " [CRITICAL] " + message
            theme = self.critical_theme

        new_log = dpg.add_text(message,
                               parent=self.filter_id,
                               filter_key=message)
        print(message)
        dpg.set_item_theme(new_log, theme)
        if self._auto_scroll:
            scroll_max = dpg.get_y_scroll_max(self.child_id)
            dpg.set_y_scroll(self.child_id, -1.0)
コード例 #27
0
ファイル: Daily.py プロジェクト: mugen8085/Bonus
 def UIBeginDate(self):
     # dpg.add_text("BeginDate(yyyy/mm/dd):", parent=self.window_id )
     self.ID_BtnBeginDate = dpg.add_button(parent=self.window_id, label="BeginDate(yyyy/mm/dd):", callback=self.callback_begindate)
     dpg.add_same_line(parent=self.window_id)
     dpg.add_text("   ", parent=self.window_id)
     dpg.add_same_line(parent=self.window_id)
     self.ID_BeginYear = dpg.add_input_text(parent=self.window_id, label="", decimal=True, width=40, callback=self.callback_inputtext)
     dpg.add_same_line(parent=self.window_id)
     dpg.add_text("/", parent=self.window_id)
     dpg.add_same_line(parent=self.window_id)
     self.ID_BeginMonth = dpg.add_input_text(parent=self.window_id, label="", decimal=True, width=20, callback=self.callback_inputtext)
     dpg.add_same_line(parent=self.window_id)
     dpg.add_text("/", parent=self.window_id)
     dpg.add_same_line(parent=self.window_id)
     self.ID_BeginDay = dpg.add_input_text(parent=self.window_id, label="", decimal=True, width=20, callback=self.callback_inputtext)
     dpg.set_value(self.ID_BeginYear, self.nBeginYear)
     dpg.set_value(self.ID_BeginMonth, self.nBeginMonth)
     dpg.set_value(self.ID_BeginDay, self.nBeginDay)
コード例 #28
0
ファイル: Daily.py プロジェクト: mugen8085/Bonus
 def UIEndDate(self):
     # dpg.add_text("EndDate(yyyy/mm/dd):  ", parent=self.window_id )
     # 取得當前時間.
     self.ID_BtnEndDate = dpg.add_button(parent=self.window_id, label="EndDate  (yyyy/mm/dd):", callback=self.callback_enddate)
     dpg.add_same_line(parent=self.window_id)
     dpg.add_text("   ", parent=self.window_id)
     dpg.add_same_line(parent=self.window_id)
     self.ID_EndYear = dpg.add_input_text(parent=self.window_id, label="", decimal=True, width=40, callback=self.callback_inputtext)
     dpg.add_same_line(parent=self.window_id)
     dpg.add_text("/", parent=self.window_id)
     dpg.add_same_line(parent=self.window_id)
     self.ID_EndMonth = dpg.add_input_text(parent=self.window_id, label="", decimal=True, width=20, callback=self.callback_inputtext)
     dpg.add_same_line(parent=self.window_id)
     dpg.add_text("/", parent=self.window_id)
     dpg.add_same_line(parent=self.window_id)
     self.ID_EndDay = dpg.add_input_text(parent=self.window_id, label="", decimal=True, width=20, callback=self.callback_inputtext)
     dpg.set_value(self.ID_EndYear, self.ExecuteTime.tm_year)
     dpg.set_value(self.ID_EndMonth, self.ExecuteTime.tm_mon)
     dpg.set_value(self.ID_EndDay, self.ExecuteTime.tm_mday)
コード例 #29
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()
コード例 #30
0
ファイル: main.py プロジェクト: filipecn/maldives
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=)
                #     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})