Esempio n. 1
0
def window(name: str,
           width: int = -1,
           height: int = -1,
           start_x: int = 200,
           start_y: int = 200,
           autosize: bool = False,
           resizable: bool = True,
           title_bar: bool = True,
           movable: bool = True,
           hide: bool = False,
           on_close: str = ""):
    try:
        yield gui.add_window(name,
                             width,
                             height,
                             start_x=start_x,
                             start_y=start_y,
                             autosize=autosize,
                             resizable=resizable,
                             title_bar=title_bar,
                             movable=movable,
                             hide=hide,
                             on_close=on_close)
    finally:
        gui.end()
Esempio n. 2
0
 def callback_enddate(self):
     if self.ID_EndDate:
         if dpg.is_item_shown(self.ID_EndDate):
             dpg.hide_item(self.ID_EndDate)
         else:
             dpg.show_item(self.ID_EndDate)
         dpg.focus_item(self.ID_EndDate)
     else:
         self.ID_EndDate = dpg.add_window(label="EndDate", pos=(60, 70))
         self.ID_EndDatePicker = dpg.add_date_picker(parent=self.ID_EndDate, label="datepicker", level=dpg.mvDatePickerLevel_Day,
                             default_value={'month_day': self.ExecuteTime.tm_mon, 'year': self.ExecuteTime.tm_year-1900, 'month': self.ExecuteTime.tm_mday}, callback=self.GetDate)
Esempio n. 3
0
 def callback_begindate(self):
     if self.ID_BeginDate:
         if dpg.is_item_shown(self.ID_BeginDate):
             dpg.hide_item(self.ID_BeginDate)
         else:
             dpg.show_item(self.ID_BeginDate)
         dpg.focus_item(self.ID_BeginDate)
     else:
         logger.log("BeginDatePicker")
         logger.log(str(self.nBeginYear) + ' ' + str(self.nBeginMonth) + ' ' + str(self.nBeginDay))
         self.ID_BeginDate = dpg.add_window(label="BeginDate", pos=(60, 50))
         self.ID_BeginDatePicker = dpg.add_date_picker(parent=self.ID_BeginDate, label="datepicker", level=dpg.mvDatePickerLevel_Day,
                             default_value={'month_day': self.nBeginDay, 'year': self.nBeginYear-1900, 'month': self.nBeginMonth}, callback=self.GetDate)
Esempio n. 4
0
    def __init__(self, parent=None):

        self.log_level = 0
        self._auto_scroll = True
        self.filter_id = None
        if parent:
            self.window_id = parent
        else:
            self.window_id = dpg.add_window(label="mvLogger",
                                            pos=(10, 150),
                                            width=800,
                                            height=200)
        self.count = 0
        self.flush_count = 1000

        with dpg.group(horizontal=True, parent=self.window_id):
            dpg.add_checkbox(label="Auto-scroll",
                             default_value=True,
                             callback=lambda sender: self.auto_scroll(
                                 dpg.get_value(sender)))
            dpg.add_button(label="Clear",
                           callback=lambda: dpg.delete_item(
                               self.filter_id, children_only=True))

        dpg.add_input_text(label="Filter",
                           callback=lambda sender: dpg.set_value(
                               self.filter_id, dpg.get_value(sender)),
                           parent=self.window_id)
        self.child_id = dpg.add_child(parent=self.window_id,
                                      autosize_x=True,
                                      autosize_y=True)
        self.filter_id = dpg.add_filter_set(parent=self.child_id)

        with dpg.theme() as self.trace_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (0, 255, 0, 255))

        with dpg.theme() as self.debug_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (64, 128, 255, 255))

        with dpg.theme() as self.info_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 255, 255))

        with dpg.theme() as self.warning_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 0, 255))

        with dpg.theme() as self.error_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))

        with dpg.theme() as self.critical_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))
Esempio n. 5
0
    def __init__(self):

        self.log_level = 0
        self._auto_scroll = True
        self.filter_id = None
        self.window_id = dpg.add_window(label="mvLogger", pos=(200, 200), width=500, height=500)
        self.count = 0
        self.flush_count = 1000
        self.level_options = {"Trace": 0, "Debug": 1, "Info": 2,  "Warning": 3, "Error": 4, "Critical": 5}

        with dpg.group(horizontal=True, parent=self.window_id):
            dpg.add_checkbox(label="Auto-scroll", default_value=True,
                             callback=lambda sender: self.auto_scroll(dpg.get_value(sender)))
            dpg.add_button(label="Clear", callback=lambda: dpg.delete_item(self.filter_id, children_only=True))
        dpg.add_input_text(label="Filter", callback=lambda sender: dpg.set_value(self.filter_id, dpg.get_value(sender)),
                           parent=self.window_id)
        dpg.add_radio_button(list(self.level_options.keys()), parent=self.window_id,
                             callback=lambda sender: self.set_level(self.level_options[dpg.get_value(sender)]))
        dpg.add_same_line(parent=self.window_id)
        self.child_id = dpg.add_child(parent=self.window_id, autosize_x=True, autosize_y=True)
        self.filter_id = dpg.add_filter_set(parent=self.child_id)

        with dpg.theme() as self.trace_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (0, 255, 0, 255))

        with dpg.theme() as self.debug_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (64, 128, 255, 255))

        with dpg.theme() as self.info_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 255, 255))

        with dpg.theme() as self.warning_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 255, 0, 255))

        with dpg.theme() as self.error_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))

        with dpg.theme() as self.critical_theme:
            dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))
