示例#1
0
def login_succeeded():
    #Remove login, and add main window
    core.delete_item("login_window")
    core.delete_item("status_window")

    #Create the app
    main_app.create_app()
 def logged_in_mode(self):
     Menu()
     core.delete_item("Login Window")
     core.add_tab_bar(name="tab_bar", parent="Main Window")
     Tab("Workout", "tab_bar").generate_tab()
     Tab("Records", "tab_bar").generate_tab()
     simple.show_item("Main Menu")
        def create_new_user_data(sender, data) -> None:
            initial_data = {
            "User Name": gg.get_value("##user_name"),
            "Start Balance": gg.get_value("##balance_input")
            }

            if not initial_data["User Name"].isalpha():
                gg.add_label_text("Error", color=[255, 0, 0],
                                  before="##balance_input", label="Username must be alphabetical")
                gg.log_error("User-name must be only alphabets")
                return
            elif initial_data["User Name"] + ".db" in os.listdir():
                gg.add_label_text("Error", color=[255, 0, 0],
                                  before="##balance_input",label="Username already exists!")
                gg.log_error("User-name must be unique")
                return

            if initial_data["Start Balance"] <= 0:
                gg.add_label_text("Error_start_balance",
                                  color=[255, 0, 0], before="Proceed",label="Balance must be greater than 0$")
                gg.log_error("Balance must be greater than 0$!")
                return
            
            create_database(initial_data["User Name"] + ".db", initial_data["Start Balance"])
            gg.delete_item("Main")
            initial_screen()
示例#4
0
def request_login():
    #Get info from login input
    login_key = core.get_value("login_input")

    #Don't login if not connected
    if console_client.client.connected != True:
        create_error_text(
            "You can't login if you're not connected to a server")
        return

    #Check login key
    login_attempt = console_client.client.save_auth_token(login_key)

    #If the login succeeded
    if login_attempt.success:
        login_succeeded()

    #If login key failed, say something
    else:
        #Delete the current error text if it exists
        if core.does_item_exist("login_error_text"):
            core.delete_item("login_error_text")

        #Setup error text
        error_text = "There was an error checking your key!"

        if login_attempt.message == "file_editing":
            error_text = "There was an error editing the key file on disk"

        if login_attempt.message == "non_key":
            error_text = "The key you entered wasn't a key..."

        #Finally, add error
        create_error_text(error_text)
示例#5
0
    def load(self, *args, **kwargs):
        """Load a the serialized profiles for the current set of monitors"""
        dpg_core.log_info("Loading save profile")
        monitor_set_id = self.get_or_create_monitor_set_id()
        dpg_core.log_debug(f"Monitor set ID: {monitor_set_id}")
        serialized_profiles = self._saved_profiles.get(monitor_set_id)
        if not serialized_profiles:
            dpg_core.log_debug(
                f"No serialized profile for monitor set ID {monitor_set_id}")
            return
        dpg_core.log_debug(
            f"Found serialized profile for monitor set ID {monitor_set_id}")
        self.show_status("Load Successful!")

        for label in self._profiles:
            dpg_core.delete_item(label)
        self._profiles = {}
        self._tab_number = 1

        for serialized_profile in serialized_profiles:
            profile = self.add_tab()
            # Ensure the plot width is accurate
            self.resize_callback(None, None)
            profile.load_dict(serialized_profile)

        self.resize_callback(None, None)
        dpg_core.log_info(
            f"Successfully loaded saved profile {monitor_set_id}")
 def change_to_window(self, sender, data):
     scene = data["Scene Function"]
     gg.delete_item(gg.get_active_window())
     try:
         scene(data['kwargs'])
     except KeyError:
         scene()
示例#7
0
    def save_new_project(self, *_args):
        """
        Fetches data from the create new project window and inserts into db and then refreshes the
        combo dropdown values
        """
        project_data = dict()
        # pylint: disable=no-member
        for val in Project.__annotations__:
            project_data[val] = c.get_value(f"{val}##new_project")
        self.db.add_project(Project(**project_data, id=None))
        c.delete_item("Projects##ProjectMenu", children_only=True)
        for name in self.db.get_project_names():
            c.add_menu_item(
                name=name,
                callback=self.select_project,
                callback_data=name,
                parent="Projects##ProjectMenu",
            )

        c.add_menu_item(
            "Add project",
            parent="Projects##ProjectMenu",
            callback=self.create_new_project,
        )
        c.delete_item("Create New Project")
