Python tkinter.messagebox 模块,askyesno() 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用tkinter.messagebox.askyesno()

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def toggle_tabs_event(self, event):
        if self.askyesno(
              "Toggle tabs",
              "Turn tabs " + ("on", "off")[self.usetabs] +
              "?\nIndent width " +
              ("will be", "remains at")[self.usetabs] + " 8." +
              "\n Note: a tab is always 8 columns",
              parent=self.text):
            self.usetabs = not self.usetabs
            # Try to prevent inconsistent indentation.
            # User must change indent width manually after using tabs.
            self.indentwidth = 8
        return "break"

    # XXX this isn't bound to anything -- see tabwidth comments
##     def change_tabwidth_event(self, event):
##         new = self._asktabwidth()
##         if new != self.tabwidth:
##             self.tabwidth = new
##             self.set_indentation_params(0, guess=0)
##         return "break"
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def next_match(self, event=None):
        try:
            current_target, current_target_end = self.match_coordinates[self.current_match]
            self.main_text.tag_remove("sel", current_target, current_target_end)
            self.main_text.tag_add("findmatch", current_target, current_target_end)
        except IndexError:
            pass

        try:
            self.current_match = self.current_match + 1
            next_target, target_end = self.match_coordinates[self.current_match]
        except IndexError:
            if len(self.match_coordinates) == 0:
                msg.showinfo("No Matches", "No Matches Found")
            else:
                if msg.askyesno("Wrap Search?", "Reached end of file. Continue from the top?"):
                    self.current_match = -1
                    self.next_match()
        else:
            self.main_text.mark_set(tk.INSERT, next_target)
            self.main_text.tag_remove("findmatch", next_target, target_end)
            self.main_text.tag_add("sel", next_target, target_end)
            self.main_text.see(next_target)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def next_match(self, event=None):
        try:
            current_target, current_target_end = self.match_coordinates[self.current_match]
            self.main_text.tag_remove("sel", current_target, current_target_end)
            self.main_text.tag_add("findmatch", current_target, current_target_end)
        except IndexError:
            pass

        try:
            self.current_match = self.current_match + 1
            next_target, target_end = self.match_coordinates[self.current_match]
        except IndexError:
            if len(self.match_coordinates) == 0:
                msg.showinfo("No Matches", "No Matches Found")
            else:
                if msg.askyesno("Wrap Search?", "Reached end of file. Continue from the top?"):
                    self.current_match = -1
                    self.next_match()
        else:
            self.main_text.mark_set(tk.INSERT, next_target)
            self.main_text.tag_remove("findmatch", next_target, target_end)
            self.main_text.tag_add("sel", next_target, target_end)
            self.main_text.see(next_target)
项目:FBIThemePreviewer    作者:jurassicplayer    | 项目源码 | 文件源码
def saveConfig(self, config_type):
        print("Saving config: {}".format(config_type))
        if config_type == "config":
            filepath = "config"
            config_dict = self.app_config
            ordered = ['theme_folder', 'theme_title', 'theme_desc', 'theme_author', 'theme_version', 'meta_icon', 'screen_gap', 'anim_duration', 'overwrite', 'language']
        elif config_type == "textcolor":
            theme_folder = self.app_config['theme_folder']
            os.makedirs(theme_folder, exist_ok=True)
            filepath = os.path.join(theme_folder,'textcolor.cfg')
            config_dict={}
            for key in self.text_config:
                value = "{}{}".format(self.text_config[key]['alpha'], swapRGBBGR(self.text_config[key]['rgb'])[1:])
                config_dict.update({key: value})
            ordered = ['text', 'nand', 'sd', 'gamecard', 'dstitle', 'file', 'directory', 'enabled', 'disabled', 'installed', 'notinstalled', 'ticketinuse', 'ticketnotinuse']
            if os.path.isfile(filepath) and not self.app_config['overwrite'] in ['always', 'textcolor']:
                if not messagebox.askyesno("Warning", "A textcolor.cfg already exists, do you want to overwrite?", icon='warning'):
                    return
        with open(filepath, 'w') as f:
            for key in ordered:
                f.write("{}={}\n".format(key, config_dict[key]))
            f.truncate(f.tell() - len(os.linesep))