Esempio n. 6
0
 def __setup_add_widget__(self, dpg_args) -> None:
     dpgcore.add_window(self.id, on_close=self._on_close, **dpg_args)
Esempio n. 7
0
import dearpygui.dearpygui as dpg
import numpy as np

dpg.create_context()


def update():
    global _text, _cell
    dpg.delete_item(_text)

    _text = dpg.add_text(
        parent=_cell,
        default_value=f"hiiiiiiii {np.random.randint(324214234)}")


_win = dpg.add_window(label="Tutorial")
_butt = dpg.add_button(label="Update Series", callback=update, parent=_win)
_table = dpg.add_table(parent=_win)
_col = dpg.add_table_column(parent=_table)
_row = dpg.add_table_row(parent=_table)
_cell = dpg.add_table_cell(parent=_row)
_text = dpg.add_text(parent=_cell, default_value="hiiiiiiii ")

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
Esempio n. 8
0
    def __init__(self, parent=None):
        self.DataPath = None
        self.DataStartDate = None
        self.StartDate = None
        self.WindowPositionX = None
        self.WindowPositionY = None

        self.nBeginYear = 2019
        self.nBeginMonth = 1
        self.nBeginDay = 1
        self.nEndYear = 1970
        self.nEndMonth = 1
        self.nEndDay = 1

        self.LoadInitFile()

        self.ExecuteTime = time.localtime()
        # TimeStr = str(self.ExecuteTime.tm_year) + "-" + str(self.ExecuteTime.tm_mon).zfill(2) + "-" + str(self.ExecuteTime.tm_mday).zfill(
        #     2) + " " + str(self.ExecuteTime.tm_hour).zfill(2) + ":" + str(self.ExecuteTime.tm_min).zfill(2) + ":" + str(
        #     self.ExecuteTime.tm_sec).zfill(2)
        #================= UI =================.
        self.count = 0
        if parent:
            self.window_id = parent
        else:
            self.window_id = dpg.add_window(label="MyApp")
        # print(self.window_id)
        dpg.set_primary_window(self.window_id, True)
        # window_id = dpg.window(label="MyApp")

        if not dpg.is_viewport_created():
            vp = dpg.create_viewport(title="MyApp", width=430, height=750, x_pos=int(self.WindowPositionX), y_pos=int(self.WindowPositionY))
            dpg.setup_dearpygui(viewport=vp)
            dpg.show_viewport(vp)
            dpg.set_viewport_height(950)
            dpg.set_viewport_width(950)

        # self.slider_float = dpg.add_slider_float(label="float", parent=self.window_id, width=100)

        # self.ID_GetWinSize = dpg.add_button(parent=self.window_id, label="GetWinSize", callback=self.callback_getwinsize )
        # dpg.add_same_line(parent=self.window_id)
        dpg.add_text(parent=self.window_id, default_value="Time:")
        dpg.add_same_line(parent=self.window_id)
        self.ID_TimeText = dpg.add_button(parent=self.window_id, label="0", callback=self.callback_update_enddate)
        self.ID_BtnBeginDate = 0
        self.ID_BeginDate = None
        self.ID_BeginDatePicker= None
        self.ID_BeginYear = None
        self.ID_BeginMonth = None
        self.ID_BeginDay = None


        self.ID_BtnEndDate = 0
        self.ID_EndDate = None
        self.ID_EndDatePicker = None
        self.ID_EndYear = None
        self.ID_EndMonth = None
        self.ID_EndDay = None

        self.ShowInfo()
        self.UIBeginDate()
        self.UIEndDate()

        # dpg.add_same_line(parent=self.window_id)
        # self.ID_BeginDate = dpg.add_button(label="BeginDate", parent=self.window_id, callback=self.callback_begindate)
        self.BeginDate = datetime.strptime(self.StartDate, "%Y-%m-%d")
        self.EndDate = datetime.today()
        self.Stock = StockTool(self.DataPath, self.BeginDate, self.EndDate)

        self.ID_BtnDownloadData = dpg.add_button(parent=self.window_id, label="Download", callback=self.callback_downloaddata)