def run(self):
        """
        A very basic stand-aloen run method to show what this looks like by default
        :return: General number display example
        """

        window_args = dict(
            autosize=False,
            height=200,
            width=200,
            x_pos=0,
            y_pos=0,
        )
        with s.window("Drawing", **window_args):
            c.add_drawing(self.name, width=90, height=150)

        with s.window(
                "command##window",
                autosize=True,
                y_pos=200,
                x_pos=0,
        ):
            c.add_input_text(
                name="command##input",
                width=600,
                height=300,
                multiline=True,
                on_enter=True,
                callback=self.execute,
            )

        c.start_dearpygui()
Пример #2
0
    def create_timer(self, **kwargs):
        """
        Creates timer window for composing into other classes
        :param kwargs: Key words for s.window
        :return: Create timer window plus timergroup
        """
        window_args = dict(
            autosize=True,
            height=150,
            width=540,
            x_pos=0,
            y_pos=0,
            no_title_bar=True,
            no_resize=True,
            no_move=True,
            no_background=True,
            no_scrollbar=True,
        )

        for kwarg, value in kwargs.items():
            window_args[kwarg] = value

        with s.window("timer##display", **window_args):
            with s.group(name="timergroup", horizontal=True):
                for section in self.display:
                    for cell in section:
                        cell.build_number_box()
Пример #3
0
    def run(self):
        """
        A very basic stand-aloen run method to show what this looks like by default
        :return: General number display example
        """
        base = BaseGUI(development=True)
        base.initialize_base_screens()
        window_args = dict(
            autosize=False,
            height=250,
            width=900,
            x_pos=0,
            y_pos=0,
            no_title_bar=True,
            no_resize=True,
            no_move=True,
            no_background=False,
        )
        with s.window("single_cell", **window_args):
            with s.group(name="timergroup", horizontal=True):
                self.build_number_box()

        self.render(Digit.num_8, 8)

        c.start_dearpygui()
Пример #4
0
def search_db(sender, data):
    simple.hide_item("Create Document from Template")
    session = Session()
    vars = session.query(Variable).order_by(Variable.name.asc())
    with simple.window(f"Search in DB ({data.split('_')[0]})",
                       **default_window()):
        core.add_text("All variables")
        for var in vars:
            core.add_input_text(
                f"{var.name}_name_search",
                label="",
                width=150,
                enabled=False,
                default_value=var.name,
            )
            core.add_same_line(spacing=10)
            core.add_input_text(
                f"{var.name}_content_search",
                label="",
                width=300,
                enabled=False,
                default_value=var.content,
            )
            core.add_same_line(spacing=10)
            core.add_button(
                f"{var.name}_update_button_search",
                label="Use this value",
                callback=use_value,
                callback_data=((data, var.content)),
            )
        core.add_button(
            "button_db_close",
            label="Close Window",
            callback=close_popup,
        )
Пример #5
0
    def draw(self):
        '''
        Draws the MainMenu
        '''
        with simple.window(self.title, **config.MENU_CONFIG):
            with simple.menu_bar('Main Menu'):

                with simple.menu('File'):
                    core.add_menu_item('New', callback=self.new)
                    core.add_menu_item('Open', callback=self.open_file)
                    core.add_menu_item('Save', callback=self.save)
                    core.add_menu_item('Save As', callback=self.save_as)

                with simple.menu('Settings'):
                    with simple.menu('Theme'):
                        for theme in config.THEMES:
                            core.add_menu_item(theme,
                                               callback=self.set_theme,
                                               check=True)

            if self.dedit.get_name():
                core.add_text("Tree: {}".format(self.dedit.get_name()))
            else:
                core.add_text("Tree: <unnamed>.json")

            self.dedit.draw()
