Example #1
0
    def make_gui(self):
        dpg.set_main_window_size(self.width, self.height)
        dpg.set_theme(self.theme)
        with simple.window("Main", no_title_bar=True):
            dpg.set_main_window_title("pytasker")
            with simple.menu_bar("Menu"):
                with simple.menu("File"):
                    dpg.add_menu_item("New Page", callback=self.new_tab)
                    dpg.add_menu_item("Load Page", callback=self.load_page)
                    dpg.add_menu_item("Save Page",
                                      callback=self.save_page_dialog)
                    dpg.add_separator()
                    dpg.add_menu_item("Quit", callback=self.exit_program)
                with simple.menu("Themes"):
                    dpg.add_menu_item("Dark", callback=self.theme_callback)
                    dpg.add_menu_item("Light", callback=self.theme_callback)
                    dpg.add_menu_item("Classic", callback=self.theme_callback)
                    dpg.add_menu_item("Dark 2", callback=self.theme_callback)
                    dpg.add_menu_item("Grey", callback=self.theme_callback)
                    dpg.add_menu_item("Dark Grey",
                                      callback=self.theme_callback)
                    dpg.add_menu_item("Cherry", callback=self.theme_callback)
                    dpg.add_menu_item("Purple", callback=self.theme_callback)
                    dpg.add_menu_item("Gold", callback=self.theme_callback)
                    dpg.add_menu_item("Red", callback=self.theme_callback)

            dpg.add_tab_bar(name="tab_bar_1", parent="Main")
            with simple.group("inittext"):
                dpg.add_text("Hello! Select File - New to get started")
    def __init__(self):

        with simple.window(self.windowName,
                           width=self.xSize,
                           height=self.ySize,
                           x_pos=self.xPos,
                           y_pos=self.yPos):
            core.add_separator()
            core.add_plot(self.plotName)
        super().__init__()
Example #3
0
    def display_history_graph(self, historyDict, numberOfEpochs):

        with simple.window(self.learningGraph, width=300, height=300):
            core.add_separator()
            core.add_plot(self.historyPlotName)
            xAxis = range(0, numberOfEpochs)
            core.add_line_series(self.historyPlotName, "Dokładnosc", xAxis,
                                 historyDict['accuracy'])
            core.add_line_series(self.historyPlotName, "Strata", xAxis,
                                 historyDict['loss'])
    def _render_start_scan_window(self):
        
        core.delete_item(item=self._window_name, children_only=True)

        core.add_text('Please choose directories to scan.', parent=self._window_name)
        core.add_text('Press \'Start Scan\' to run duplicate images search.', parent=self._window_name)

        core.add_text( '',  parent=self._window_name)
        core.add_separator(parent=self._window_name)

        core.add_button(
            'Add Scan Directory', 
            callback=self._add_scan_directory_callback,
            parent=self._window_name)

        core.add_text('', parent=self._window_name)

        core.add_text('Folders to scan', parent=self._window_name)

        if not self._scan_directories:
            core.add_text('No directories chosen', 
            parent=self._window_name,
            color=[249, 19, 19])

        for scan_directory in self._scan_directories:

            core.add_button(
                name='Remove ##'+scan_directory, 
                parent=self._window_name,
                callback=self._remove_scan_dir_click_handler,
                callback_data=scan_directory)

            core.add_same_line(
                parent=self._window_name)

            core.add_text(
                name=scan_directory, 
                parent=self._window_name)


        core.add_separator(parent=self._window_name)

        
        core.add_text( '',  parent=self._window_name)

        core.add_button(
            'Start Scan', 
            callback=self._start_scan_click_handler, 
            callback_data=self._scan_directories,
            parent=self._window_name)
Example #5
0
def window_crud_maintenance(sender, data):
    log_info(f'Function: CRUD Maintenance Window, {sender}, {data}')
    if does_item_exist(f'{data}##window'):
        log_info(f'Already exist {data}##window')
        pass
    else:
        if data == 'Key Values':
            table_headers = ['Key', 'Value', 'Comment']
        elif data == 'Plex Shows':
            table_headers = ['Show Name', 'Show Id', 'Cleaned Show Name']
        elif data == 'Plex Episodes':
            table_headers = [
                'Show Name', 'Season', 'Episode', 'Date Watched',
                'TVM Updated', 'TVM Update Status'
            ]
        else:
            table_headers = ['Unknown']
        with window(name=f'{data}##window',
                    width=2130,
                    height=650,
                    x_pos=5,
                    y_pos=45):
            add_input_text(name=f'{data}_input',
                           no_spaces=True,
                           multiline=False,
                           decimal=False,
                           label=data,
                           width=200)
            add_same_line(spacing=10)
            add_button(name=f'Search##{data}',
                       callback=func_crud_search,
                       callback_data=data)
            if data == 'Key Values' or data == 'Plex Shows':
                add_same_line(spacing=10)
                add_button(name=f"Add New##{data}")
            add_same_line(spacing=10)
            add_button(name=f"Edit##{data}")
            if data == 'Key Values':
                add_same_line(spacing=10)
                add_button(name=f"Delete##{data}")
            add_same_line(spacing=10)
            add_button(name=f"Clear##{data}",
                       callback=func_crud_clear,
                       callback_data=f'Table##{data}')
            add_separator(name=f'##{data}SEP1')
            add_table(name=f'Table##{data}', headers=table_headers)
            add_separator(name=f'##{data}SEP1')
Example #6
0
    def __init__(self):
        with simple.window(self.windowName,
                           width=self.xSize,
                           height=self.ySize,
                           x_pos=self.xPos,
                           y_pos=self.yPos):

            core.add_button(self.importButtonName,
                            callback=self.open_file_dialog)
            core.add_label_text(name=self.fileStatus,
                                label='##' + self.fileMissing,
                                default_value=self.fileMissing)

            core.add_separator()
            core.add_same_line()
            core.add_plot(self.plotName)
        super().__init__()
Example #7
0
    def set_rows(self, nrows):
        """ "Set the rows in the table

        Each row has two columns. The first column is the grid number. The second column is a list
        of applications to snap to the grid. We use a table to enable multiselect
        """
        dpg_core.log_info(f"Refreshing rows for table {self.id}")
        for row in range(1, nrows + 1):
            name = f"{self._id}_{row}"
            # If the row already exists, we don't need to do anything else
            if dpg_core.does_item_exist(name):
                continue

            with dpg_simple.managed_columns(name,
                                            len(self.HEADER),
                                            parent=self.parent):
                # The first column is the grid number
                dpg_core.add_input_int(
                    f"##{self._id}_{row}_number",
                    default_value=row,
                    readonly=True,
                    step=0,
                    parent=name,
                )

                # The second column is the table. Wrap in a collapsing header so the screen isn't
                # too full the entire time.
                with dpg_simple.collapsing_header(f"##{self._id}_{row}_header",
                                                  parent=name):
                    dpg_core.add_table(
                        f"{self._id}_{row}_table",
                        [""],  # no headers
                        callback=self.selected,
                        parent=f"##{self._id}_{row}_header",
                    )
                    # populate the table with the names of available windows
                    for window_name in sorted(self.ACTIVE_WINDOWS):
                        dpg_core.add_row(f"{self._id}_{row}_table",
                                         [window_name])

            # Separate each row with a line
            dpg_core.add_separator(name=f"{self._id}_{row}_sep", parent=name)

        self._nrows = nrows
        dpg_core.log_info(f"Refreshed rows for table {self.id}")
Example #8
0
    def _render_results_group_operations(self):
        """ Render the 'Group Operations' block of 'Results' screen.
        """

        core.add_text(
            name='Group operations',
            color=self._control_text_color,
            parent=self._window_name)

        core.add_button(
            'Keep newest file, delete all other duplicates', 
            callback=self._delete_all_duplicate_click_hander,
            callback_data=self._duplicates_list,
            parent=self._window_name) 

        core.add_text('',  parent=self._window_name)

        core.add_separator(parent=self._window_name)
Example #9
0
    def _draw_duplicates_set(self, duplicate_images_list: FileMetaDataList) -> None:
        """ Draw a single image and all the files containing it.
            All the files in duplicate_images_list containg duplicate of same image.
        """
        
        try:

            file_path = duplicate_images_list[0].GetPath()

            core.add_drawing(
                file_path, 
                width=100, 
                height=100, 
                parent=self._window_name)

            core.draw_image(
                file_path, 
                file_path, 
                [0, 0], 
                pmax=[100, 100],
                uv_min=[0, 0], 
                uv_max=[1, 1], 
                tag="image")

            for file in duplicate_images_list:
                
                file_path = file.GetPath()

                core.add_button(
                    'Delete ##'+file_path, 
                    callback=self._delete_file_button_click_handler, 
                    callback_data=file,
                    parent=self._window_name)

                core.add_same_line(parent=self._window_name)

                core.add_text(
                file_path, 
                parent=self._window_name)

            core.add_separator(parent=self._window_name)

        except Exception as e:
            core.log_error('View::_draw_duplicates_set - Exception : [%s]' % (e))
