def create_component(self):
     """
     Creates window with structure for component.
     Used when combining with multiple components
     before running c.start_dearpygui()
     """
     with s.window(
             "Example Component",
             width=485,
             height=335,
             x_pos=0,
             y_pos=0,
     ):
         self._create_menu()
         c.add_table(
             self._table_name,
             headers=self.labels,
             width=200,
         )
         c.add_same_line()
         c.add_plot(
             self._plot_name,
             width=200,
             height=200,
             no_legend=True,
         )
         self.update_data()
    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()
Exemplo n.º 3
0
        def file_callback(sender, data):
            nonlocal c_board
            nonlocal pars

            pars = Parser()
            pars.get_plays(data[0]+'/'+data[1])

            # Lista de partidas cargadas--------------------------------TODO
            dpg.add_window('Lista de Partidas',on_close=close_callback)
            colums = set()
            for match in pars.matches:
                for att in match.attr:
                    colums.add(att)
            colums = list(colums)
            # colums.sort()
            dpg.add_table("Partidas", colums, callback=load_match)

            rows = list()
            for match in pars.matches:
                row = list()
                for colum in colums:
                    row.append(match.attr[colum])

                rows.append(row)

            for row in rows:
                dpg.add_row("Partidas", row)

            dpg.end()
Exemplo n.º 4
0
 def compose_workout(self):
     equipment_val = core.get_value("Equipment##widget")
     exercise_type_val = core.get_value("Exercise Type##widget")
     muscle_group_val = core.get_value("Muscle Group##widget")
     if not equipment_val or not exercise_type_val or not muscle_group_val:
         simple.show_item("Fill all the inputs, please.")
     else:
         simple.hide_item("workout_composition_group")
         self._composed_workout = workout_services.get_composed_workout(
             equipment_val, exercise_type_val, muscle_group_val)
         core.add_group(name="buttons", parent="workout_execution_group")
         core.add_table(
             "workout_table",
             ["Exercise", "Sets", "Reps", "Example"],
             parent="workout_execution_group",
             callback=self.toggle,
         )
         for workout in self._composed_workout:
             core.add_row("workout_table", list(workout.values()))
         core.add_button("Cancel##widget",
                         callback=self.cancel_workout,
                         parent="buttons")
         core.add_button("Clear##widget",
                         callback=self.clear_table,
                         parent="buttons")
         core.add_button("Save##widget",
                         callback=self.save_workout,
                         parent="buttons")
Exemplo n.º 5
0
 def generate_records_table(self):
     self._records = record_services.get_all_records_by_user(self._username)
     core.add_table(
         "record_table",
         ["Exercise", "Sets", "Reps", "Date"],
     )
     for record_arr in self._records:
         core.add_row("record_table", record_arr)
Exemplo n.º 6
0
    def __tableRefresh(self):
        if core.does_item_exist("table"):
            core.delete_item("table")

        # build the data model so we can search it
        core.add_table("table", self.__headers, parent="panel")
        search = core.get_value("filter")
        search = re.compile(filter, re.I)
        for row in self.__rows:
            for cell in row:
                if search.search(cell):
                    core.add_row("table", row)
                    break
Exemplo n.º 7
0
 def create_table(self, input_data: List[Entry]) -> None:
     """
     Creates table widget with name Entries##table
     :param input_data: Initial data to create table with
     :return: Table loaded with entries
     """
     self.prior_id = id(input_data)
     c.add_table(
         self.table_name,
         headers=["Project", "Description", "Duration", "Start", "End"],
     )
     for single_entry in input_data:
         self.add_row_to_entry_table(single_entry)
Exemplo n.º 8
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")
Exemplo n.º 9
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")
Exemplo n.º 10
0
 def compose_workout(self):
     equipment_val = core.get_value("Equipment##widget")
     exercise_type_val = core.get_value("Exercise Type##widget")
     muscle_group_val = core.get_value("Muscle Group##widget")
     if not equipment_val or not exercise_type_val or not muscle_group_val:
         simple.show_item("Fill all the inputs, please.")
     else:
         self.composed_workout = get_composed_workout(
             equipment_val, exercise_type_val, muscle_group_val)
         simple.hide_item("workout_composition_group")
         core.add_table("Workout", ["Exercise", "Sets", "Reps", "Example"],
                        callback=self.toggle)
         for el in self.composed_workout:
             core.add_row("Workout", list(el.values()))
         core.add_button("Cancel##widget")
         core.add_button("Save##widget")
