python类askyesno()的实例源码

wanna-quit.py 文件源码 项目:tkinter-tutorial 作者: Akuli 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def wanna_quit():
    if messagebox.askyesno("Quit", "Do you really want to quit?"):
        # the user clicked yes, let's close the window
        root.destroy()
run this one.py 文件源码 项目:my_research 作者: MorvanZhou 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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")
main.py 文件源码 项目:jjal_downloader 作者: tucuprum 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def AskYesNo(questionMsg):
    res = messagebox.askyesno(PROGRAM_TITLE,questionMsg)
    return res


#########################################################
################ MAIN GUI WINDOW BUTTONS ################
#########################################################
main.py 文件源码 项目:ugm-kayu-nde 作者: mappuji 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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!")
appjar.py 文件源码 项目:BeachedWhale 作者: southpaw5271 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(title, message)
oxo_dialog_ui.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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))
oxo_gui_complete.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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()
configDialog.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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()
configDialog.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
contacts_form.py 文件源码 项目:network-pj-chatroom 作者: KevinWang15 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
configDialog.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
configDialog.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
tkgui.py 文件源码 项目:sorter 作者: giantas 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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()
gui.py 文件源码 项目:qcri 作者: douville 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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.'))
main.py 文件源码 项目:CTPrivAPI 作者: doubleelforbes 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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()
PyShell.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
learn_notebook.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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()
PyShell.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
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
PyShell.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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


问题


面经


文章

微信
公众号

扫码关注公众号