def example_one():
    """
    Creates window plus execution callback ready to take input commands
    """
    def execute(*_args):
        """
        Executes arbitrary command input in running program
        :param _args: This catches sender and data arguments that we aren't using here
        :return: None, executes command
        """
        command = c.get_value("command##input")
        exec(command)

    with s.window(
            name="command##window",
            autosize=True,
            x_pos=0,
            y_pos=0,
    ):
        c.add_input_text(
            name="command##input",
            width=500,
            height=300,
            multiline=True,
            on_enter=True,
            callback=execute,
        )

    c.start_dearpygui()
Пример #7
0
    def __init__(self, 
        height: int, 
        width:  int,
        x_pos:  int,
        y_pos:  int,
        delete_image_callback: callable,
        delete_all_duplicates_callback: callable):

        self._window_name: str = 'Results Window'

        self._delete_image_callback: callable = delete_image_callback

        self._delete_all_duplicates_callback: callable = delete_all_duplicates_callback


        self._duplicates_list: [FileMetaDataList] = []     

        # RGB color of special text
        self._control_text_color = [0, 200, 255]

        with simple.window(self._window_name):
            core.configure_item(
                self._window_name,
                    width=width,
                    height=height,
                    x_pos=x_pos,
                    y_pos=y_pos,
                    label='Results')
Пример #8
0
    def __init__(self):
        # tracks all the dpg mvKey_ constants
        self.__keymap = {}
        for const in dir(core):
            if const.startswith('mvKey_'):
                c = getattr(core, const)
                self.__keymap[c] = {'name': const, 'val': 0}

        core.set_main_window_size(750, 480)

        with simple.window("main"):
            with simple.group("press"):
                ...
            core.add_same_line()

            with simple.group("down"):
                ...
            core.add_same_line()

            with simple.group("release"):
                ...

        core.set_key_press_callback(self.__press)
        core.set_key_down_callback(self.__down)
        core.set_key_release_callback(self.__release)
        core.set_render_callback(lambda s, d: self.__render())
Пример #9
0
    def __init__(self):
        core.set_style_frame_padding(3, 3)
        core.set_style_window_padding(3, 3)
        core.set_main_window_size(650, 450)
        core.set_global_font_scale(1.5)
        with simple.window("main", autosize=True):
            with simple.group("panel", width=210):
                count = max(22, len(_fontnames))
                core.add_input_text("regex", label='', default_value=" ")
                core.add_listbox("font",
                                 label='',
                                 items=_fontnames,
                                 num_items=count,
                                 width=210,
                                 callback=self.__changed)
            core.add_same_line()
            with simple.group("text"):
                core.add_text(
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\
				Phasellus in mollis mauris. Donec tempor felis eget libero accumsan sagittis.\
				Integer efficitur urna sed nibh auctor, non hendrerit libero pulvinar.\
				Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere\
				cubilia curae; In hac habitasse platea dictumst. Vestibulum consectetur,\
				sem vitae tristique rhoncus, sem ex maximus ligula, vitae egestas lorem libero\
				nec libero. Pellentesque habitant morbi tristique senectus et netus et malesuada\
				fames ac turpis egestas. Praesent gravida laoreet pharetra. Ut nec vulputate purus.\
				Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos\
				himenaeos. Maecenas malesuada neque vel ipsum imperdiet, et lobortis justo sollicitudin.",
                    wrap=560)
        simple.show_style_editor()
Пример #10
0
def create_server_input(dimensions):
    with simple.window(
            "server_input",
            width=dimensions.width,
            height=dimensions.height,
            x_pos=dimensions.x,
            y_pos=dimensions.y,
            no_resize=True,
            no_move=True,
            no_title_bar=True,
    ):
        #DEBUG TEXT
        core.add_text("Server Input")

        #Add input text
        core.add_value("input_text_value", "")

        core.add_input_text("input_text",
                            label="",
                            on_enter=True,
                            callback=enter_button,
                            source="input_text_value")
        core.add_button("input_button",
                        label="Send to Server",
                        callback=enter_button)
 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 add_data_option(self, sender, data):
        """
        Creates the data input window for the add data window
        """

        with s.window(
                "Add Data Window",
                autosize=True,
                x_pos=0,
                y_pos=350,
        ):
            # Title text
            c.add_text("Add a new data row:")
            c.add_text(
                name=f"Idx: \t{len(self.table_data)}",
                tip="This is created automatically",
            )
            # Text divider
            c.add_text("-" * 30)
            # input sliders
            c.add_slider_int(name=": x_val")
            c.add_slider_int(name=": y_val")

            # Action buttons
            c.add_button(
                "Cancel",
                callback=lambda *args: c.delete_item("Add Data Window"),
            )
            c.add_same_line()
            c.add_button("Add Row", callback=self.save_new_row)
