Esempio n. 1
0
 def __toggle_stock(self, sender, data):
     """Toggle a todo to True of False.
     Get the selected cell of the table (list of [row index, column index])
     and uses the row index to update the todo at that index in the todos
     list. Then, saves the selected row index in the case you would want to
     delete that todo.
     """
     stock_row = dpg.get_table_selections("Stocks")
     stock = self.stocks[stock_row[0][0]]
     dpg.add_data("selected-stock-index", self.stocks.index(stock))
     dpg.set_value("Selected stock:", f"Selected Stock: {stock['Stock']}")
Esempio n. 2
0
 def set_start_time(manual_time: Optional[datetime.datetime] = None):
     """
     Sets start_time property to either now or a manual entry
     :param manual_time: datetime object manual setting
     """
     if manual_time is None:
         c.add_data("start_time", datetime.datetime.now())
     elif isinstance(manual_time, datetime.datetime):
         c.add_data("start_time", manual_time)
     else:
         raise ValueError
Esempio n. 3
0
 def set_tracking(self, value: Optional[bool] = None):
     """
     Flips tracking data bool by default or sets to exact value
     :param value:
     """
     if value is None:
         c.add_data("tracking", not self.tracking)
     elif isinstance(value, bool):
         c.add_data("tracking", value)
     else:
         raise ValueError
Esempio n. 4
0
 def __toggle_todo(self, sender, data):
     """Toggle a todo to True of False.
     Get the selected cell of the table (list of [row index, column index])
     and uses the row index to update the todo at that index in the todos
     list. Then, saves the selected row index in the case you would want to
     delete that todo.
     """
     todo_row = dpg.get_table_selections("Todos")
     todo = self.todos[todo_row[0][0]]
     todo['done'] = not todo['done']
     dpg.add_data('selected-todo-index', self.todos.index(todo))
     dpg.set_value('Selected todo:', f"Selected id: {todo['id']}")