示例#8
0
    def refresh(self):
        '''
        Refreshes the MainMenu

        usage -- NOTE: draw() must be called before refresh()
        '''
        core.delete_item(self.title)
        self.draw()
示例#9
0
文件: moon.py 项目: zkxjzmswkwl/moon
def multiple_accounts(sender, data):
    core.delete_item('Account Email')
    core.delete_item('Account Password')

    core.add_input_text('Accounts File',
                        default_value='accs_to_level.txt',
                        before='Login',
                        width=200)
示例#10
0
 def _delete_widgets(self, widgets: [str]):
     """
     Helper function that takes a list of widget names (ids) and deletes them
     :param widgets: list of widgets
     :return:
     """
     if widgets:
         for name in widgets:
             core.delete_item(name)
示例#11
0
def create_error_text(error):
    #Delete the current error text if it exists
    if core.does_item_exist("login_error_text"):
        core.delete_item("login_error_text")

    core.add_text("login_error_text",
                  default_value=error,
                  before="login_button",
                  wrap=0)
示例#12
0
 def create_tab(self, sender, data):
     tab_name = dpg.get_value("NewTabName")
     dpg.delete_item("NewPopup")
     if dpg.does_item_exist("inittext"):
         dpg.delete_item("inittext")
     tab = trackers.Tab(tab_name, "tab_bar_1")
     self.tab_tracker.add_tab(tab)
     page = Page(f"{tab_name}Page", f"tab{tab.id}")
     tab.render(page)
示例#13
0
def delete_items(data):
    """
    Removes the window name.

    Parameters:
    data (List[str]): items to be deleted
    """
    for item in data:
        core.delete_item(item)
示例#14
0
def createTokenFile(sender, data):
    """
    Creates a new token.txt files and writes token to it.
    """
    token = core.get_value("##token")
    with open('token.txt', 'w') as token_f:
        token_f.write(token)
    core.delete_item('Enter you personal token from IBM website')
    start()
示例#15
0
 def cancel_workout(self):
     if core.does_item_exist("example_image"):
         core.delete_item("example_image")
     core.delete_item("buttons")
     core.delete_item("workout_table")
     simple.show_item("workout_composition_group")
     if core.get_value("Results successfully saved"):
         core.delete_item("Results successfully saved")
     if core.get_value("Error happened while saving the result"):
         core.delete_item("Results successfully saved")
示例#16
0
def switch_back_to_menu():
    logging.info("Switch back to start menu")
    global start_threading
    start_threading = 0
    hwnd = win32gui.GetForegroundWindow()
    win32gui.MoveWindow(hwnd, 0, 0, 492, 830, True)
    simple.show_item("##Overlay")
    simple.show_item("##Config")
    faceit_name = config_functions.get_faceit_name_from_db()
    core.delete_item(f"{faceit_name} Elo")
    win32gui.SetWindowText(hwnd, "FACEIT Elo Overlay")
示例#17
0
 def show_example(self, link):
     if core.does_item_exist("example_image"):
         core.delete_item("example_image")
     response = requests.get(link)
     if response.status_code == 200:
         open(EXAMPLE_IMAGE_FILE_PATH, "wb").write(response.content)
         core.add_image(
             "example_image",
             EXAMPLE_IMAGE_FILE_PATH,
             parent="workout_execution_group",
         )
示例#18
0
def checkCustomConnections(sender, data):
    # colect and process the connections between nodes
    for node_name in gui.arbitrary_node_list:
        connections = core.get_value(
            "connections to node {}##node_connection_{}".format(
                node_name, node_name))
        connections = list(item.strip(" ") for item in connections.split(","))
        gui.arbitrary_node_connections[node_name] = connections

    # transition the window to the next state
    core.delete_item('connection creation##100')
    core.configure_item('finalization##110', show=True)
示例#19
0
 def __restore_tab(self, data):
     try:
         if dpg.does_item_exist("inittext"):
             dpg.delete_item("inittext")
         tab = trackers.Tab(data["pagename"].replace("Page", ""),
                            "tab_bar_1")
         self.tab_tracker.add_tab(tab)
         page = Page(data["pagename"], f"tab{tab.id}", data["path"],
                     data["filename"])
         tab.render(page, data)
     except Exception as e:
         # TODO: Actually do something about this
         raise e