Exemplo n.º 11
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')
Exemplo n.º 12
0
def table(*args, header_row: bool = True, width: int = 0, height: int = 0, inner_width: int = 0, show: bool = True, parent: str = "",
		before: str = "", resizable: bool = False, reorderable: bool = False, hideable: bool = False, sortable: bool = False,   
		context_menu_in_body: bool = False, row_background: bool = False, borders_innerH: bool = False, borders_outerH: bool = False,
		borders_innerV: bool = False, borders_outerV: bool = False, policy: int = 0, no_host_extendX: bool = False,
		no_host_extendY: bool = False, no_keep_columns_visible: bool = False, precise_widths: bool = False, no_clip: bool = False,
		pad_outerX: bool = False, no_pad_outerX: bool = False, no_pad_innerX: bool = False, scrollX: bool = False, scrollY: bool = False,
        id:str='', indent=-1, callback: Callable = None, sort_multi: bool = False, sort_tristate: bool = False):
    """Wraps add_table() and automates calling end().

    Args:
        name: Unique name used to programmatically refer to the item. If label is unused this will be the label,
            anything after "##" that occurs in the name will not be shown on screen.
			**header_row: show headers at the top of the columns
			**width: 
			**height: 
			**inner_width:
			**show: Attempt to render
			**parent: Parent this item will be added to. (runtime adding)
			**before: This item will be displayed before the specified item in the parent. (runtime adding)
			**resizable: Enable resizing columns
	        **reorderable: Enable reordering columns in header row
	        **hideable: Enable hiding/disabling columns in context menu.
	        **sortable: Enable sorting.
	        **context_menu_in_body: Right-click on columns body/contents will display table context menu.
			**row_background: Set each RowBg color with ImGuiCol_TableRowBg or ImGuiCol_TableRowBgAlt (equivalent of calling TableSetBgColor with ImGuiTableBgFlags_RowBg0 on each row manually)
	        **borders_innerH: Draw horizontal borders between rows.
	        **borders_outerH: Draw horizontal borders at the top and bottom.
	        **borders_innerV: Draw vertical borders between columns.
	        **borders_outerV: Draw vertical borders on the left and right sides.
	        **policy: sizing policy
			**no_host_extendX: Make outer width auto-fit to columns, overriding outer_size.x value. Only available when ScrollX/ScrollY are disabled and Stretch columns are not used.
			**no_host_extendY: Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.
			**no_keep_columns_visible: Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable.
			**precise_widths: Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.
			**no_clip: Disable clipping rectangle for every individual columns.
	        **pad_outerX: Default if BordersOuterV is on. Enable outer-most padding. Generally desirable if you have headers.
	        **no_pad_outerX: Default if BordersOuterV is off. Disable outer-most padding.
	        **no_pad_innerX: Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off).
	        **scollX: Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Changes default sizing policy. Because this create a child window, ScrollY is currently generally recommended when using ScrollX.
	        **scollY: Enable horizontal vertical.

    Returns:
        None
    """
    try:
        widget = internal_dpg.add_table(*args, header_row=header_row, width = width, height = height, inner_width = inner_width,
		    show = show, parent = parent, before = before, resizable = resizable, reorderable = reorderable, hideable = hideable,
		    sortable = sortable, context_menu_in_body = context_menu_in_body, row_background = row_background,
		    borders_innerH = borders_innerH, borders_outerH = borders_outerH, borders_innerV = borders_innerV,
		    borders_outerV = borders_outerV, policy = policy, no_host_extendX = no_host_extendX,
		    no_host_extendY = no_host_extendY, no_keep_columns_visible = no_keep_columns_visible, precise_widths = precise_widths,
		    no_clip = no_clip, pad_outerX = pad_outerX, no_pad_outerX = no_pad_outerX, no_pad_innerX = no_pad_innerX,
		    scrollX = scrollX, scrollY = scrollY, id=id, indent=indent, callback=callback, sort_multi=sort_multi,
            sort_tristate=sort_tristate)
        internal_dpg.push_container_stack(widget)
        yield widget
    finally:
        internal_dpg.pop_container_stack()
Exemplo n.º 13
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}")
Exemplo n.º 14
0
 def user_dashboard(self):
     with window("User Dash", width=500, height=500):
         self.menu(True, False, False, False)
         with group("Basic user info", horizontal=True):
             gg.add_text(f"Username: {self.user.file[:-3]}")
             gg.add_text(f"Starting Balance: {self.user.start_funds}")
             net_worth = round(sum(self.user.share_quantity[ticker]*yfs.get_live_price(ticker)
                              for ticker in self.user.share_quantity), 2) + self.user.current_balance
             gg.add_text(f"Net Worth: {net_worth}")
         with group("Tables", horizontal=True):
             gg.add_table("Your Watchlist", headers=["Watchlist Ticker Name"], width=150)
             for stock in self.user.watchlist:
                 gg.add_row("Your Watchlist", [f"{stock}"])
             gg.add_table("Your stocks", headers=["Ticker Name", "Date", "Quantity"])
             for stock in self.user.share_by_name:
                 for share_data in self.user.share_by_name[stock]:
                     row = [stock, share_data[1], str(share_data[-1])]
                     gg.add_row("Your stocks", row)