Example #10
0
    def show(self):
        """Start the gui."""
        with sdpg.window("Main Window"):
            dpg.set_main_window_size(550, 650)
            dpg.set_main_window_resizable(False)
            dpg.add_spacing()
            dpg.set_main_window_title("Dearpygui File Zip")

            dpg.add_spacing()
            dpg.add_text("File Zip App")
            dpg.add_spacing()
            dpg.add_text("Select files to zip by adding them to the table",
                         bullet=True)
            dpg.add_text("Set the output directory", bullet=True)
            dpg.add_text("Click on the table to remove a file", bullet=True)
            dpg.add_text("Click on the zip files button to zip all the files",
                         bullet=True)
            dpg.add_text(
                "If you do not choose a directory, it will by default be"
                "the same directory from where you've run this script.",
                bullet=True)
            dpg.add_spacing()
            dpg.add_separator()

            dpg.add_spacing(count=10)
            dpg.add_button("Select output directory",
                           width=250,
                           callback=self.__select_output_directory)
            dpg.add_same_line()
            dpg.add_button("Add file", width=250, callback=self.__select_file)
            dpg.add_spacing(count=10)
            dpg.add_separator()

            dpg.add_text("Selected output directory:")
            dpg.add_table('Files', ['Path', 'Name'],
                          height=200,
                          callback=self.__remove_file)
            dpg.add_separator()
            dpg.add_progress_bar('Zip Progress', width=-1)
            dpg.add_separator()
            dpg.add_button("Clear files",
                           width=250,
                           callback=self.__clear_files)
            dpg.add_same_line()
            dpg.add_button("Zip Files", width=250, callback=self.__zip_files)
            dpg.add_spacing()
            dpg.add_label_text('##warnings')

            # Render Callback and Start gui
            dpg.set_render_callback(self.__render)
            dpg.start_dearpygui(primary_window="Main Window")
    def watchlist_stocks(self):
        with window("Watchlist Window", width=500, height=500):
            self.menu(False, False, False, True)
            watchlist_data = get_user_watchlist_data(self.user.file)
            gg.add_separator()
            with managed_columns("headers", 4):
                gg.add_text("TICKER")
                gg.add_text("PRICE WHEN ADDED")
                gg.add_text("DATE ADDED")
                gg.add_text("")

            def remove_from_watchlist(sender, data):
                self.user.remove_from_watchlist(data["Ticker"])
                gg.delete_item(f"{data['Ticker']} row")

            for row in watchlist_data:
                ticker_name, price_when_added, str_date_added = row[0], row[1], row[2]
                gg.add_separator()
                with managed_columns(f"{ticker_name} row", 4):
                    gg.add_button(name=ticker_name,
                                  callback=self.change_to_window,
                                  callback_data={"Scene Function": self.info_single_stock,
                                                 "kwargs": {"Ticker": ticker_name}})
                    s = f"{price_when_added} | "
                    s += f"{get_percent_change(float(price_when_added), yfs.get_live_price(ticker_name))}%"
                    gg.add_text(s)
                    gg.add_text(str_date_added)
                    gg.add_button(f"Remove {ticker_name}", label="Remove", callback=remove_from_watchlist,
                                  callback_data={"Ticker": ticker_name})
            gg.add_separator()
    def show(self):
        """Start the gui."""
        dpg.set_main_window_size(550, 550)
        dpg.set_main_window_resizable(False)
        dpg.set_main_window_title("Dearpygui Todo App")

        dpg.add_text("Todo App")
        dpg.add_text(
            "Add a todo by writing a title and clicking"
            " the add todo button",
            bullet=True)
        dpg.add_text("Toggle a todo by clicking on its table row", bullet=True)
        dpg.add_text(
            "Remove a todo by clicking on its table row and clicking"
            " the remove todo button",
            bullet=True)
        dpg.add_separator()

        dpg.add_spacing(count=10)
        dpg.add_input_text("New Todo Title", source="new-todo-title")
        dpg.add_button("Add todo", callback=self.__add_todo)
        dpg.add_spacing(count=10)
        dpg.add_separator()

        dpg.add_table('Todos', ['ID', 'Content', 'Done'],
                      height=200,
                      callback=self.__toggle_todo)
        dpg.add_separator()
        dpg.add_text("Selected todo:")
        dpg.add_button("Remove todo", callback=self.__remove_todo)
        dpg.add_button("Clear todos", callback=self.__clear_todos)

        # Render Callback and Start gui
        dpg.set_render_callback(self.__render)
        dpg.start_dearpygui()
def choose_user_screen():

    with window("Choose User",width=600):

        gg.add_separator()
        with managed_columns("row", 5):
            gg.add_text("USERNAME")
            gg.add_text("STARTING BALANCE")
            gg.add_text("CURRENT BALANCE")
            gg.add_text("DATE CREATED")
            gg.add_text("")
        gg.add_separator()

        def load_user(sender, data):
            user = User(data["file_name"] + ".db")
            gg.delete_item("Choose User")
            MainGui(user)

        count = 1
        for file in os.listdir():
            if(file[-3:]) == ".db":
                user_name = file[:-3]
                initial_balance, current_balance, date_created = get_user_data(file)
                with managed_columns(f"row{count}", 5):
                    gg.add_text(f"{user_name}")
                    gg.add_text(f"{initial_balance}")
                    gg.add_text(f"{current_balance}")
                    gg.add_text(f"{date_created}")
                    gg.add_button(f"load {user_name}", callback=load_user, callback_data={"file_name": user_name})
                gg.add_separator()
                count += 1
Example #14
0
    def show(self):
        """Start the gui."""
        with sdpg.window("Main Window"):
            dpg.set_main_window_size(550, 600)
            dpg.set_main_window_resizable(False)
            dpg.set_main_window_title("Stockify")

            dpg.add_text("Stockify: The Future of Stocks")
            dpg.add_text(
                "Predict a stock by typing in its ticker and clicking"
                " the predict stock button",
                bullet=True,
            )
            dpg.add_text(
                "Remove a stock by clicking on its table row and clicking"
                " the remove stock button",
                bullet=True,
            )
            dpg.add_text(
                "All predictions will predict a stocks value "
                "in 30 days",
                bullet=True,
            )

            dpg.add_text(
                "Confidence is the degree that Stockify"
                " is sure about its prediction",
                bullet=True,
            )
            dpg.add_separator()

            dpg.add_spacing(count=10)
            dpg.add_input_text("Stock Ticker", source="stock-ticker")
            dpg.add_button("Predict Stock", callback=self.__add_stock)
            dpg.add_spacing(count=10)
            dpg.add_separator()

            dpg.add_table(
                "Stocks",
                ["Stock", "Prediction", "Confidence"],
                height=200,
                callback=self.__toggle_stock,
            )
            dpg.add_separator()
            dpg.add_text("Selected stock:")
            dpg.add_button("Remove stock", callback=self.__remove_stock)
            dpg.add_button("Clear stocks", callback=self.__clear_stocks)

            # Render Callback and Start gui
            dpg.set_render_callback(self.__render)
        dpg.start_dearpygui(primary_window="Main Window")
    def user_stock_dash(self):
        with window("User stock dashboard", width=500, height=500):
            self.menu(False, False, True, False)
            gg.add_separator()
            with managed_columns("Header", 5):
                gg.add_text("TICKER")
                gg.add_text("DATE")
                gg.add_text("BUY $ / SELL $")
                gg.add_text("QUANTITY")
                gg.add_text("SELL")

            def sell_stock(sender, data):
                buy_data = data["Purchase Data"]
                purchaseid, date_bought, time_bought, buy_price, quantity_buy = buy_data
                quantity_sell = round(gg.get_value(sender), 2)
                label = f"Message"
                if quantity_sell > quantity_buy:
                    set_item_label(label, f"Cannot sell more than {quantity_buy}!")
                else:
                    self.user.sell_share(data["Ticker"], purchaseid, quantity_sell, data["Sell Price"])
                    self.change_to_window(sender, {"Scene Function": self.user_stock_dash})
                    set_item_label(label, f"Sold {quantity_sell} shares at {data['Sell Price']}$")
                    
            for ticker in self.user.share_by_name:
                ticker_buy_data = self.user.share_by_name[ticker]
                current_price = round(yfs.get_live_price(ticker), 2)
                for event in ticker_buy_data:
                    purchaseid, date, time, buy_price, qty = event
                    gg.add_separator()
                    with managed_columns(f"Data {ticker}{purchaseid}", columns=5, border=True):
                        gg.add_text(ticker)
                        gg.add_text(date)
                        gg.add_text(f"{buy_price} / {current_price}")
                        gg.add_label_text(name=f"{purchaseid} qty", label=str(qty))
                        with group(f"Sell{ticker}{purchaseid}"):
                            gg.add_input_float(name=f"##Sell {ticker}{purchaseid} input", default_value=0,
                                               on_enter=True,
                                               callback=sell_stock, callback_data={"Ticker": ticker,
                                                                                   "Purchase Data": event,
                                                                                   "Sell Price": current_price},
                                               format="%.2f",
                                               width=80)

            gg.add_separator()
            gg.add_button("Message", label="")
    def dashboard_stocks(self):
        with window("Dashboard", width=500, height=500):
            self.menu(False, True, False, False)
            gg.add_separator()
            with managed_columns("headers", 3):
                gg.add_text("TICKER")
                gg.add_text("LIVE PRICE")
                gg.add_text("MY SHARES")
            for ticker in self.main_tickers:
                gg.add_separator()
                with managed_columns(ticker + "col", 3):
                    live_price = round(yfs.get_live_price(ticker), 3)
                    gg.add_button(ticker, callback=self.change_to_window,
                                  callback_data={"Scene Function": self.info_single_stock,
                                                 "kwargs": {"Ticker": ticker}})
                    gg.add_text(str(live_price))
                    try:
                        gg.add_text(str(self.user.share_quantity[ticker]))
                    except KeyError:
                        gg.add_text("0")
            gg.add_separator()

            def go_to_single_stock_info(sender, data):
                input_ticker = gg.get_value(sender)
                if str(yfs.get_live_price(input_ticker)) == 'nan':
                    set_item_label("Search ticker input", label=f"No ticker called {input_ticker} found")
                    return
                else:
                    set_item_label("Search ticker input", label="Loading...")
                    self.change_to_window(sender,
                                          {"Scene Function": self.info_single_stock,
                                           "kwargs": {"Ticker": input_ticker}})

            gg.add_input_text(name="Search ticker input", width=100,
                              default_value='AAPL', tip="Search for a stock ticker", label="Get Ticker Info",
                              callback=go_to_single_stock_info, on_enter=True, uppercase=True)