项目:FBIThemePreviewer    作者:jurassicplayer    | 项目源码 | 文件源码
def savePreview(self):
        print("Generating preview image...")
        x1 = self.winfo_rootx()+self.canvas.winfo_x()
        y1 = self.winfo_rooty()+self.canvas.winfo_y()
        x2 = x1+self.canvas.winfo_width()
        y2 = y1+self.canvas.winfo_height()
        coords = [x1, y1, x2, y2]
        if os.path.isfile("preview.png") and not self.app_config['overwrite'] in ['always', 'preview']:
            if not messagebox.askyesno("Warning", "Preview image already exists, do you want to overwrite?", icon='warning'):
                return
        self.attributes("-topmost", 1)
        self.attributes("-topmost", 0)
        self.canvas.delete('toolbar')
        self.canvas.update_idletasks()
        ImageGrab.grab().crop((x1,y1,x2,y2)).save("preview.png")
        self.updateCanvas()
项目:FBIThemePreviewer    作者:jurassicplayer    | 项目源码 | 文件源码
def saveConfig(self, config_type):
        print("Saving config: {}".format(config_type))
        if config_type == "config":
            filepath = "config"
            config_dict = self.app_config
            ordered = ['theme_folder', 'theme_title', 'theme_desc', 'theme_author', 'theme_version', 'meta_icon', 'screen_gap', 'anim_duration', 'overwrite', 'language']
        elif config_type == "textcolor":
            theme_folder = self.app_config['theme_folder']
            os.makedirs(theme_folder, exist_ok=True)
            filepath = os.path.join(theme_folder,'textcolor.cfg')
            config_dict={}
            for key in self.text_config:
                r,g,b,a = self.text_config[key]
                value = "{:02x}{:02x}{:02x}{:02x}".format(a,b,g,r).upper()
                config_dict.update({key: value})
            ordered = ['text', 'nand', 'sd', 'gamecard', 'dstitle', 'file', 'directory', 'enabled', 'disabled', 'installed', 'notinstalled', 'ticketinuse', 'ticketnotinuse']
            if os.path.isfile(filepath) and not self.app_config['overwrite'] in ['always', 'textcolor']:
                if not messagebox.askyesno("Warning", "A textcolor.cfg already exists, do you want to overwrite?", icon='warning'):
                    return
        with open(filepath, 'w') as f:
            for key in ordered:
                f.write("{}={}\n".format(key, config_dict[key]))
            f.truncate(f.tell() - len(os.linesep))
项目:FBIThemePreviewer    作者:jurassicplayer    | 项目源码 | 文件源码
def savePreview(self):
        print("Generating preview image...")
        x1 = self.winfo_rootx()+self.canvas.winfo_x()
        y1 = self.winfo_rooty()+self.canvas.winfo_y()
        x2 = x1+self.canvas.winfo_width()
        y2 = y1+self.canvas.winfo_height()
        coords = [x1, y1, x2, y2]
        if os.path.isfile("preview.png") and not self.app_config['overwrite'] in ['always', 'preview']:
            if not messagebox.askyesno("Warning", "Preview image already exists, do you want to overwrite?", icon='warning'):
                return
        self.attributes("-topmost", 1)
        self.attributes("-topmost", 0)
        self.canvas.delete('toolbar')
        self.canvas.update_idletasks()
        ImageGrab.grab().crop((x1,y1,x2,y2)).save("preview.png")
        #self.v['canvas_image'].save("preview.png")
        self.updateCanvas()
项目:jjal_downloader    作者:tucuprum    | 项目源码 | 文件源码
def DeleteItem(): # ??? ??? ??
    rawSelectedItems = tree.selection()
    pageIndexList = tree.get_children()
    [tree.selection_add(tree.get_children(r)) for r in rawSelectedItems if r in pageIndexList]
    [tree.selection_add(tree.parent(r)) for r in rawSelectedItems if r not in pageIndexList and tree.next(r) == '' and tree.prev(r) == '']
    selectedItems = tree.selection()
    numberOfSelection = len(selectedItems)
    if numberOfSelection == 0:
        return 0

    displayMessage = '? ' + str(len(selectedItems)) + ' ? ??? ?????????'
    if messagebox.askyesno('?? ??', displayMessage):
        for s in selectedItems:
            if not tree.exists(s):
                continue
            elif tree.parent(s) == '':
                tree.delete(s)
            elif tree.parent(s) in selectedItems:
                continue
            else:
                itspage = tree.parent(s)
                origVal = tree.set(itspage)
                tree.item(itspage, value=[origVal['#1'], origVal['#2'], int(origVal['#3'])-1, origVal['#4']])
                tree.delete(s)
        root.lift()
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def main():
    # ?????????,?????Tkinter????????Tk??.??????withdraw()??????
    tk = tkinter.Tk()
    tk.withdraw()  # ?????

    print(dir(mb))

    # ??,?????????,??ok,????????????.??????????????,??????????.
    # ??,???Cancel?,??????None
    mb.showinfo("Title", "Your message here")
    mb.showerror("An Error", "Oops!")
    mb.showwarning("Title", "This may not work...")
    mb.askyesno("Title", "Do you love me?")
    mb.askokcancel("Title", "Are you well?")
    mb.askquestion("Title", "How are you?")
    mb.askretrycancel("Title", "Go again?")
    mb.askyesnocancel("Title", "Are you well?")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def toggle_tabs_event(self, event):
        if self.askyesno(
              "Toggle tabs",
              "Turn tabs " + ("on", "off")[self.usetabs] +
              "?\nIndent width " +
              ("will be", "remains at")[self.usetabs] + " 8." +
              "\n Note: a tab is always 8 columns",
              parent=self.text):
            self.usetabs = not self.usetabs
            # Try to prevent inconsistent indentation.
            # User must change indent width manually after using tabs.
            self.indentwidth = 8
        return "break"

    # XXX this isn't bound to anything -- see tabwidth comments