Пример #13
0
    def show(self) -> None:
        if core.does_item_exist(self._win_name):
            self.destroy(self._win_name)

        obj_name = self._entry.get_object_name()

        with simple.window(self._win_name,
                           label=f"{obj_name}",
                           on_close=self.destroy,
                           width=400):
            ts = self._entry.get_timestamp_str()
            age = self._entry.get_age()

            core.add_label_text(self._win_name + "ts",
                                label=f"Timestamp",
                                default_value=f"{ts}")
            core.add_label_text(self._win_name + "age",
                                label=f"Age",
                                default_value=f"{age}")
            core.add_label_text(self._win_name + "freq",
                                label=f"Frequency",
                                default_value=f"0.0 Hz")
            core.add_text("")
            core.add_label_text(self._win_name + "content",
                                default_value=str(self._entry.get_object()),
                                label="")

        self._freq_thread.start()
Пример #14
0
    def init_ui(self):
        """Initialize the main window's UI

        The main window has save and load buttons and a tab bar for the profiles.
        """
        with dpg_simple.window("Main Window"):
            dpg_core.add_button(self._save_id, callback=self.save)
            dpg_core.add_same_line()
            dpg_core.add_button(self._load_id, callback=self.load)
            dpg_core.add_same_line(name=self._status_id_same_line, show=False)
            dpg_core.add_text(self._status_id, default_value="", show=False)

            main_window_tab_bar_ctx = dpg_simple.tab_bar(
                "##MainWindow-tabbar",
                parent="Main Window",
                reorderable=True,
                callback=self.remove_tab,
            )
            with main_window_tab_bar_ctx:
                self.add_tab()
                dpg_core.add_tab_button(
                    "+##MainWindow-btn",
                    parent="##MainWindow-tabbar",
                    callback=self.add_tab,
                    trailing=True,
                    no_tooltip=True,
                )
Пример #15
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")
Пример #16
0
def create_status(x, y):
    #Setup login window size
    width  = 245
    height = 220


    #Build window size
    with simple.window(
        "status_window",

        no_title_bar = True,
        no_close     = True,
        no_resize    = True,
        no_move      = True,
        autosize     = False,
        
        width  = width,
        height = height,

        x_pos = x,
        y_pos = y,
    ):
        #Title
        core.add_text("== SERVER STATUS ==")

        show_server_status()
Пример #17
0
    def create_new_project(self, *_args):
        """
        Defines a simple window that takes inputs for creating a new project
        :return: On save inserts project data into database
        """
        with s.window("Create New Project", autosize=True):
            c.add_input_text("project_name##new_project", label="Project Name")
            c.add_input_text("client##new_project", label="Client")
            c.add_slider_int(
                "rate##new_project",
                label="Billing Rate per hour",
                max_value=100,
                tip="ctrl+click to directly type the number",
            )
            c.add_slider_int(
                "monthly_frequency##new_project",
                label="Pay Frequency per Month",
                default_value=2,
                max_value=8,
                tip="How frequently pay is given, default twice a month",
            )
            c.add_slider_int(
                "weekly_hour_allotment##new_project",
                label="Weekly Hours",
                max_value=80,
                default_value=20,
                tip="Hours per week for project.",
            )

            c.add_button("Save##SaveProject", callback=self.save_new_project)