Example #17
0
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Bg, _hsv_to_rgb(i/7.0, 0.6, 0.6), item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Active, _hsv_to_rgb(i/7.0, 0.8, 0.8), item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Hovered, _hsv_to_rgb(i/7.0, 0.7, 0.7), item=button)

            with cxt.group(horizontal=True):

                dpg.add_text("Press a button: ")
                dpg.add_button(arrow=True, direction=dpg.mvDir_Left, callback=lambda: dpg.set_value(widget, int(dpg.get_value(widget))-1))
                dpg.add_button(arrow=True, direction=dpg.mvDir_Right, callback=lambda: dpg.set_value(widget, int(dpg.get_value(widget))+1))
                widget = dpg.add_text("0")

            widget = dpg.add_text("hover me")
            with cxt.tooltip(parent=widget): # note that "parent" is the item the tooltip show's for
                dpg.add_text("I'm a fancy tooltip")

            dpg.add_separator()

            dpg.add_text("Value", label="Label", show_label=True)
            dpg.add_combo(("AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK"), label="combo", default_value="AAAA", callback=_log)
            dpg.add_input_text(label="input text", default_value="Hello, world!", callback=_log)
            _help(
                    "USER:\n"
                    "Hold SHIFT or use mouse to select text.\n"
                    "CTRL+Left/Right to word jump.\n"
                    "CTRL+A or double-click to select all.\n"
                    "CTRL+X,CTRL+C,CTRL+V clipboard.\n"
                    "CTRL+Z,CTRL+Y undo/redo.\n"
                    "ESCAPE to revert.\n\n")
            dpg.add_input_text(label="input text (w/ hint)", hint="enter text here", callback=_log)
            dpg.add_input_int(label="input int", callback=_log)
            dpg.add_input_float(label="input float", callback=_log)
Example #18
0
    core.add_additional_font('resources/monofur.ttf', 18)

    core.add_dummy(width=140)
    core.add_same_line()
    core.add_image('logo', 'resources/l0lscape.png')

    core.add_button('About', callback=modal, width=100)
    core.add_same_line()
    core.add_button('Github', callback=open_url, width=100)
    core.add_same_line()
    core.add_button('Discord', callback=open_url, width=100)
    core.add_same_line()
    core.add_button('Help', callback=open_url, width=100)

    core.add_separator()

    for value in load_config():
        key = value.get('key')

        core.add_text(f'{key}', bullet=True)
        core.add_input_text(f'{key}-input',
                            default_value=value.get('value'),
                            width=205,
                            label='')
        core.add_same_line()
        core.add_button(key + '_listen',
                        label='Listen',
                        callback=listen,
                        width=100)
        core.add_same_line()
Example #19
0
    def build(self):
        with simple.window("game_win", autosize=True):
            with simple.group("player"):
                left_label_text("Round: ",
                                "round",
                                default_value=str(self.round))
                left_label_text("Player: ",
                                "player",
                                default_value=self.player.name)
                left_label_text("Cash: ",
                                "cash",
                                default_value=str(self.player.cash))
                core.add_spacing(count=5)
                core.add_button("next_round",
                                label="Next round",
                                callback=self.next_round)

            core.add_spacing(count=5)
            core.add_separator()
            core.add_spacing(count=5)

            with simple.group("stocks"):
                # Titles
                core.add_text("Company")
                core.add_same_line(xoffset=stock_table_offsets[1])
                core.add_text("Price")
                core.add_same_line(xoffset=stock_table_offsets[2])
                core.add_text("Owned")
                core.add_same_line(xoffset=stock_table_offsets[3])
                core.add_text("Change")
                core.add_same_line(xoffset=stock_table_offsets[4])
                core.add_text("Old price")
                core.add_same_line(xoffset=stock_table_offsets[5])
                core.add_text("New price")
                core.add_same_line(xoffset=stock_table_offsets[6])
                core.add_text("Dividend")

                for stock in self.stocks:
                    core.add_text(stock.name)
                    core.add_same_line(xoffset=stock_table_offsets[1])
                    core.add_text(f"stock.{stock.name}.price",
                                  default_value=str(stock.price))
                    core.add_same_line(xoffset=stock_table_offsets[2])

                    # Buy / Sell functionality
                    core.add_input_int(
                        f"stock.{stock.name}.owned",
                        label="",
                        default_value=self.player.get_owned_stocks(stock),
                        max_value=int(self.player.cash / stock.price),
                        min_clamped=True,
                        max_clamped=True,
                        callback=self.buy_or_sell,
                        callback_data=[
                            stock,
                        ],
                        width=100,
                    )

                    core.add_same_line(xoffset=stock_table_offsets[3])
                    core.add_text(f"stock.{stock.name}.change",
                                  default_value=str(stock.change))
                    core.add_same_line(xoffset=stock_table_offsets[4])
                    core.add_text(
                        f"stock.{stock.name}.previous_price",
                        default_value=str(stock.previous_price),
                    )
                    core.add_same_line(xoffset=stock_table_offsets[5])
                    core.add_text(f"stock.{stock.name}.price2",
                                  default_value=str(stock.price))
                    core.add_same_line(xoffset=stock_table_offsets[6])
                    core.add_text(
                        f"stock.{stock.name}.dividend",
                        default_value=str(stock.dividend),
                    )

        core.set_main_window_title("Stock Trader")
        core.set_main_window_size(650, 450)
        core.set_main_window_resizable(False)