##     def change_tabwidth_event(self, event):
##         new = self._asktabwidth()
##         if new != self.tabwidth:
##             self.tabwidth = new
##             self.set_indentation_params(0, guess=0)
##         return "break"
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def _do_reset():
    if not _needs_reset:
        messagebox.showinfo("Reset Settings",
                            "You are already using the default settings.")
        return

    if not messagebox.askyesno(
            "Reset Settings", "Are you sure you want to reset all settings?",
            parent=_dialog):
        return

    for section in _sections.values():
        for key, info in section._infos.items():
            if info.reset:
                section[key] = info.default
    messagebox.showinfo(
        "Reset Settings", "All settings were reset to defaults.",
        parent=_dialog)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def toggle_tabs_event(self, event):
        if self.askyesno(
              "Toggle tabs",
              "Turn tabs " + ("on", "off")[self.usetabs] +
              "?\nIndent width " +
              ("will be", "remains at")[self.usetabs] + " 8." +
              "\n Note: a tab is always 8 columns",
              parent=self.text):
            self.usetabs = not self.usetabs
            # Try to prevent inconsistent indentation.
            # User must change indent width manually after using tabs.
            self.indentwidth = 8
        return "break"

    # XXX this isn't bound to anything -- see tabwidth comments
##     def change_tabwidth_event(self, event):
##         new = self._asktabwidth()
##         if new != self.tabwidth:
##             self.tabwidth = new
##             self.set_indentation_params(0, guess=0)
##         return "break"
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(title, message)
项目:sc8pr    作者:dmaccarthy    | 项目源码 | 文件源码
def __init__(self, response=str, text="", title=None, accept=0, **options):
        if response is bool:
            self.dialog = [askyesno, askokcancel, askretrycancel][accept]
        else: self.dialog = {None:showinfo, str:askstring, int:askinteger, float:askfloat,
            0:askopenfilename, 1:asksaveasfilename, 2:askdirectory}[response]
        self.options = options.copy()
        if "initialdir" in options:
            self.options["initialdir"] = abspath(options["initialdir"])
        if type(response) is int:
            self.args = tuple()
            if title: self.options["title"] = title
        else:
            if title is None:
                title = "Info" if response is None else "Confirm" if response is bool else "Input"
            self.args = title, text
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def cancel(self, event=None, force=False):
        title = 'Warning'
        message = 'Are you sure you want\nto stop taking this test?'
        if force or messagebox.askyesno(title, message, master=self):
            if self.parent is not None:
                self.parent.focus_set()
            self.destroy()

################################################################################
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(title, message)
项目:ine5430-gomoku    作者:igoryamamoto    | 项目源码 | 文件源码
def isHuman(self, number):
        '''
            Function to choose wether the player is human or not.
        '''
        msg = 'Is Player {} a human?'.format(number)
        return messagebox.askyesno('Human or PC', msg)


    #|22th.|
项目:ine5430-gomoku    作者:igoryamamoto    | 项目源码 | 文件源码
def playAgain(self, number):
        msg = 'Player {} is the winner! \nDo you want to play again?'.format(number)
        return messagebox.askyesno('Play again', msg)


    #|20th.|
项目:PyLabyrinthe    作者:yoann-darche    | 项目源码 | 文件源码
def quitter(self, event=None):
        """
        Fonction appelé pour finir le programme, une confirmation est demandée avant
        """

        reponse = askyesno("Quitter le programme ?",
        "Voulez-vous réellement terminer ? \n cliquer <<oui>> pour finir")

        if reponse:
            self.fenetre.destroy()