Exemplo n.º 15
0
    core.set_table_item("Earnings", 5, 1, repr(calendar.iloc[5, 0]))
    core.set_table_item("Earnings", 6, 1, repr(calendar.iloc[6, 0]))


with simple.window("Tables",
                   height=300,
                   width=500,
                   x_pos=980,
                   y_pos=110,
                   no_close=True):
    with simple.menu("Select Company##table"):
        for file in os.listdir("dataset"):
            filename = os.fsdecode(file)
            if filename.endswith(".csv"):
                core.add_menu_item(filename.split('_')[0] + "##table",
                                   callback_data=filename.split('_')[0],
                                   callback=update_table)
    core.add_table("Earnings", ["Specs", "Value"])
    core.add_row("Earnings", ["Earnings Date", ""])
    core.add_row("Earnings", ["Earnings Average", ""])
    core.add_row("Earnings", ["Earnings Low", ""])
    core.add_row("Earnings", ["Earnings High", ""])
    core.add_row("Earnings", ["Revenue Average", ""])
    core.add_row("Earnings", ["Revenue Low", ""])
    core.add_row("Earnings", ["Revenue High", ""])

# core.show_logger()
# simple.show_documentation()

core.start_dearpygui()
Exemplo n.º 16
0
    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")
Exemplo n.º 17
0
    def start(self):
        available_out_ports = mido.get_output_names()
        available_in_ports = mido.get_input_names()

        if len(available_in_ports) > 0:
            status.current_in_port = mido.open_input(
                available_in_ports[0], callback=self.get_midi_input)

        if len(available_out_ports) > 0:
            self.out_port = mido.open_output(available_out_ports[0])

        core.set_main_window_size(350, 550)
        core.set_main_window_title('Fractal Melody Machine')
        core.set_theme('Gold')

        with simple.window('Fractal Melody Machine', width=500, height=300):
            core.add_text('MIDI Input Port')
            core.add_combo('ComboInPort', items=mido.get_input_names(
            ), default_value=status.current_in_port.name, label='', width=100, callback=self.change_midi_in_port)

            core.add_text('MIDI Output Port')
            core.add_combo('ComboOutPort', items=mido.get_output_names(
            ), default_value=self.out_port.name, label='', width=100, callback=self.change_midi_out_port)

            core.add_spacing(count=10)

            core.add_text('BPM')
            core.add_slider_int('SliderBPM', default_value=60, min_value=20, max_value=200, label='', width=100, callback=self.change_bpm)

            core.add_text('Depth')
            core.add_slider_int('SliderDepth', default_value=4, min_value=1,
                                max_value=16, label='', width=100, callback=self.change_depth)

            core.add_same_line(spacing=45)
            core.add_text('DetectedKey', default_value='Detected Key: ')

            core.add_text('Branching Factor')
            core.add_slider_int('SliderBF', default_value=2, min_value=2,
                                max_value=4, label='', width=100, callback=self.change_bf)

            core.add_text('Octave Spread')
            core.add_child('OctaveWindow', width=300, height=150)
            core.end()

            core.add_text('Figures')
            core.add_child('FigureWindow', width=300, height=150)

            core.add_table('FigureTable', [], hide_headers=True, height=10)

            core.add_columns('FigureTableCols', 2, border=False)

            core.add_checkbox(str(theory.FIGURE_WHOLE_NOTE), label='Whole note', callback=self.change_figures)
            core.add_checkbox(str(theory.FIGURE_QUARTER_NOTE), label='Quarter note', callback=self.change_figures, default_value=True)
            core.add_checkbox(str(theory.FIGURE_16TH_NOTE), label='16th note', callback=self.change_figures)
            core.add_checkbox(str(theory.FIGURE_64TH_NOTE), label='64th note', callback=self.change_figures)

            core.add_next_column()

            core.add_checkbox(str(theory.FIGURE_HALF_NOTE), label='Half note', callback=self.change_figures)
            core.add_checkbox(str(theory.FIGURE_8TH_NOTE), label='8th note', callback=self.change_figures, default_value=True)
            core.add_checkbox(str(theory.FIGURE_32ND_NOTE), label='32nd note', callback=self.change_figures)

            core.end()

            # Initialize octave spread sliders
            self.change_depth()

        core.start_dearpygui(primary_window='Fractal Melody Machine')
Exemplo n.º 18
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)