Example #20
0
def show_demo():

    _create_static_textures()
    _create_dynamic_textures()

    with cxt.collapsing_header(label="Textures & Images"):

        with cxt.tree_node(label="Help"):

            dpg.add_separator()
            dpg.add_text("ABOUT TEXTURES:")
            dpg.add_text("Textures are buffers of RGBA data.",
                         bullet=True,
                         indent=20)
            dpg.add_text("Textures are used by 'image based' widgets:",
                         bullet=True,
                         indent=20)
            dpg.add_text("add_image", bullet=True, indent=50)
            dpg.add_text("add_image_button", bullet=True, indent=50)
            dpg.add_text("draw_image", bullet=True, indent=50)
            dpg.add_text("add_image_series", bullet=True, indent=50)
            dpg.add_text("Textures are themselves widgets.",
                         bullet=True,
                         indent=20)
            dpg.add_text(
                "Textures must be a child of a texture container widget.",
                bullet=True,
                indent=20)
            dpg.add_text(
                "Textures can be either static or dynamic (see following sections).",
                bullet=True,
                indent=20)

            dpg.add_separator()
            dpg.add_text("PROGRAMMER GUIDE:")
            dpg.add_text(
                "'image based' widgets hold a reference to a texture widget.",
                bullet=True,
                indent=20)
            dpg.add_text(
                "Deleting the texture widget will not affect widget's using it.",
                bullet=True,
                indent=50)
            dpg.add_text(
                "Textures are only free'd from the GPU when the reference count reaches 0.",
                bullet=True,
                indent=50)
            dpg.add_text(
                "The texture container widget is a root (has no parent).",
                bullet=True,
                indent=20)
            dpg.add_text("The texture container widget is hidden by default.",
                         bullet=True,
                         indent=20)
            dpg.add_text(
                "'Showing' it, opens a manager to inspect the textures within.",
                bullet=True,
                indent=50)
            dpg.add_same_line()
            dpg.add_button(label="Press Here",
                           small=True,
                           callback=lambda: dpg.configure_item(
                               demo_texture_container, show=True))
            dpg.add_separator()

        with cxt.tree_node(label="Static Textures"):

            dpg.add_separator()
            dpg.add_text("ABOUT STATIC TEXTURES:")
            dpg.add_text("Can NOT be modified after creation.",
                         bullet=True,
                         indent=20)
            dpg.add_text("Can be loaded from a file using the 'file' keyword.",
                         bullet=True,
                         indent=20)
            dpg.add_separator()

            with cxt.group(horizontal=True):

                with cxt.group():
                    dpg.add_text("Image Button")
                    dpg.add_image_button(demo_static_texture_1)

                with cxt.group():
                    dpg.add_text("Image")
                    dpg.add_image(demo_static_texture_2)

                with cxt.group():
                    dpg.add_text("Image (texture size)")
                    dpg.add_image(demo_static_texture_3)

                with cxt.group():
                    dpg.add_text("Image (2x texture size)")
                    dpg.add_image(demo_static_texture_3, width=200, height=200)

            dpg.add_image("INTERNAL_DPG_FONT_ATLAS")

        with cxt.tree_node(label="Dynamic Textures"):

            dpg.add_separator()
            dpg.add_text("ABOUT DYNAMIC TEXTURES:")
            dpg.add_text("Can be modified after creation with 'set_value'.",
                         bullet=True,
                         indent=20)
            dpg.add_text(
                "New data must be the same dimensions as the original",
                bullet=True,
                indent=20)
            dpg.add_separator()

            with cxt.group():
                dpg.add_color_picker(label="Texture 1",
                                     default_value=(255, 0, 255, 255),
                                     no_side_preview=True,
                                     alpha_bar=True,
                                     width=200,
                                     callback=_update_dynamic_textures,
                                     callback_data=1)
                dpg.add_text("Image Button")
                dpg.add_image_button(demo_dynamic_texture_1,
                                     width=100,
                                     height=100)

            dpg.add_same_line()

            with cxt.group():
                dpg.add_color_picker(label="Texture 2",
                                     default_value=(255, 255, 0, 255),
                                     no_side_preview=True,
                                     alpha_bar=True,
                                     width=200,
                                     callback=_update_dynamic_textures,
                                     callback_data=2)
                dpg.add_text("Image")
                dpg.add_image(demo_dynamic_texture_2)

        with cxt.tree_node(label="Image Series (plots)"):

            plot_id = dpg.add_plot(label="Image Plot", height=400)
            dpg.add_image_series("INTERNAL_DPG_FONT_ATLAS", [300, 300],
                                 [400, 400],
                                 label="font atlas",
                                 parent=plot_id)
            dpg.add_image_series(demo_static_texture_1, [0, 0], [100, 100],
                                 label="static 1",
                                 parent=plot_id)
            dpg.add_image_series(demo_static_texture_2, [150, 150], [200, 200],
                                 label="static 2",
                                 parent=plot_id)
            dpg.add_image_series(demo_static_texture_3, [200, -150],
                                 [300, -50],
                                 label="static 3",
                                 parent=plot_id)
            dpg.add_image_series(demo_dynamic_texture_1, [-200, 100],
                                 [-100, 200],
                                 label="dynamic 1",
                                 parent=plot_id)
            dpg.add_image_series(demo_dynamic_texture_2, [-200, -100],
                                 [-150, -50],
                                 label="dynamic 2",
                                 parent=plot_id)

        with cxt.tree_node(label="Drawlists"):

            with cxt.drawlist(width=400, height=300):
                dpg.draw_rectangle((0, 0), (400, 300),
                                   color=(100, 100, 100, 250),
                                   thickness=2)
                dpg.draw_image(demo_static_texture_3, [0, 0], [100, 100])
                dpg.draw_image(demo_dynamic_texture_1, [200, 100], [300, 200])
Example #21
0
 def _setup_add_widget(self, dpg_args) -> None:
     dpgcore.add_separator(name=self.id, **dpg_args)