项目:DnD    作者:the-nick-of-time    | 项目源码 | 文件源码
def load_file(self):
        base = iface.JSONInterface.OBJECTSPATH
        # filename = 'monster/' + h.clean(self.filequery.get().casefold()) + '.monster'
        filename = self.filename
        # if (os.path.isfile(base + filename)):
        if (os.path.isfile(filename)):
            interface = iface.JSONInterface(filename, isabsolute=True)
            self.data.update(interface.get('/'))
            # self.data.update({'average': self.av.get()})
            av = messagebox.askyesno(message='Take average HP?')
            self.data.update({'average': av})
            self.finish(fromfile=True)
        else:
            gui.ErrorMessage('That file does not exist. Check your spelling.')
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_yes_no(self, title, message):
        return messagebox.askyesno(title, message)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_yes_no(self, title, message):
        return messagebox.askyesno(title, message)
项目:rollingshutterpy    作者:alexd3rsan    | 项目源码 | 文件源码
def start(self) -> None:
        rs = self.rolling_shutter = RollingShutter(self.files,
                                                   self.tk_speed_val.get(),
                                                   self.file_output)

        lines_covered = rs.frame_count * self.tk_speed_val.get()

        if lines_covered < rs.height:
            m = ('The number of iterations ({}) is lower than the height'
                 ' of the resulting image ({}px).\n\nMissing spots ({} lines)'
                 ' will be filled with black.\n\n'
                 'Do you want to continue?')
            message = m.format(lines_covered,
                               rs.height,
                               rs.height-lines_covered)
            choice = askyesno('Proceed?', message)

            if not choice:
                return None

        self.disable_buttons()
        self.progress_bar.config(maximum=lines_covered)
        self.progress_bar.state(['!disabled'])

        t1 = Thread(target=rs.thread, args=(self,))
        t1.setDaemon(True)
        t1.start()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def DeleteCustomKeys(self):
        keySetName=self.customKeys.get()
        if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
                                     'to delete the key set %r ?' % (keySetName),
                                     parent=self):
            return
        #remove key set from config
        idleConf.userCfg['keys'].remove_section(keySetName)
        if keySetName in self.changedItems['keys']:
            del(self.changedItems['keys'][keySetName])
        #write changes
        idleConf.userCfg['keys'].Save()
        #reload user key set list
        itemList=idleConf.GetSectionList('user','keys')
        itemList.sort()
        if not itemList:
            self.radioKeysCustom.config(state=DISABLED)
            self.optMenuKeysCustom.SetMenu(itemList,'- no custom keys -')
        else:
            self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
        #revert to default key set
        self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys','default'))
        self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys','name'))
        #user can't back out of these changes, they must be applied now
        self.Apply()
        self.SetKeysType()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def DeleteCustomTheme(self):
        themeName=self.customTheme.get()
        if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
                                     'to delete the theme %r ?' % (themeName,),
                                     parent=self):
            return
        #remove theme from config
        idleConf.userCfg['highlight'].remove_section(themeName)
        if themeName in self.changedItems['highlight']:
            del(self.changedItems['highlight'][themeName])
        #write changes
        idleConf.userCfg['highlight'].Save()
        #reload user theme list
        itemList=idleConf.GetSectionList('user','highlight')
        itemList.sort()
        if not itemList:
            self.radioThemeCustom.config(state=DISABLED)
            self.optMenuThemeCustom.SetMenu(itemList,'- no custom themes -')
        else:
            self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
        #revert to default theme
        self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme','default'))
        self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme','name'))
        #user can't back out of these changes, they must be applied now
        self.Apply()
        self.SetThemeType()
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def close_window(self):
        yes = tkmessage.askyesno("Exit", "Do you really want to quit?")
        if yes:
            self.close()
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def remove_task(self, event):
        task = event.widget
        if msg.askyesno("Really Delete?", "Delete " + task.cget("text") + "?"):
            self.tasks.remove(event.widget)
            event.widget.destroy()
            self.recolour_tasks()
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def remove_task(self, event):
        task = event.widget
        if msg.askyesno("Really Delete?", "Delete " + task.cget("text") + "?"):
            self.tasks.remove(event.widget)

            delete_task_query = "DELETE FROM tasks WHERE task=?"
            delete_task_data = (task.cget("text"),)
            self.runQuery(delete_task_query, delete_task_data)

            event.widget.destroy()

            self.recolour_tasks()
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def confirm_delete(self, event=None):
        current_tab = self.notebook.tab(self.notebook.select(), "text")
        tree = self.tab_trees[current_tab]
        selected_item_id = tree.selection()
        selected_item = tree.item(selected_item_id)

        if msg.askyesno("Delete Item?", "Delete " + selected_item["values"][0] + "?", parent=self):
            task_name = selected_item["values"][0]
            task_time = selected_item["values"][2]
            task_date = " ".join([current_tab, task_time])
            self.master.delete_task(task_name, task_date)
            tree.delete(selected_item_id)