Пример #18
0
    def construct(self):
        core.set_main_window_title("Pathfinder")
        core.set_main_window_pos(0, 0)
        core.set_main_window_size(width=self.width, height=self.height)
        core.set_main_window_resizable(resizable=False)

        with simple.window("main_window"):
            core.add_group("main_panel", parent="main_window", horizontal=True)
            # MapDisplay ######################################################
            map_display = MapDisplay("map_display",
                                     parent="main_panel",
                                     tile_radius=1,
                                     latitude=47.4751158,
                                     longitude=19.0057389)
            map_display.construct()

            # InputPanel ######################################################
            core.add_group("user_panel", parent="main_panel", horizontal=False)
            input_panel = InputPanel("input_panel",
                                     parent="user_panel",
                                     map_display=map_display)
            input_panel.construct()

            execution_panel = ExecutionPanel("execution_panel",
                                             parent="user_panel",
                                             plotter=map_display)
            execution_panel.construct()
            core.end()  # user_panel

            ###################################################################
            core.end()  # main_panel
Пример #19
0
def open_about_window(sender, data):
    """
    Opens new window with credentials
    """
    with simple.window('About##window',
                       width=700,
                       height=300,
                       on_close=delete_items(['About##window'])):
        core.add_text('Developers:')
        core.add_text(
            '* Valeriy Novossyolov [Computer Science senior student, Nazarbayev University]'
        )
        core.add_text(
            '* Saadat Nursultan [Computer Science senior student, Nazarbayev University]'
        )
        core.add_spacing(name='##space10', count=5)
        core.add_text('Adviser:')
        core.add_text(
            '* Martin Lukac [Associate Professor, Dep. of Computer Science, Nazarbayev University]'
        )
        core.add_spacing(name='##space10', count=5)
        core.add_text('Developed to support the scientific paper')
        core.add_text(
            "'Geometric Refactoring of Quantum and Reversible Circuits: Quantum Layout'"
        )
        core.add_text(
            'by Martin Lukac, Saadat Nursultan, Georgiy Krylov and Oliver Keszocze'
        )
Пример #20
0
def add_db():
    simple.hide_item("Create Document from Template")
    with simple.window("Add Variable to DB", **default_window()):
        core.add_text("Variable Name".ljust(23))
        core.add_same_line(spacing=10)
        core.add_text("Variable Content")
        core.add_input_text(
            "name_db_add",
            label="",
            width=150,
        )
        core.add_same_line(spacing=10)
        core.add_input_text(
            "content_db_add",
            label="",
            width=300,
        )
        core.add_button(
            "button_db_add",
            label="Add Variable",
            callback=add_variable_gui,
            callback_data=("name_db_add", "content_db_add"),
        )
        core.add_button(
            "button_db_close",
            label="Close Window",
            callback=close_popup,
        )
Пример #21
0
	def __init__(self):
		core.set_style_item_spacing(1, 1)
		core.set_style_window_padding(0, 0)
		core.set_main_window_size(690, 450)
		with simple.window("main"):
			core.add_drawing("canvas")
		core.set_resize_callback(self.__resize)
		core.set_render_callback(self.__render)
Пример #22
0
 def __init__(self):
     with simple.window("Login Window",
                        no_title_bar=True,
                        autosize=True,
                        no_resize=True):
         core.add_group(name="signup_els")
         core.add_group(name="login_els")
         self.add_login_els()
Пример #23
0
	def __init__(self):
		core.set_main_window_size(720, 540)
		with simple.window("main"):
			with simple.group("group"):
				core.add_button("thread", label='Add Thread', callback=lambda s, d: self.__buttonThread())

		self.__bars = {}
		core.set_render_callback(lambda s, d: self.__render())
		core.set_resize_callback(lambda s, d: self.__resize())