Example #22
0
def show_demo():

    with cxt.collapsing_header(label="Widgets"):

        with cxt.tree_node(label="Basic"):

            with cxt.group(horizontal=True):
                dpg.add_button(label="Button", callback=_log)
                dpg.add_button(label="Button", callback=_log, small=True)
                dpg.add_button(label="Button", callback=_log,
                               arrow=True)  # default direction is mvDir_Up
                dpg.add_button(label="Button",
                               callback=_log,
                               arrow=True,
                               direction=dpg.mvDir_Left)
                dpg.add_button(label="Button",
                               callback=_log,
                               arrow=True,
                               direction=dpg.mvDir_Right)
                dpg.add_button(label="Button",
                               callback=_log,
                               arrow=True,
                               direction=dpg.mvDir_Down)

            dpg.add_checkbox(label="checkbox", callback=_log)
            dpg.add_radio_button(("radio a", "radio b", "radio c"),
                                 callback=_log,
                                 horizontal=True)
            dpg.add_selectable(label="selectable", callback=_log)

            with cxt.group(horizontal=True) as g:

                for i in range(0, 7):
                    button = dpg.add_button(label="Click", callback=_log)
                    dpg.set_theme_style(dpg.mvThemeStyle_Button_Rounding,
                                        i * 5,
                                        item=button)
                    dpg.set_theme_style(dpg.mvThemeStyle_Button_PaddingX,
                                        i * 3,
                                        item=button)
                    dpg.set_theme_style(dpg.mvThemeStyle_Button_PaddingY,
                                        i * 3,
                                        item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Bg,
                                        _hsv_to_rgb(i / 7.0, 0.6, 0.6),
                                        item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Active,
                                        _hsv_to_rgb(i / 7.0, 0.8, 0.8),
                                        item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Hovered,
                                        _hsv_to_rgb(i / 7.0, 0.7, 0.7),
                                        item=button)

            with cxt.group(horizontal=True):

                dpg.add_text("Press a button: ")
                dpg.add_button(arrow=True,
                               direction=dpg.mvDir_Left,
                               callback=lambda: dpg.set_value(
                                   widget,
                                   int(dpg.get_value(widget)) - 1))
                dpg.add_button(arrow=True,
                               direction=dpg.mvDir_Right,
                               callback=lambda: dpg.set_value(
                                   widget,
                                   int(dpg.get_value(widget)) + 1))
                widget = dpg.add_text("0")

            widget2 = dpg.add_text("hover me")
            with cxt.tooltip(
                    parent=widget2
            ):  # note that "parent" is the item the tooltip show's for
                dpg.add_text("I'm a fancy tooltip")

            dpg.add_separator()

            dpg.add_text("Value", label="Label", show_label=True)
            dpg.add_combo(("AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF",
                           "GGGG", "HHHH", "IIII", "JJJJ", "KKKK"),
                          label="combo",
                          default_value="AAAA",
                          callback=_log)
            dpg.add_input_text(label="input text",
                               default_value="Hello, world!",
                               callback=_log)
            _help("USER:\n"
                  "Hold SHIFT or use mouse to select text.\n"
                  "CTRL+Left/Right to word jump.\n"
                  "CTRL+A or double-click to select all.\n"
                  "CTRL+X,CTRL+C,CTRL+V clipboard.\n"
                  "CTRL+Z,CTRL+Y undo/redo.\n"
                  "ESCAPE to revert.\n\n")
            dpg.add_input_text(label="input text (w/ hint)",
                               hint="enter text here",
                               callback=_log)
            dpg.add_input_int(label="input int", callback=_log)
            dpg.add_input_float(label="input float", callback=_log)
            dpg.add_input_float(label="input scientific",
                                format="%e",
                                callback=_log)
            dpg.add_input_floatx(label="input floatx",
                                 callback=_log,
                                 default_value=[1, 2, 3, 4])
            dpg.add_drag_int(label="drag int", callback=_log)
            _help("Click and drag to edit value.\n"
                  "Hold SHIFT/ALT for faster/slower edit.\n"
                  "Double-click or CTRL+click to input value.")
            dpg.add_drag_int(label="drag int 0..100",
                             format="%d%%",
                             callback=_log)
            dpg.add_drag_float(label="drag float", callback=_log)
            dpg.add_drag_float(label="drag small float",
                               default_value=0.0067,
                               format="%.06f ns",
                               callback=_log)
            dpg.add_slider_int(label="slider int", max_value=3, callback=_log)
            _help("CTRL+click to enter value.")
            dpg.add_slider_float(label="slider float",
                                 max_value=1.0,
                                 format="ratio = %.3f",
                                 callback=_log)
            dpg.add_slider_int(label="slider angle",
                               min_value=-360,
                               max_value=360,
                               format="%d deg",
                               callback=_log)
            _help("Click on the colored square to open a color picker.\n"
                  "Click and hold to use drag and drop.\n"
                  "Right-click on the colored square to show options.\n"
                  "CTRL+click on individual component to input value.\n")
            dpg.add_color_edit((102, 179, 0, 128),
                               label="color edit 4",
                               callback=_log,
                               uint8=True)
            dpg.add_color_edit(default_value=(.5, 1, .25, .1),
                               label="color edit 3",
                               callback=_log,
                               m_3component=True,
                               uint8=True,
                               floats=False)
            dpg.add_listbox(
                ("Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange",
                 "Pineapple", "Strawberry", "Watermelon"),
                label="listbox",
                num_items=4,
                callback=_log)
            dpg.add_color_button(label="color button")

        with cxt.tree_node(label="Bullets"):

            dpg.add_text("Bullet point 1", bullet=True)
            dpg.add_text(
                "Bullet point 2\nbullet text can be\nOn multiple lines",
                bullet=True)

            with cxt.tree_node(label="Tree node"):
                dpg.add_text("Another bullet point", bullet=True)

            dpg.add_text("1", bullet=True)
            dpg.add_same_line()
            dpg.add_button(label="Button", small=True)

        with cxt.tree_node(label="Text"):

            with cxt.tree_node(label="Colored Text"):

                dpg.add_text("Pink", color=(255, 0, 255))
                dpg.add_text("Yellow", color=(255, 255, 0))

            with cxt.tree_node(label="Word Wrapping"):

                dpg.add_text(
                    'This text should automatically wrap on the edge of the window.The current implementation for the text wrapping follows simple rules suited for English and possibly other languages',
                    wrap=0)
                dpg.add_slider_int(
                    label="wrap width",
                    default_value=500,
                    max_value=1000,
                    callback=lambda sender: dpg.configure_item(
                        "_demo_wrap", wrap=dpg.get_value(sender)))
                dpg.add_text(
                    'The lazy dong is a good dog. This paragraph should fit within the child. Testing a 1 character word. The quick brown fox jumps over the lazy dog.',
                    id="_demo_wrap",
                    wrap=100)

        with cxt.tree_node(label="Text Input"):

            dpg.add_checkbox(label="readonly",
                             callback=_config,
                             callback_data="Multi-line Text Input")
            dpg.add_checkbox(label="on_enter",
                             callback=_config,
                             callback_data="Multi-line Text Input")

            with cxt.tree_node(id="Multi-line Text Input"):

                dpg.add_input_text(
                    multiline=True,
                    default_value="/*\n"
                    " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
                    " the hexadecimal encoding of one offending instruction,\n"
                    " more formally, the invalid operand with locked CMPXCHG8B\n"
                    " instruction bug, is a design flaw in the majority of\n"
                    " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
                    " processors (all in the P5 microarchitecture).\n"
                    "*/\n\n"
                    "label:\n"
                    "\tlock cmpxchg8b eax\n",
                    height=300,
                    callback=_log,
                    tab_input=True)

            with cxt.tree_node(label="Filtered Text Input"):

                dpg.add_input_text(callback=_log, label="default")
                dpg.add_input_text(callback=_log,
                                   label="decimal",
                                   decimal=True)
                dpg.add_input_text(callback=_log,
                                   label="no blank",
                                   no_spaces=True)
                dpg.add_input_text(callback=_log,
                                   label="uppercase",
                                   uppercase=True)
                dpg.add_input_text(callback=_log,
                                   label="scientific",
                                   scientific=True)
                dpg.add_input_text(callback=_log,
                                   label="hexdecimal",
                                   hexadecimal=True)

            with cxt.tree_node(label="Password Input"):

                password = dpg.add_input_text(label="password",
                                              password=True,
                                              callback=_log)
                dpg.add_input_text(label="password (w/ hint)",
                                   password=True,
                                   hint="<password>",
                                   source=password,
                                   callback=_log)
                dpg.add_input_text(label="password (clear)",
                                   source=password,
                                   callback=_log)

        with cxt.tree_node(label="Simple Plots"):

            dpg.add_simple_plot(
                label="Frame Times",
                default_value=[0.6, 0.1, 1.0, 0.5, 0.92, 0.1, 0.2])
            dpg.add_simple_plot(label="Histogram",
                                default_value=(0.6, 0.1, 1.0, 0.5, 0.92, 0.1,
                                               0.2),
                                height=80,
                                histogram=True,
                                minscale=0.0)

            data1 = []
            for i in range(0, 70):
                data1.append(cos(3.14 * 6 * i / 180))

            dpg.add_simple_plot(label="Lines", default_value=data1, height=80)
            dpg.add_simple_plot(label="Histogram",
                                default_value=data1,
                                height=80,
                                histogram=True)
            dpg.add_progress_bar(label="Progress Bar",
                                 default_value=0.78,
                                 overlay="78%")
            dpg.add_same_line()
            dpg.add_text("Progress Bar")
            bar = dpg.add_progress_bar(default_value=0.78, overlay="1367/1753")
            dpg.set_theme_color(dpg.mvThemeCol_ProgressBar_Bar,
                                (255, 0, 0, 255),
                                item=bar)

        with cxt.tree_node(label="Multi-component Widgets"):

            for i in range(2, 5):

                with cxt.group():
                    float_source = dpg.add_input_floatx(
                        label=f"input float {i}",
                        min_value=0.0,
                        max_value=100.0,
                        size=i)
                    dpg.add_drag_floatx(label=f"drag float {i}",
                                        source=float_source,
                                        size=i)
                    dpg.add_slider_floatx(label=f"slider float {i}",
                                          source=float_source,
                                          size=i)

                with cxt.group():

                    int_source = dpg.add_input_intx(label=f"input int {i}",
                                                    min_value=0,
                                                    max_value=100,
                                                    size=i)
                    dpg.add_drag_intx(label=f"drag int {i}",
                                      source=int_source,
                                      size=i)
                    dpg.add_slider_intx(label=f"slider int {i}",
                                        source=int_source,
                                        size=i)

                dpg.add_dummy(height=10)

        with cxt.tree_node(label="Vertical Sliders"):

            dpg.add_slider_int(label=" ",
                               default_value=1,
                               vertical=True,
                               max_value=5,
                               height=160)
            dpg.add_same_line()

            with cxt.group(horizontal=True):

                values = [0.0, 0.60, 0.35, 0.9, 0.70, 0.20, 0.0]

                for i in range(0, 7):
                    widget3 = dpg.add_slider_float(label=" ",
                                                   default_value=values[i],
                                                   vertical=True,
                                                   max_value=1.0,
                                                   height=160)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_Bg,
                                        _hsv_to_rgb(i / 7.0, 0.5, 0.5),
                                        item=widget3)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_Grab,
                                        _hsv_to_rgb(i / 7.0, 0.9, 0.9),
                                        item=widget3)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_BgActive,
                                        _hsv_to_rgb(i / 7.0, 0.7, 0.5),
                                        item=widget3)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_BgHovered,
                                        _hsv_to_rgb(i / 7.0, 0.6, 0.5),
                                        item=widget3)

            dpg.add_same_line()
            with cxt.group():
                for i in range(0, 3):
                    with cxt.group(horizontal=True):
                        values = [0.20, 0.80, 0.40, 0.25]
                        for j in range(0, 4):
                            dpg.add_slider_float(label=" ",
                                                 default_value=values[j],
                                                 vertical=True,
                                                 max_value=1.0,
                                                 height=50)

            dpg.add_same_line()
            with cxt.group(horizontal=True):
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)

        with cxt.tree_node(label="Time/Date Widgets"):

            dpg.add_time_picker(label="Time Picker",
                                default_value={
                                    'hour': 14,
                                    'min': 32,
                                    'sec': 23
                                })
            dpg.add_separator()

            with cxt.table(header_row=False):

                dpg.add_table_column()
                dpg.add_table_column()
                dpg.add_table_column()

                dpg.add_date_picker(label="Date Picker1",
                                    level=0,
                                    default_value={
                                        'month_day': 8,
                                        'year': 93,
                                        'month': 5
                                    })
                dpg.add_table_next_column()
                dpg.add_date_picker(label="Date Picker2",
                                    level=1,
                                    default_value={
                                        'month_day': 8,
                                        'year': 93,
                                        'month': 5
                                    })
                dpg.add_table_next_column()
                dpg.add_date_picker(label="Date Picker3",
                                    level=2,
                                    default_value={
                                        'month_day': 8,
                                        'year': 93,
                                        'month': 5
                                    })

        with cxt.tree_node(label="Loading Indicators"):

            dpg.add_loading_indicator()
            dpg.add_same_line()
            dpg.add_loading_indicator(style=1)

        with cxt.tree_node(label="Knobs"):

            with cxt.group(horizontal=True):

                dpg.add_knob_float(label="K1")
                dpg.add_knob_float(label="K2", default_value=25.0)
                dpg.add_knob_float(label="K3", default_value=50.0)

        with cxt.tree_node(label="2D/3D Sliders"):

            dpg.add_3d_slider(label="3D Slider", scale=0.5)