项目:chronophore    作者:mesbahamin    | 项目源码 | 文件源码
def _show_confirm_window(self, message, title):
        logger.debug('Window feedback: "{}"'.format(message))
        yes_pressed = messagebox.askyesno(
            message=message,
            title=title,
            icon='question',
            default='yes',
            parent=self.root,
        )
        # TODO(amin): Bind KP_Enter in all dialogs
        return yes_pressed
项目:tkinter-tutorial    作者:Akuli    | 项目源码 | 文件源码
def wanna_quit():
    if messagebox.askyesno("Quit", "Do you really want to quit?"):
        # the user clicked yes, let's close the window
        root.destroy()
项目:my_research    作者:MorvanZhou    | 项目源码 | 文件源码
def button_save_learning_result_clicked(self):
        global episode
        if os.path.exists('q_table_trained_{}_episode.pickle'.format(episode)) \
                and os.path.exists('q_index_trained_{}_episode.pickle'.format(episode)):
            answer = messagebox.askyesno(message="Hunter's experience has already saved,\nSave again?")
            if answer == True:
                hunter.q_table.to_pickle('q_table_trained_{}_episode.pickle'.format(episode))
                hunter.q_index.to_pickle('q_index_trained_{}_episode.pickle'.format(episode))
                messagebox.showinfo(message="Hunter's experience has been saved")
        else:
            hunter.q_table.to_pickle('q_table_trained_{}_episode.pickle'.format(episode))
            hunter.q_index.to_pickle('q_index_trained_{}_episode.pickle'.format(episode))
            messagebox.showinfo(message="Hunter's experience has been saved")
项目:jjal_downloader    作者:tucuprum    | 项目源码 | 文件源码
def AskYesNo(questionMsg):
    res = messagebox.askyesno(PROGRAM_TITLE,questionMsg)
    return res


#########################################################
################ MAIN GUI WINDOW BUTTONS ################
#########################################################
项目:ugm-kayu-nde    作者:mappuji    | 项目源码 | 文件源码
def pick_naturfreq(self):
        """ Pick auto detect frequency natural or manual
        """
        naturfreq, naturfreq_mag = self.get_natural_freq()
        prompt = "Natural Frequency found at " + str(naturfreq) + FREQ_UNIT_HZ + "\n" \
            + str(naturfreq_mag) + FREQ_MAG_UNIT + "\nDo you want to use this frequency?"
        if messagebox.askyesno("Autodetect Natural Frequency", \
             prompt):
            self.kayu_naturfreq = naturfreq
        else:
            messagebox.showinfo("Warning!", \
                "You need to input the desired natural frequency manually!")
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(title, message)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def play_game(game):
    result = ""
    while not result:
        print_game(game)
        choice = input("Cell[1-9 or q to quit]: ")
        if choice.lower()[0] == "q":
            save = mb.askyesno("Save game", "Save game before quitting?")
            if save:
                oxo_logic.save_game(game)
            quit_game()
        else:
            try:
                cell = int(choice) - 1
                if not (0 <= cell <= 8):  # check range
                    raise ValueError
            except ValueError:
                print("Choose a number between 1 and 9 or 'q' to quit ")
                continue

            try:
                result = oxo_logic.user_move(game, cell)
            except ValueError:
                mb.showerror("Invalid cell", "Choose an empty cell")
                continue
            if not result:
                result = oxo_logic.computer_move(game)
            if not result:
                continue
            elif result == "D":
                print_game(game)
                mb.showinfo("Result", "It's a draw")
            else:
                print_game(game)
                mb.showinfo("Result", "Winner is {}".format(result))
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def ev_exit():
    global status
    if status["text"] == "Playing game":
        if mb.askyesno("Quitting", "Do you want to save the game before quitting?"):
            ev_save()
    top.quit()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def DeleteCustomKeys(self):
        keySetName=self.customKeys.get()
        delmsg = 'Are you sure you wish to delete the key set %r ?'
        if not tkMessageBox.askyesno(
                'Delete Key Set',  delmsg % keySetName, parent=self):
            return
        #remove key set from config
        idleConf.userCfg['keys'].remove_section(keySetName)
        if keySetName in self.changedItems['keys']:
            del(self.changedItems['keys'][keySetName])
        #write changes
        idleConf.userCfg['keys'].Save()
        #reload user key set list
        itemList = idleConf.GetSectionList('user', 'keys')
        itemList.sort()
        if not itemList:
            self.radioKeysCustom.config(state=DISABLED)
            self.optMenuKeysCustom.SetMenu(itemList, '- no custom keys -')
        else:
            self.optMenuKeysCustom.SetMenu(itemList, itemList[0])
        #revert to default key set
        self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys', 'default'))
        self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys', 'name'))
        #user can't back out of these changes, they must be applied now
        self.Apply()
        self.SetKeysType()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def DeleteCustomTheme(self):
        themeName = self.customTheme.get()
        delmsg = 'Are you sure you wish to delete the theme %r ?'
        if not tkMessageBox.askyesno(
                'Delete Theme',  delmsg % themeName, parent=self):
            return
        #remove theme from config
        idleConf.userCfg['highlight'].remove_section(themeName)
        if themeName in self.changedItems['highlight']:
            del(self.changedItems['highlight'][themeName])
        #write changes
        idleConf.userCfg['highlight'].Save()
        #reload user theme list
        itemList = idleConf.GetSectionList('user', 'highlight')
        itemList.sort()
        if not itemList:
            self.radioThemeCustom.config(state=DISABLED)
            self.optMenuThemeCustom.SetMenu(itemList, '- no custom themes -')
        else:
            self.optMenuThemeCustom.SetMenu(itemList, itemList[0])
        #revert to default theme
        self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme', 'default'))
        self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme', 'name'))
        #user can't back out of these changes, they must be applied now
        self.Apply()
        self.SetThemeType()