示例#20
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
 def save_new_row(self, sender, data):
     """
     Appends data from Add Data Window to table data
     and closes window
     """
     dev.log_debug("Adding new row -")
     self.table_data.append([
         len(self.table_data),
         c.get_value(": x_val"),
         c.get_value(": y_val"),
     ])
     self.update_data()
     c.delete_item("Add Data Window")
    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)
示例#23
0
 def load_match(sender,data):
     nonlocal pars
     nonlocal c_board
     coords = dpg.get_table_selections(sender)
     dpg.delete_item('Partidas')
     dpg.delete_item('Lista de Partidas')
     i = coords[0][0]
     match = pars.matches[i]
     pars.current_match = match
     c_board.board = match.board
     c_board.reading_pgn = True
     dpg.set_value('accion','Leyendo partida PGN')
     dpg.set_value('pieza','Sin seleccionar')
     c_board.draw_board()
示例#24
0
def show_button(sender, data):
    """
    Displays all the elements after connecting to IBM.
    """
    if (gui.server_on):
        if (gui.loading):
            core.delete_item('Please wait')
            gui.loading = False
        core.configure_item('##file_block', show=True)
        core.configure_item('##settings_block', show=True)
        core.configure_item('Process', show=True)
        core.configure_item('##images_block', show=True)
        core.configure_item('##output_block1', show=True)
        core.configure_item('##output_block2', show=True)
        core.configure_item('Program output:', show=True)
示例#25
0
    def __redraw(self):
        items = core.get_all_items()
        if "Layout" in items:
            core.delete_item("Layout")

        with simple.group("Layout", parent="MainWindow"):
            for index, i in enumerate(self.__board):
                core.add_image_button(f"button-{i}",
                                      f"image-{i}",
                                      width=self.__width,
                                      height=self.__height,
                                      frame_padding=0,
                                      callback=self.__cbButtonMove)
                if (index + 1) % self.__rows != 0:
                    core.add_same_line()
    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)
示例#27
0
    def __render(self):
        for x in ["press", "down", "release"]:
            kid = f"{x}-kid"
            if core.does_item_exist(kid):
                core.delete_item(kid)
            with simple.group(kid, parent=x, width=250):
                core.add_text(f'{x}-text', default_value=' ')

        for k, v in self.__keymap.items():
            if v['val'] == 1:
                core.add_text(v['name'], parent="press-kid")
            if v['val'] == 2:
                core.add_text(v['name'], parent="down-kid")
            if v['val'] == 4:
                core.add_text(v['name'], parent="release-kid")
                self.__keymap[k]['val'] = 0
示例#28
0
def delete_arbitrary_coupling_view():
    core.delete_item('##space9')
    if core.get_value("Architecture name:"):
        core.delete_item('Architecture name:')
        core.delete_item('radio##3')
    else:
        core.delete_item('There are no arbitrary couplings.')

    gui.prev_architecture = 0
示例#29
0
def check_iteration_num(sender, data):
    """
    Controls the number_of_iterations value so it will not be less than 1.

    If value is less than 1, a warning message is displayed and default value of 1 is set.
    """
    if core.get_value(sender) > 1 and core.get_value(
            'Number of iterations should not be less than 1.'):
        core.delete_item('Number of iterations should not be less than 1.')
    if core.get_value(sender) < 1:
        core.set_value('##num_of_iter', 1)
        if not core.get_value(
                'Number of iterations should not be less than 1.'):
            core.add_text('Number of iterations should not be less than 1.',
                          color=[255, 0, 0, 255],
                          before='##num_of_iter',
                          wrap=300)
示例#30
0
 def remove_tab(self, *args, **kwargs):
     """Close a tab"""
     # Due to https://github.com/hoffstadt/DearPyGui/issues/429, when a tab is closed, we have to
     # search for the tab to remove the profile itself
     remove = set()
     for label in self._profiles:
         if dpg_core.is_item_shown(label):
             dpg_core.configure_item(label,
                                     closable=dpg_core.get_value(label))
         else:
             dpg_core.delete_item(label)
             remove.add(label)
     self._profiles = {
         label: self._profiles[label]
         for label in self._profiles if label not in remove
     }
     dpg_core.log_info(f"Profiles {remove} successfully closed")