Example #23
0
    def __init__(self):
        self.tensorFlowInterface = TensorFlowInterface()
        self.outputVisualisationWindow = OutputVisualisationWindow()
        self.historyGraphWindow = HistoryGraphWindow()

        with simple.window(self.windowName,
                           width=self.xSize,
                           height=self.ySize,
                           x_pos=self.xPos,
                           y_pos=self.yPos):
            core.add_text(self.simulationSetting)
            core.add_button(self.createNetwork,
                            callback=self.create_network_callback)
            core.add_same_line()
            core.add_button(self.createVisualization,
                            callback=self.create_visualisation_callback)
            core.add_same_line()
            core.add_button(self.createOutputPrediction,
                            callback=self.create_output_prediction)
            core.add_same_line()
            core.add_button(self.historyGraph,
                            callback=self.create_history_graph)
            core.add_button(self.trainData,
                            callback=self.execute_training_data)
            core.add_same_line()
            #core.add_slider_int(self.timeToTrain, default_value = 100, min_value=1, max_value=1000, width = 200)
            core.add_input_int(self.timeToTrain,
                               default_value=100,
                               min_value=1,
                               max_value=1000,
                               width=200)
            core.add_same_line()
            core.add_checkbox(self.use2DInOut)

            core.add_slider_int(self.numberOfLayers,
                                default_value=2,
                                min_value=2,
                                max_value=self.maxNumberOfLayers,
                                callback=self.layer_slider_callback,
                                width=200)
            for i in range(0, self.maxNumberOfLayers):
                core.add_slider_int(self.layer + str(i),
                                    default_value=1,
                                    width=200)
                core.add_same_line()
                core.add_combo(self.type + '##' + str(i),
                               items=self.neuronTypeList,
                               width=70,
                               callback=self.change_list_callback,
                               default_value='Dense')
                core.add_same_line()
                core.add_combo(self.activation + '##' + str(i),
                               items=self.neuronActivationList,
                               width=70,
                               callback=self.change_list_callback,
                               default_value='relu')

            core.add_separator()
            self.layer_slider_callback()

        #self.visualization_window = VisualizationWindow()
        self.betterVisualizer = BetterVisualizer()
        self.betterVisualizer.hide_window()
        self.importWindow = ImportWindow()
        self.neuronDataContainer = ModelDataContainer(
            self.neuronDataContainerDefaultData[0],
            self.neuronDataContainerDefaultData[1],
            self.neuronDataContainerDefaultData[2],
            self.neuronDataContainerDefaultData[3])
        self.modify_neuron_list()
        self.tensorFlowInterface.create_model(self.neuronDataContainer)
        super().__init__()