Esempio n. 5
0
def main():

    center_items = []
    core.add_data('item_center_list', center_items)

    with simple.window(TITLE):
        with simple.menu_bar('##menu_bar'):
            with simple.menu('File'):
                # core.add_menu_item('Import', callback=None)
                # core.add_menu_item('Export', callback=None)
                with simple.menu('Theme'):
                    themes = ['Dark', 'Light', 'Classic', 'Dark 2', 'Grey', 'Dark Grey', 'Cherry', 'Purple', 'Gold', 'Red']
                    for theme in themes:
                        core.add_menu_item(theme, callback=menu.update_theme)
                # core.add_menu_item('Exit', callback=None)
            with simple.menu('About'):
                core.add_menu_item('Version', callback=menu.show_version)

        with simple.group('##input_group'):
            # Title input
            core.add_text('Title:')
            core.add_input_text(TITLE_ID, hint='Enter title', width=WIDGET_WIDTH)
            core.add_spacing(count=2)

            # Identifier input
            core.add_text('Identifier:')
            core.add_input_text(IDENTIFIER_ID, hint='Enter identifier', width=WIDGET_WIDTH)
            core.add_spacing(count=2)

            # Password input
            core.add_text('Password:'******'Enter password', width=WIDGET_WIDTH)
            core.add_spacing(count=2)

            # Note input
            core.add_text('Note:')
            core.add_input_text(NOTE_ID, hint='Enter note info', width=WIDGET_WIDTH)
            core.add_spacing(count=10)

            # Save button
            save_clear_spacing = 50
            core.add_button('##save', label='Save', callback=input_field.save_password, width=WIDGET_HALF_WIDTH - (save_clear_spacing // 2))
            core.set_item_color('##save', core.mvGuiCol_Button, color=GREEN)
            core.add_same_line(spacing=save_clear_spacing)
            # Clear input entry button
            core.add_button('##clear_input', label='Clear input', callback=input_field.clear_input, width=WIDGET_HALF_WIDTH - (save_clear_spacing // 2))
            core.add_spacing(count=20)

        with simple.group('##log_group'):
            # Logger
            core.add_logger('##log_message', auto_scroll_button=False, copy_button=False, filter=False, clear_button=False, width=WIDGET_WIDTH, height=80)
            core.set_log_level(core.mvTRACE, logger='##log_message')
            core.add_spacing(count=10)

            # Clear log button
            core.add_button('##clear_log', label='Clear log', callback=logger.clear_log, width=WIDGET_WIDTH)
            core.add_spacing(count=10)

        with simple.group('##password_table_group'):
            # Password table
            header = ['No', 'Title', 'Identifier', 'Password', 'Note']
            core.add_table('##password_table', header, callback=table.table_printer, height=int(WINDOW_HEIGHT * 0.45), width=WIDGET_WIDTH)
            core.add_spacing(count=10)

            table.update_password_table()

            # Update password table button
            update_delete_spacing = 20
            core.add_button('##update_table', label='Update table', callback=table.update_password_table, width=WIDGET_HALF_WIDTH - (update_delete_spacing // 2))
            core.set_item_color('##update_table', core.mvGuiCol_Button, color=BLUE)
            core.add_same_line(spacing=update_delete_spacing)

            # Delete password table button
            core.add_button('##delete_table', label='Delete table', width=WIDGET_HALF_WIDTH - (update_delete_spacing // 2))
            core.set_item_color('##delete_table', core.mvGuiCol_Button, color=RED)
            with simple.popup('##delete_table', '##ask_delete', mousebutton=core.mvMouseButton_Left, modal=True):
                with simple.group('##delete_table_button_group'):
                    delete_table_spacing = 10
                    delete_table_half_width = core.get_main_window_size()[1] // 5 - delete_table_spacing

                    core.add_text('##delete_table_button', default_value='Are you sure to delete all data?')

                    core.add_spacing(count=delete_table_spacing)
                    core.add_button('##delete_table_button_yes', label='Yes', callback=table.delete_password_table, callback_data=True, width=delete_table_half_width)
                    core.add_same_line(spacing=delete_table_spacing)
                    core.add_button('##delete_table_button_no', label='No', callback=table.delete_password_table, callback_data=False, width=delete_table_half_width)

                    # TODO WONT WORK NEED TO FIX center_item FUNCTION
                    # center_item('##delete_table_button')
                    # center_item('##delete_table_button_yes')
                    # center_item('##delete_table_button_no')
                # center_item('##delete_table_button_group')

    if DEBUG_MODE:
        # core.show_logger()
        simple.show_debug()
        # simple.show_documentation()

    # Common Configuration
    core.set_theme(DEFAULT_THEME)
    core.add_additional_font(FONT, FONT_SIZE)
    core.set_main_window_title(TITLE)
    core.set_main_window_size(WINDOW_WIDTH, WINDOW_HEIGHT)
    core.set_main_window_resizable(RESIZABLE)
    core.set_style_window_padding(WINDOW_PADDING, WINDOW_PADDING)
    core.set_exit_callback(model.close_connection)

    # core.set_render_callback(apply_centering)
    core.start_dearpygui(primary_window=TITLE)
Esempio n. 6
0
def video_callback(sender, data):
    video_on = True if sender == "Start Video" else False
    add_data("video_on", video_on)
Esempio n. 7
0
    with group("Left Panel", width=200):
        add_button("Start Video", callback=video_callback)
        add_same_line()
        add_button("End Video", callback=video_callback)
        add_checkbox("Recording", default_value=False, source="is_recording")
        add_same_line(spacing=20)
        add_checkbox("Goggle View",
                     default_value=False,
                     source="display_goggle_view")
        for name, (low, high, step, default) in parameters.items():
            add_slider_int(name,
                           default_value=default,
                           min_value=low,
                           max_value=high,
                           source=name)

    add_same_line()
    image = np.zeros((640, 480, 3), dtype=np.uint8)
    image = cv2.cvtColor(image, cv2.COLOR_RGB2RGBA)
    add_texture("texture", image, 640, 480)
    add_image("canvas", "texture")
    add_slider_float("FPS",
                     max_value=60,
                     enabled=False,
                     no_input=True,
                     source="realtime_fps")

add_data("video_on", False)
set_render_callback(update_canvas)
start_dearpygui(primary_window="Main Window")
Esempio n. 8
0
 def initialize_tracking_data():
     """
     Initializes data objects tracking and start_time
     """
     c.add_data("tracking", False)
     c.add_data("start_time", datetime.datetime.now())