项目:network-pj-chatroom    作者:KevinWang15    | 项目源码 | 文件源码
def try_open_user_id(self, id, name, username):

        for i in range(0, len(self.pack_objs)):
            frame = self.pack_objs[i]
            if frame.item['id'] == id and frame.item['type'] == 0:
                self.on_frame_click(self.my_event(frame))
                return
        result = messagebox.askyesno("?????", name + "????????????????")
        if result:
            self.sc.send(MessageType.add_friend, username)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def DeleteCustomKeys(self):
        keySetName=self.customKeys.get()
        delmsg = 'Are you sure you wish to delete the key set %r ?'
        if not tkMessageBox.askyesno(
                'Delete Key Set',  delmsg % keySetName, parent=self):
            return
        #remove key set from config
        idleConf.userCfg['keys'].remove_section(keySetName)
        if keySetName in self.changedItems['keys']:
            del(self.changedItems['keys'][keySetName])
        #write changes
        idleConf.userCfg['keys'].Save()
        #reload user key set list
        itemList = idleConf.GetSectionList('user', 'keys')
        itemList.sort()
        if not itemList:
            self.radioKeysCustom.config(state=DISABLED)
            self.optMenuKeysCustom.SetMenu(itemList, '- no custom keys -')
        else:
            self.optMenuKeysCustom.SetMenu(itemList, itemList[0])
        #revert to default key set
        self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys', 'default'))
        self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys', 'name'))
        #user can't back out of these changes, they must be applied now
        self.Apply()
        self.SetKeysType()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def DeleteCustomTheme(self):
        themeName = self.customTheme.get()
        delmsg = 'Are you sure you wish to delete the theme %r ?'
        if not tkMessageBox.askyesno(
                'Delete Theme',  delmsg % themeName, parent=self):
            return
        #remove theme from config
        idleConf.userCfg['highlight'].remove_section(themeName)
        if themeName in self.changedItems['highlight']:
            del(self.changedItems['highlight'][themeName])
        #write changes
        idleConf.userCfg['highlight'].Save()
        #reload user theme list
        itemList = idleConf.GetSectionList('user', 'highlight')
        itemList.sort()
        if not itemList:
            self.radioThemeCustom.config(state=DISABLED)
            self.optMenuThemeCustom.SetMenu(itemList, '- no custom themes -')
        else:
            self.optMenuThemeCustom.SetMenu(itemList, itemList[0])
        #revert to default theme
        self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme', 'default'))
        self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme', 'name'))
        #user can't back out of these changes, they must be applied now
        self.Apply()
        self.SetThemeType()
项目:sorter    作者:giantas    | 项目源码 | 文件源码
def _show_exit_dialog(self):
        answer = messagebox.askyesno(title='Leave',
                                     message='Do you really want to quit?')
        if answer:
            self.logger.info('Exiting...')
            self.destroy()