Example #24
0
def start_build_dpg():
    with simple.window("FACEIT Elo Overlay",
                       on_close=lambda: delete_item("FACEIT Elo Overlay"),
                       no_title_bar=True,
                       no_resize=True):
        """
        Set window configurations
        """

        simple.set_window_pos("FACEIT Elo Overlay", 0, 0)
        core.set_main_window_title("FACEIT Elo Overlay")
        core.set_main_window_size(492, 830)
        core.set_style_frame_rounding(6.00)
        core.add_additional_font("resources/OpenSans-Bold.ttf", size=14.5)
        """
        Initial loads
        """
        db_create.create_database(DBNAME)
        COLOR_List = config_functions.get_color()
        """
        Set some Background and Font Colors
        also the frame rounding and the window size
        """
        core.set_theme_item(mvGuiCol_Text, COLOR_List[1][0], COLOR_List[1][1],
                            COLOR_List[1][2], COLOR_List[1][3])
        core.set_theme_item(mvGuiCol_WindowBg, COLOR_List[3][0],
                            COLOR_List[3][1], COLOR_List[3][2],
                            COLOR_List[3][3])
        core.set_theme_item(mvGuiCol_Border, COLOR_List[4][0],
                            COLOR_List[4][1], COLOR_List[4][2],
                            COLOR_List[4][3])
        core.set_style_frame_border_size(1.00)
        core.set_theme_item(mvGuiCol_Button, COLOR_List[0][0],
                            COLOR_List[0][1], COLOR_List[0][2],
                            COLOR_List[0][3])
        core.set_theme_item(mvGuiCol_ButtonHovered, COLOR_List[0][0],
                            COLOR_List[0][1], COLOR_List[0][2],
                            COLOR_List[0][3])
        core.set_theme_item(mvGuiCol_ButtonActive, COLOR_List[2][0],
                            COLOR_List[2][1], COLOR_List[2][2],
                            COLOR_List[2][3])
        core.set_theme_item(mvGuiCol_BorderShadow, COLOR_List[0][0],
                            COLOR_List[0][1], COLOR_List[0][2] - 50,
                            COLOR_List[0][3])

    with simple.window('##Overlay',
                       no_collapse=True,
                       no_resize=True,
                       no_move=True,
                       no_close=True,
                       x_pos=30,
                       y_pos=0,
                       width=445,
                       height=790,
                       no_title_bar=True):
        """
        Set a Header 
        """
        bool_list_faceit, bool_list_match, name, acEloGoal = startup()
        core.add_button("FACEIT Overlay Menu")
        core.set_item_style_var("FACEIT Overlay Menu",
                                mvGuiStyleVar_FramePadding, [5 * 27, 5 * 3])
        core.add_spacing(count=5)
        """
        Build up the FACEIT Stats configuration 
        """

        with simple.group("##GroupStats"):
            core.add_button("Default Configurations##STATS")
            core.set_item_style_var("Default Configurations##STATS",
                                    mvGuiStyleVar_FramePadding,
                                    [5 * 20, 5 * 3])
            core.add_spacing(count=5)
            core.add_text("##TextFaceitName",
                          default_value="FACEIT Name:",
                          color=(255, 255, 0, -1))
            core.add_input_text("##FaceitName",
                                hint="FACEIT Name Case sensitive",
                                default_value=name,
                                callback=changes_detected)
            core.add_spacing(count=2)
            core.add_text("##TextEloGoal", default_value="FACEIT Elo goal:")
            core.add_input_text("##EloGoal",
                                hint="Set your Elo goal, empty = disabled",
                                default_value=str(acEloGoal),
                                callback=changes_detected)
            core.add_spacing(count=5)
            """
            Faceit Stats header 
            """
            core.add_button("FACEIT Stats")
            core.set_item_style_var("FACEIT Stats", mvGuiStyleVar_FramePadding,
                                    [5 * 26, 5 * 3])
            core.add_spacing(count=2)
            """
            Checkbox group 
            """
            core.add_checkbox(
                "Disable All##stats",
                default_value=False,
                callback=lambda sender, data: disable_all(sender))
            core.add_same_line()
            core.add_checkbox("Enable All##stats",
                              default_value=False,
                              callback=lambda sender, data: enable_all(sender))
            core.add_spacing(count=3)
            """
            Checkbox group 
            """
            core.add_checkbox("Current Elo##stats",
                              default_value=bool_list_faceit[0],
                              callback=changes_detected)
            core.add_same_line(xoffset=250)
            core.add_checkbox("Faceit Rank##stats",
                              default_value=bool_list_faceit[1],
                              callback=changes_detected)
            """
            Checkbox group 
            """
            core.add_checkbox("Elo Gained today##stats",
                              default_value=bool_list_faceit[2],
                              callback=changes_detected)
            core.add_same_line(xoffset=250)
            core.add_checkbox("Win Streak##stats",
                              default_value=bool_list_faceit[3],
                              callback=changes_detected)
            """
            Checkbox group 
            """
            core.add_checkbox("Total Matches##stats",
                              default_value=bool_list_faceit[4],
                              callback=changes_detected)
            core.add_same_line(xoffset=250)
            core.add_checkbox("Matches Won##stats",
                              default_value=bool_list_faceit[5],
                              callback=changes_detected)
            core.add_spacing(count=2)
            win_loss = config_functions.get_win_loss()
            print(win_loss)
            if win_loss[0][0] is None:
                win_loss = [(0, 0)]
            core.add_text("##TextWinLoss", default_value="Win/Loss Stats:")
            core.add_checkbox("Day##WinLoss",
                              default_value=int(win_loss[0][0]),
                              callback=lambda sender, data: win_los(sender))
            core.add_same_line()
            core.add_checkbox("Week##WinLoss",
                              default_value=int(win_loss[0][1]),
                              callback=lambda sender, data: win_los(sender))
            core.add_spacing(count=5)
            """
            Last Match header 
            """
            core.add_button("Last Match")
            core.set_item_style_var("Last Match", mvGuiStyleVar_FramePadding,
                                    [5 * 26.5, 5 * 3])
            core.add_spacing(count=2)
            """
            Checkbox group 
            """
            core.add_checkbox(
                "Disable All##match",
                default_value=False,
                callback=lambda sender, data: disable_all(sender))
            core.add_same_line()
            core.add_checkbox("Enable All##match",
                              default_value=False,
                              callback=lambda sender, data: enable_all(sender))
            core.add_spacing(count=3)
            """
            Checkbox group 
            """
            core.add_checkbox("Score##match",
                              default_value=bool_list_match[0],
                              callback=changes_detected)
            core.add_same_line(xoffset=250)
            core.add_checkbox("Result (W/L)##match",
                              default_value=bool_list_match[1],
                              callback=changes_detected)
            """
            Checkbox group 
            """
            core.add_checkbox("Map##match",
                              default_value=bool_list_match[2],
                              callback=changes_detected)
            core.add_same_line(xoffset=250)
            core.add_checkbox("K/D##match",
                              default_value=bool_list_match[3],
                              callback=changes_detected)
            """
            Checkbox group 
            """
            core.add_checkbox("Elo Diff##match",
                              default_value=bool_list_match[4],
                              callback=changes_detected)
            core.add_same_line(xoffset=250)
            core.add_checkbox("Kills##match",
                              default_value=bool_list_match[5],
                              callback=changes_detected)
            """
            Checkbox group 
            """
            core.add_checkbox("Death##match",
                              default_value=bool_list_match[6],
                              callback=changes_detected)
            core.add_spacing(count=5)
            """
            Apply Configuration to the database Button 
            """
            core.add_button("Apply Configuration", callback=save_data)
        """
        Start the Overlay with the current configuration 
        """
        core.add_spacing(count=3)
        core.add_button("Start", callback=open_overlay)
        core.set_item_style_var("Start", mvGuiStyleVar_FramePadding,
                                [5 * 29.5, 5 * 3])

    with simple.window('##Config',
                       no_collapse=True,
                       no_resize=True,
                       no_move=True,
                       no_close=True,
                       x_pos=0,
                       y_pos=1,
                       width=20,
                       height=790,
                       no_title_bar=True):
        core.set_item_color("##Config",
                            mvGuiCol_Text,
                            color=(COLOR_List[1][0], COLOR_List[1][1],
                                   COLOR_List[1][2], COLOR_List[1][3]))
        core.set_item_color("##Config",
                            mvGuiCol_WindowBg,
                            color=(COLOR_List[3][0], COLOR_List[3][1],
                                   COLOR_List[3][2], COLOR_List[3][3] - 10))
        core.set_item_style_var("##Config",
                                mvGuiStyleVar_WindowRounding,
                                value=[6])
        core.set_item_color("##Config",
                            mvGuiCol_Border,
                            color=(COLOR_List[4][0], COLOR_List[4][1],
                                   COLOR_List[4][2], COLOR_List[4][3]))
        core.add_image_button("##ConfigPlus",
                              value="resources/cfg_wheel.png",
                              callback=animation_config_color,
                              frame_padding=1,
                              tip="Settings & Colors")
        core.add_same_line(xoffset=50)
        with simple.group("##Config_Colors", show=False):
            COLOR_List = config_functions.get_color()
            core.add_text(
                "You can type in the RBG Values or click on the right Color Button"
            )

            core.add_color_edit4(name="Header#Color",
                                 default_value=[
                                     COLOR_List[0][0], COLOR_List[0][1],
                                     COLOR_List[0][2], COLOR_List[0][3]
                                 ],
                                 label="Header")
            core.add_color_edit4(name="Text#Color",
                                 default_value=[
                                     COLOR_List[1][0], COLOR_List[1][1],
                                     COLOR_List[1][2], COLOR_List[1][3]
                                 ],
                                 label="Text")
            core.add_color_edit4(name="ButtonActive#Color",
                                 default_value=[
                                     COLOR_List[2][0], COLOR_List[2][1],
                                     COLOR_List[2][2], COLOR_List[2][3]
                                 ],
                                 label="Button Active")
            core.add_color_edit4(name="BG#Color",
                                 default_value=[
                                     COLOR_List[3][0], COLOR_List[3][1],
                                     COLOR_List[3][2], COLOR_List[3][3]
                                 ],
                                 label="Background")
            core.add_color_edit4(name="Outline#Color",
                                 default_value=[
                                     COLOR_List[4][0], COLOR_List[4][1],
                                     COLOR_List[4][2], COLOR_List[4][3]
                                 ],
                                 label="Outline")
            core.add_separator()
            core.add_button("Test Colors", callback=test_colors)
            core.add_same_line()
            core.add_button("Reset", callback=reset_colors)
            core.add_button("Save Colors", callback=save_colors)
            core.add_spacing(count=2)
            core.add_separator()
            core.add_separator()
            core.add_spacing(count=2)
            scale = config_functions.get_scale()
            core.set_global_font_scale(scale)
            core.add_text("Change The Global Font Size")
            core.add_drag_float(
                "Global Scale",
                default_value=scale,
                format="%0.2f",
                speed=0.01,
                callback=lambda sender, data: core.set_global_font_scale(
                    core.get_value("Global Scale")))

            core.add_button("Reset##1", callback=reset_scale)
            core.add_button("Save Size##1", callback=save_scale)
            core.add_spacing(count=2)
            core.add_separator()
            core.add_separator()
            core.add_spacing(count=2)
            refresh = config_functions.get_refresh()
            refreshSymbol = config_functions.get_refresh_sign()
            core.add_text(
                "Change The refresh time for the Overlay ( in seconds )")
            core.add_input_int("##RefreshTime",
                               default_value=refresh,
                               min_value=5,
                               step=0)
            core.add_button("Save refresh time##1", callback=save_refresh_time)
            if refreshSymbol in "True":
                refreshSymbol = True
            else:
                refreshSymbol = False
            core.add_spacing(count=2)
            core.add_text("Enable, Disable the refresh sign in the overlay")
            core.add_checkbox("Refresh Symbol##RefreshTime",
                              default_value=refreshSymbol,
                              callback=refresh_symbol)
            core.add_separator()
            core.add_separator()
            core.add_button("Close##Color", callback=animation_config_color)

        core.add_spacing(count=3)
        core.add_image_button("##ConfigWeb",
                              value="resources/web.png",
                              callback=animation_config_web,
                              frame_padding=1,
                              tip="Web")
        core.add_spacing(count=2)
        core.add_image_button("##ConfigQuestion",
                              value="resources/q.png",
                              callback=animation_config_help,
                              frame_padding=1,
                              tip="Help")
        core.add_same_line(xoffset=50)

        with simple.group("##Web", show=False):
            web = webFunctions.get_web()
            web_parameters = webHandler.get_web_parameters()
            print(web_parameters)
            bgimage = ""
            core.add_text("Browser Settings")
            core.add_checkbox("Open in Browser Only##Browser",
                              default_value=web[0],
                              callback=lambda sender, data: save_web())
            core.add_same_line()
            core.add_checkbox("Open in Browser and App##Browser",
                              default_value=web[1],
                              callback=lambda sender, data: save_web())
            core.add_spacing(count=2)
            core.add_text("Text Size (pixel)")
            core.add_input_int("##BrowserTextSize",
                               default_value=web_parameters[0][0],
                               min_value=5,
                               step=0,
                               callback=save_font)
            core.add_text("Text Font:")
            core.add_combo("Font Family##Web",
                           items=WEB_FONT,
                           default_value=web_parameters[0][1],
                           callback=save_font)
            core.add_spacing(count=2)
            core.add_text(name="Background Image##Web",
                          default_value="Background Image")
            core.add_input_text("##BgImage",
                                default_value=web_parameters[0][2],
                                readonly=True)
            core.add_button("Search Background Image##Web",
                            callback=openFileDialog.get_background_image,
                            callback_data=bgimage)
            core.add_same_line()
            core.add_button(
                "Delete Background Image##Web",
                callback=lambda sender, data: core.set_value("##BgImage", ""))
            core.add_separator()
            core.add_separator()
            core.add_button("Close##Web", callback=animation_config_web)

        with simple.group("##Help", show=False):
            core.add_text("OUTDATED, WILL BE UPDATED IN THE NEXT RELEASE")
            core.add_input_text(
                "##HelpIntroText",
                multiline=True,
                readonly=True,
                height=110,
                width=340,
                default_value="Welcome to the help page of the Faceit Overlay\n"
                "here the options and different possibilities are\n"
                "explained to you.\n"
                "Here is a small overview;\n"
                "1: Start menu\n"
                "2: Color configuration\n"
                "3: Overlay")
            core.add_spacing(count=2)
            core.add_text("1: Start menu")
            core.add_image("##StartmenuImage",
                           value="resources/start_menu.png")
            core.add_input_text(
                "##HelpStartMenuText",
                multiline=True,
                height=70,
                width=340,
                readonly=True,
                default_value="The start menu is the configuration menu\n"
                "Here you can change colors, global size\n"
                "Enable / disable stats you want to see\n"
                "and start the Overlay")
            core.add_spacing(count=2)
            core.add_text("2: Color configuration")
            core.add_image("##ColorconfImage",
                           value="resources/color_config.png")
            core.add_input_text(
                "##HelpColorConfigText",
                multiline=True,
                height=220,
                width=340,
                readonly=True,
                default_value=
                "Here you can adjust the colors according to your own taste.\n"
                "The buttons have the following functions:\n\n"
                "Test Color: Sets the color for the menu so that you can check it.\n"
                "Reset Color: Sets the colors back to the default value.\n"
                "Save Color: Saves the colors so that they will be kept\n"
                "\t\t\t\t\t   on the next startup.\n\n"
                "To adjust the global size of the texts and heads you can move \n"
                "the slider to the left or right and then use the buttons \n"
                "to perform the following functions:\n\n"
                "Reset: Set the size back to 1.0\n"
                "Save Size: Save the global size for the next start up")
            core.add_spacing(count=2)
            core.add_text("3: Overlay")
            core.add_image("##OverlayImage", value="resources/overlay.png")
            core.add_input_text(
                "##HelpOverlayText",
                multiline=True,
                height=100,
                width=340,
                readonly=True,
                default_value=
                "The overlay has basically no functionalities except \n"
                "that it updates itself regularly (every 60 seconds) \n"
                "and thus adjusts the values.\n"
                "But if you click on the headers \n"
                "FACEIT STATS | LAST GAME  you get back to the start screen.\n"
            )
            core.add_button("Close##Help", callback=animation_config_help)
    """ ---------------------------------------------------------------------------------------------------------------
                                                START DPG 
        -------------------------------------------------------------------------------------------------------------"""
    core.enable_docking(dock_space=False)
    core.start_dearpygui(primary_window="FACEIT Elo Overlay")
    def info_single_stock(self, data: dict):
        ticker = data["Ticker"]
        with window(ticker + "##window", width=500, height=500, no_scrollbar=False):
            self.menu(False, False, False, False)
            ticker_data = yfs.get_quote_table(ticker, dict_result=True)
            date_time = datetime.datetime.now()
            time = date_time.time()
            date = date_time.date()
            price = round(ticker_data["Quote Price"], 2)
            with group("heading", horizontal=True):
                with group("day_info"):
                    gg.add_text("Date: " + str(date), color=[255, 0, 0])
                    gg.add_text("Time: " + str(time), color=[255, 0, 0])
                try:
                    gg.add_label_text("Current Shares",
                                      label=f"Number of shares: {self.user.share_quantity[ticker]}",
                                      color=[0, 255, 0])
                except KeyError:
                    gg.add_label_text("Current Shares",
                                      label=f"Number of shares: 0",
                                      color=[0, 255, 0])
            with menu_bar("local_info"):
                gg.add_menu_item("ticker", label=ticker, enabled=False)
                gg.add_label_text("Current Balance", label=f"Current Balance: {self.user.current_balance}",
                                  color=[255, 0, 0])

            gg.add_separator()
            gg.add_text("Today")
            gg.add_separator()
            with managed_columns("day_info_ticker", columns=3):
                gg.add_text("Last close: " + str(ticker_data["Previous Close"]))
                gg.add_text("Open price: " + str(ticker_data["Open"]))
                gg.add_text("Current price: " + str(price))
            gg.add_separator()

            with group("Extra info", horizontal=True):
                with group("Extra Info##1"):
                    gg.add_text("Volume: " + str(ticker_data["Volume"]), bullet=True)
                    gg.add_text("Market Cap: " + str(ticker_data["Market Cap"]), bullet=True)
            
                with group("Extra info##2"):
                    gg.add_text("52 Week Range: " + str(ticker_data["52 Week Range"]), bullet=True)
                    one_year_estimate = ticker_data["1y Target Est"]
                    percent_change = get_percent_change(price, one_year_estimate)
                    if one_year_estimate > price:
                        colour = [0, 255, 0]
                    else:
                        colour = [255, 0, 0]

                    with group("1Y estimate", horizontal=True):
                        gg.add_text(f"1y Target Estimate: {ticker_data['1y Target Est']} |", bullet=True)
                        gg.add_text(f"{percent_change}%", color=colour)

            gg.add_spacing(count=5)

            # Table of share data on first day of each month since 365 days ago
            date_data_since = date - datetime.timedelta(365)
            table_monthly_interval_data = yfs.get_data(ticker, start_date=date_data_since, interval="1mo")
            gg.add_table("monthly_data", headers=["date"] + [header for header in table_monthly_interval_data])
            for date_index in table_monthly_interval_data.index:
                list_values = [str(date_index)[:10]]
                list_values.extend(list(table_monthly_interval_data.loc[date_index]))
                for i in range(len(list_values)):
                    if type(list_values[i]) == str:
                        continue
                    else:
                        list_values[i] = str(round(list_values[i], 3))
                gg.add_row("monthly_data", list_values)

            gg.add_spacing(count=2)

            def make_plot():
                date_data_since = date - datetime.timedelta(30)
                scatter_plot_weekly_data = yfs.get_data(ticker, start_date=date_data_since, interval="1d")
                indecis = [x for x in scatter_plot_weekly_data.index]
                start_date = indecis[0]
                x_axis = [(x - start_date).days for x in indecis]
                y_axis_max = [scatter_plot_weekly_data.loc[x]['high'] for x in indecis]
                y_axis_min = [scatter_plot_weekly_data.loc[x]['low'] for x in indecis]
                gg.add_plot("30 Day Price Fluctuation", height=300, scale_max=.5,
                            x_axis_name=f"Days since {start_date}", y_axis_name="Single share price")
                gg.add_scatter_series("30 Day Price Fluctuation", "Day High", x=x_axis, y=y_axis_max, size=3)
                gg.add_scatter_series("30 Day Price Fluctuation", "Day Low", x=x_axis, y=y_axis_min, marker=1, size=3)

                # Set initial plot view
                gg.set_plot_xlimits("30 Day Price Fluctuation", 0, 30)
                gg.set_plot_ylimits("30 Day Price Fluctuation", min(y_axis_min)*.97, max(y_axis_max)*1.03)
                gg.set_plot_ylimits_auto("30 Day Price Fluctuation")
                gg.set_plot_xlimits_auto("30 Day Price Fluctuation")

            make_plot()
            # Create purchase button and what not

            def purchase_stocks(sender, data):
                quantity = round(gg.get_value("Quantity"), 2)
                total_price = quantity * price
                gg.set_item_color("Message", style=1, color=[255, 0, 0])
                if self.user.current_balance < total_price:
                    set_item_label("Message", "Cannot purchase, insufficient funds")
                elif 0 >= total_price:
                    set_item_label("Message", "Must spend more than 0$")
                else:
                    set_item_label("Message", f"Purchase of {quantity} {ticker} shares at {price} made")
                    gg.set_item_color("Message", style=1, color=[0, 255, 0])
                    self.user.buy_share(quantity, price, ticker, str(date), str(time))
                    set_item_label("Current Balance", f"Current Balance: {self.user.current_balance}")
                    set_item_label("Current Shares", f"Number of shares: {self.user.share_quantity[ticker]}")

            def add_to_watchlist(sender, data):
                self.user.add_to_watchlist(ticker, price, database=True)
                set_item_label(sender, "Remove From Watchlist")
                gg.set_item_callback(sender, remove_from_watchlist)

            def remove_from_watchlist(sender, data):
                self.user.remove_from_watchlist(ticker)
                set_item_label(sender, "Add To Watchlist")
                gg.set_item_callback(sender, add_to_watchlist)

            with group("footer", horizontal=True):
                with group("Buy Stock Group"):
                    def get_dynamic_cost(sender, data):
                        # TODO dynamic colouring
                        cost = round(gg.get_value("Quantity") * price, 2)
                        set_item_label("Stock volume", f"Total Cost: {cost}")

                    gg.add_input_float("Stock volume", default_value=0,
                                       width=100, source="Quantity", label="Total cost: 0",
                                       callback=get_dynamic_cost, on_enter=True)
                    gg.add_label_text("Message", label="", color=[255, 0, 0])
                    gg.add_button("Buy Shares", callback=purchase_stocks)
                with group("Stock Watchlist"):
                    if ticker not in self.user.watchlist:
                        gg.add_button("Watchlist Button", callback=add_to_watchlist, label="Add To Watchlist")
                    else:
                        gg.add_button("Watchlist Button", callback=remove_from_watchlist, label="Remove From Watchlist")