Пример #24
0
	def __init__(self):
		core.set_vsync(False)
		core.set_style_frame_padding(0, 0)

		self.__width = 60
		self.__height = 40
		self.__fire = [0] * (self.__height * self.__width)

		with simple.window("Controls", width=220, no_resize=True):
			core.add_slider_int("Width", width=150, default_value=self.__width, min_value=5, max_value=80, clamped=True)
			core.add_slider_int("Height", width=150, default_value=self.__height, min_value=5, max_value=50, clamped=True)

		with simple.window("MainWindow"):
			core.add_drawing("Canvas", width=1920, height=1080)
			color = (0, 0, 0, 255)
			for i in range(self.__width, self.__width * self.__height):
				core.draw_quad("Canvas", (0, 0), (0, 0), (0, 0), (0, 0), color, thickness=0, tag=f"quad-{i}")
		core.set_render_callback(self.__render)
Пример #25
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'])
Пример #26
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_separator()
            core.add_plot(self.plotName)
        super().__init__()
Пример #27
0
def open_qasm(sender, data):
    """
    Opens window with qasm code
    """
    with simple.window('Qasm code',
                       width=500,
                       height=600,
                       on_close=delete_items(['Qasm code'])):
        with open(gui.qasm_file, 'r') as f:
            core.add_text(f.read())
Пример #28
0
    def next_round(self):
        core.configure_item("next_round", enabled=False)

        self.round += 1
        core.set_value("round", str(self.round))

        for stock in self.stocks:
            core.configure_item(f"stock.{stock.name}.owned", enabled=False)
            stock.new_price()

        self.player.apply_market_changes()
        core.set_value("cash", self.player.cash)

        bankrupted = []
        share_issued = []
        for stock in self.stocks:
            if stock.is_bankcrupted():
                bankrupted.append(stock)
                stock.price = 10
                stock.dividend = 0
                stock.change = 0
                stock.previous_price = 0
            if stock.is_share_issued():
                share_issued.append(stock)
            core.set_value(f"stock.{stock.name}.price", f"{stock.price:0.2f}")
            core.set_value(f"stock.{stock.name}.previous_price",
                           f"{stock.previous_price:0.2f}")
            core.set_value(f"stock.{stock.name}.change",
                           f"{stock.change:0.2f}")
            core.set_value(f"stock.{stock.name}.dividend",
                           f"{stock.dividend:0.2f}")

        if bankrupted or share_issued:
            with simple.window(
                    "Stock news!",
                    autosize=True,
                    no_collapse=True,
                    no_move=True,
                    on_close=self.news_close,
            ):
                if bankrupted:
                    core.add_text("The following stocks are gone bankruptcy:")
                    for stock in bankrupted:
                        core.add_text(f"{stock.name}")
                    core.add_spacing(count=5)
                if share_issued:
                    core.add_text(
                        "The following stocks are giving share issue:")
                    for stock in share_issued:
                        core.add_text(f"{stock.name}")
                core.add_spacing(count=5)
                core.add_button(
                    "Close", callback=lambda: self.news_close("Stock news!"))
        else:
            self.news_close("")
def example_two():
    """
    Commands to put into input
    """
    with s.window("Hello World", autosize=True):
        c.add_text("Hello world!")

    c.show_logger()
    c.log_info("Foo")
    c.log_info("Check it out ma - no IDE!")

    with s.window("Canvas", x_pos=0, y_pos=300, autosize=True):
        c.add_drawing("Draw", width=300, height=300)
        c.draw_circle(
            "Draw",
            center=[150, 150],
            radius=50,
            color=[125, 125, 125],
            fill=[125, 125, 200],
        )
Пример #30
0
    def __init__(self):
        self.__fontSize = 1.
        self.__fontSizeStep = .1
        self.__fontSizeRange = (.8, 15.)
        core.set_global_font_scale(self.__fontSize)
        core.set_theme("Cherry")
        core.set_main_window_size(960, 540)

        with simple.window("MainWindow", autosize=True):
            core.add_text("HELLO WORLD!")
        core.set_mouse_wheel_callback(self.__cbMouseWheel)