项目:qcri    作者:douville    | 项目源码 | 文件源码
def _on_upload_btn_clicked(self):
        selected_rows = self.runresultsview.get_selection()
        if len(selected_rows) == 0:
            messagebox.showerror('Error', 'No tests selected.')
            return
        selected_qc_dir = self.qcdir_tree.selection()
        if len(selected_qc_dir) != 1:
            messagebox.showerror('Error', 'Destination not selected.')
            return
        qcdir = self.dir_dict[selected_qc_dir[0]]
        if not qcdir:
            messagebox.showerror('Error', 'path is blank')
            return
        assert qcdir.startswith('Root\\'), qcdir
        # remove "Root\"
        qcdir = qcdir[5:]

        results = self.results.copy()
        results['tests'] = [self.runresultsview.tests[row]
                            for row in selected_rows]

        result = messagebox.askyesno(
            'Confirm',
            ('Are you sure you want to upload to the following '
             'location?\n\n{}'.format(qcdir)))
        if not result:
            return

        work_in_background(
            self,
            lambda: importer.import_results(
                self.qcc,
                qcdir,
                results,
                self.attach_report.get()),
            lambda: messagebox.showinfo('Success', 'Import complete.'))
项目:CTPrivAPI    作者:doubleelforbes    | 项目源码 | 文件源码
def withdraw():
    global privapi
    currency = simpledialog.askstring("Currency Required", "Please provide the currency to withdraw(eg. 'DOT' or '2')")
    if currency == "" or not currency:
        debugout("ERROR! - Cannot withdraw without a currency.")
    else:
        currency = currency.upper()
        address = simpledialog.askstring("Withdrawal Address Required", "Please provide the address to withdraw the " +
                                         currency + " to")
        if address == "" or not address:
            debugout("ERROR! - Withdrawal Address not provided.")
        else:
            amount = simpledialog.askfloat("Amount Required", "Please provide an amount of " + currency +
                                           " to send to: " + address)
            if not amount:
                debugout("ERROR! - Cannot Withdraw without an amount.")
            else:
                amount = "{0:.8f}".format(amount)
                payidreq = messagebox.askyesno("PaymentID for CryptoNote currencies",
                                               "Would you like to provide a Payment ID?\r\n" +
                                               "Only required for CryptoNote.")
                if payidreq:
                    payid = simpledialog.askstring("PaymentID Entry",
                                                   "You have requested Payment ID Entry please provide it.")
                    if payid == "" or not payid:
                        debugout("ERROR! - User requested a Payment ID but failed to provide it.")
                    else:
                        debugout(amount + " " + currency + " withdrawal requested to: " + address + " with PaymentID: "
                                 + payid)
                        response = privapi.submitwithdraw(currency, address, amount, payid)
                        if isinstance(response, str):
                            debugout("Withdrawal submitted under ID: " + response)
                        else:
                            debugout(str(response) + " is a " + str(type(response)))
                        gettransactions()
                else:
                    debugout(amount + " " + currency + " withdrawal requested to: " + address)
                    response = privapi.submitwithdraw(currency, address, amount)
                    # API returns an int ID for the transaction
                    debugout("Withdrawal submitted under ID: " + str(response))
                    gettransactions()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def runcode(self, code):
        "Override base class method"
        if self.tkconsole.executing:
            self.interp.restart_subprocess()
        self.checklinecache()
        if self.save_warnings_filters is not None:
            warnings.filters[:] = self.save_warnings_filters
            self.save_warnings_filters = None
        debugger = self.debugger
        try:
            self.tkconsole.beginexecuting()
            if not debugger and self.rpcclt is not None:
                self.active_seq = self.rpcclt.asyncqueue("exec", "runcode",
                                                        (code,), {})
            elif debugger:
                debugger.run(code, self.locals)
            else:
                exec(code, self.locals)
        except SystemExit:
            if not self.tkconsole.closing:
                if tkMessageBox.askyesno(
                    "Exit?",
                    "Do you want to exit altogether?",
                    default="yes",
                    master=self.tkconsole.text):
                    raise
                else:
                    self.showtraceback()
            else:
                raise
        except:
            if use_subprocess:
                print("IDLE internal error in runcode()",
                      file=self.tkconsole.stderr)
                self.showtraceback()
                self.tkconsole.endexecuting()
            else:
                if self.tkconsole.canceled:
                    self.tkconsole.canceled = False
                    print("KeyboardInterrupt", file=self.tkconsole.stderr)
                else:
                    self.showtraceback()
        finally:
            if not use_subprocess:
                try:
                    self.tkconsole.endexecuting()
                except AttributeError:  # shell may have closed
                    pass
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def main():
    top = tix.Tk()

    nb = tix.NoteBook(top, width=300, height=200)
    nb.pack(expand=True, fill="both")

    nb.add("page1", label="text")
    f1 = tix.Frame(nb.subwidget("page1"))
    st = tix.ScrolledText(f1)
    st.subwidget("text").insert("1.0", "Here is where the text goes...")
    st.pack(expand=True)
    f1.pack()

    nb.add("page2", label="Message Boxes")
    f2 = tix.Frame(nb.subwidget("page2"))
    # ??????expand,fill?anchor???????????????????????
    tix.Button(f2, text="error", bg="lightblue", command=lambda t="error", m="This is bad!": mb.showerror(t, m)).pack(fill="x",
                                                                                                                      expand=True)
    tix.Button(f2, text="info", bg="pink", command=lambda t="info", m="Information": mb.showinfo(t, m)).pack(fill="x", expand=True)
    tix.Button(f2, text="warning", bg="yellow", command=lambda t="warning", m="Don't do it!": mb.showwarning(t, m)).pack(fill="x",
                                                                                                                         expand=True)
    tix.Button(f2, text="question", bg="green", command=lambda t="question", m="Will I?": mb.askquestion(t, m)).pack(fill="x",
                                                                                                                     expand=True)
    tix.Button(f2, text="yes - no", bg="lightgrey", command=lambda t="yes - no", m="Are you sure?": mb.askyesno(t, m)).pack(
            fill="x", expand=True)
    tix.Button(f2, text="yes - no - cancel", bg="black", fg="white",
               command=lambda t="yes - not - cancel", m="Last chance...": mb.askyesnocancel(t, m)).pack(fill="x", expand=True)

    f2.pack(side="top", fill="x")
    top.mainloop()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def runcode(self, code):
        "Override base class method"
        if self.tkconsole.executing:
            self.interp.restart_subprocess()
        self.checklinecache()
        if self.save_warnings_filters is not None:
            warnings.filters[:] = self.save_warnings_filters
            self.save_warnings_filters = None
        debugger = self.debugger
        try:
            self.tkconsole.beginexecuting()
            if not debugger and self.rpcclt is not None:
                self.active_seq = self.rpcclt.asyncqueue("exec", "runcode",
                                                        (code,), {})
            elif debugger:
                debugger.run(code, self.locals)
            else:
                exec(code, self.locals)
        except SystemExit:
            if not self.tkconsole.closing:
                if tkMessageBox.askyesno(
                    "Exit?",
                    "Do you want to exit altogether?",
                    default="yes",
                    parent=self.tkconsole.text):
                    raise
                else:
                    self.showtraceback()
            else:
                raise
        except:
            if use_subprocess:
                print("IDLE internal error in runcode()",
                      file=self.tkconsole.stderr)
                self.showtraceback()
                self.tkconsole.endexecuting()
            else:
                if self.tkconsole.canceled:
                    self.tkconsole.canceled = False
                    print("KeyboardInterrupt", file=self.tkconsole.stderr)
                else:
                    self.showtraceback()
        finally:
            if not use_subprocess:
                try:
                    self.tkconsole.endexecuting()
                except AttributeError:  # shell may have closed
                    pass
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def runcode(self, code):
        "Override base class method"
        if self.tkconsole.executing:
            self.interp.restart_subprocess()
        self.checklinecache()
        if self.save_warnings_filters is not None:
            warnings.filters[:] = self.save_warnings_filters
            self.save_warnings_filters = None
        debugger = self.debugger
        try:
            self.tkconsole.beginexecuting()
            if not debugger and self.rpcclt is not None:
                self.active_seq = self.rpcclt.asyncqueue("exec", "runcode",
                                                        (code,), {})
            elif debugger:
                debugger.run(code, self.locals)
            else:
                exec(code, self.locals)
        except SystemExit:
            if not self.tkconsole.closing:
                if tkMessageBox.askyesno(
                    "Exit?",
                    "Do you want to exit altogether?",
                    default="yes",
                    master=self.tkconsole.text):
                    raise
                else:
                    self.showtraceback()
            else:
                raise
        except:
            if use_subprocess:
                print("IDLE internal error in runcode()",
                      file=self.tkconsole.stderr)
                self.showtraceback()
                self.tkconsole.endexecuting()
            else:
                if self.tkconsole.canceled:
                    self.tkconsole.canceled = False
                    print("KeyboardInterrupt", file=self.tkconsole.stderr)
                else:
                    self.showtraceback()
        finally:
            if not use_subprocess:
                try:
                    self.tkconsole.endexecuting()
                except AttributeError:  # shell may have closed
                    pass