當前位置: 首頁>>代碼示例>>Python>>正文


Python messagebox.askokcancel方法代碼示例

本文整理匯總了Python中tkinter.messagebox.askokcancel方法的典型用法代碼示例。如果您正苦於以下問題:Python messagebox.askokcancel方法的具體用法?Python messagebox.askokcancel怎麽用?Python messagebox.askokcancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tkinter.messagebox的用法示例。


在下文中一共展示了messagebox.askokcancel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: confirm_close

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def confirm_close(self):
        """ Pop a message box to get confirmation that an unsaved project should be closed

        Returns
        -------
        bool: ``True`` if user confirms close, ``False`` if user cancels close
        """
        if not self._modified:
            logger.debug("Project is not modified")
            return True
        confirmtxt = "You have unsaved changes.\n\nAre you sure you want to close the project?"
        if messagebox.askokcancel("Close", confirmtxt, default="cancel", icon="warning"):
            logger.debug("Close Cancelled")
            return True
        logger.debug("Close confirmed")
        return False 
開發者ID:deepfakes,項目名稱:faceswap,代碼行數:18,代碼來源:project.py

示例2: _confirm_close_on_running_task

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def _confirm_close_on_running_task(self):
        """ Pop a confirmation box to close the GUI if a task is running

        Returns
        -------
        bool: ``True`` if user confirms close, ``False`` if user cancels close
        """
        if not self._config.tk_vars["runningtask"].get():
            logger.debug("No tasks currently running")
            return True

        confirmtxt = "Processes are still running.\n\nAre you sure you want to exit?"
        if not messagebox.askokcancel("Close", confirmtxt, default="cancel", icon="warning"):
            logger.debug("Close Cancelled")
            return True
        logger.debug("Close confirmed")
        return False 
開發者ID:deepfakes,項目名稱:faceswap,代碼行數:19,代碼來源:gui.py

示例3: move_to_trash

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def move_to_trash(self):
        assert self.supports_trash()

        selection = self.get_selection_info(True)
        if not selection:
            return

        trash = "Recycle Bin" if running_on_windows() else "Trash"
        if not messagebox.askokcancel(
            "Moving to %s" % trash,
            "I'll try to move %s to %s,\n" % (selection["description"], trash)
            + "but my method is not always reliable —\n"
            + "in some cases the files will be deleted\n"
            + "without the possibility to restore.",
            icon="info",
        ):
            return

        self.perform_move_to_trash(
            selection["paths"], _("Moving %s to %s") % (selection["description"], trash)
        )
        self.refresh_tree() 
開發者ID:thonny,項目名稱:thonny,代碼行數:24,代碼來源:base_file_browser.py

示例4: okcancel

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def okcancel(subject, text):
        return messagebox.askokcancel(subject, text) 
開發者ID:pabloibiza,項目名稱:WiCC,代碼行數:4,代碼來源:wicc_view_popup.py

示例5: save_file_cmd

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def save_file_cmd(puzzle_frame, parent):
    """
    Input's save to file button click handler

    puzzle_frame : The puzzle frame which it's puzzle will be saved to file
    parent : The parent window of the puzzle_frame
             This is used for showing the 'save as file' dialog so it can be showed on top of the window.
    """
    # Check if puzzle frame has a valid input, and if not, ask the user if he's sure he wants to save the puzzle
    lst = is_input_puzzle_valid(puzzle_frame)
    if not lst:
        if not messagebox.askokcancel("Input not valid",
                                      "Input puzzle is not valid, are you sure to save it as a file?",
                                      parent=parent):
            return

    # Open the 'save as file' dialog
    file_name = filedialog.asksaveasfilename(title="Choose a file to save puzzle", parent=parent)
    # Check if user has selected a file
    if not file_name:
        return

    # Generate file's content
    len_sqrt = int(math.sqrt(len(lst)))
    file_lines = []
    for i in range(0, len(lst), 3):
        line_nums = []
        for j in range(0, len_sqrt):
            line_nums.append(str(lst[i + j]))
        file_lines.append(' '.join(line_nums))

    try:
        with open(file_name, 'w') as file:
            file.write('\n'.join(file_lines))
    except:
        messagebox.showerror("Error saving to file",
                             "Some problem happened while saving puzzle to the file.",
                             parent=parent)


# Save to file button widgget 
開發者ID:mahdavipanah,項目名稱:pynpuzzle,代碼行數:43,代碼來源:pynpuzzle.py

示例6: ask_save_dialog

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def ask_save_dialog(self):
        msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"
        confirm = tkMessageBox.askokcancel(title="Save Before Run or Check",
                                           message=msg,
                                           default=tkMessageBox.OK,
                                           parent=self.editwin.text)
        return confirm 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:ScriptBinding.py

示例7: close

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def close(self):
        "Extend EditorWindow.close()"
        if self.executing:
            response = tkMessageBox.askokcancel(
                "Kill?",
                "Your program is still running!\n Do you want to kill it?",
                default="ok",
                parent=self.text)
            if response is False:
                return "cancel"
        self.stop_readline()
        self.canceled = True
        self.closing = True
        return EditorWindow.close(self) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:16,代碼來源:PyShell.py

示例8: change_mode

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def change_mode(self):
        if (self.nand_mode):
            self.nand_frame.pack_forget()
            self.checks_frame.pack(padx=10, anchor=W)
            self.nand_mode = False

        else:
            if askokcancel('Warning', ('You are about to enter NAND mode. Do it only if you know '
                'what you are doing. Proceed?'), icon=WARNING):
                self.checks_frame.pack_forget()
                self.nand_frame.pack(padx=10, pady=(0, 10), fill=X)
                self.nand_mode = True


    ################################################################################################ 
開發者ID:mondul,項目名稱:HiyaCFW-Helper,代碼行數:17,代碼來源:HiyaCFW_Helper.py

示例9: exit_app

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def exit_app(self):
        self.now_playing = False
        if messagebox.askokcancel("Quit", "Really quit?"):
            self.root.destroy() 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代碼行數:6,代碼來源:3.12.py

示例10: close_window

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def close_window(self):
        if messagebox.askokcancel("Quit", "Do you really want to quit?"):
            self.root.destroy() 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代碼行數:5,代碼來源:6.09.py

示例11: on_closing

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def on_closing(self, root):
        if messagebox.askokcancel("Quit", "Do you want to quit?"):
            self.presenter.stop_server()
            root.destroy() 
開發者ID:IBM,項目名稱:clai,代碼行數:6,代碼來源:clai_emulator.py

示例12: on_closing

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def on_closing():
    from tkinter import messagebox
    if messagebox.askokcancel("Quit", "Do you want to quit?"):
        window.destroy() 
開發者ID:Spidy20,項目名稱:Attendace_management_system,代碼行數:6,代碼來源:AMS_Run.py

示例13: Closing

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def Closing(app):
    try:
        if messagebox.askokcancel("Quit", "Do you want to quit?"):
            StopAll(None)
            app.destroy()
    except Exception:
        sys.exit(-1) 
開發者ID:li-zheng-hao,項目名稱:yysScript,代碼行數:9,代碼來源:Window.py

示例14: ask_ok_cancel

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message) 
開發者ID:wynand1004,項目名稱:SPGL,代碼行數:4,代碼來源:spgl.py

示例15: pickOkOrCancel

# 需要導入模塊: from tkinter import messagebox [as 別名]
# 或者: from tkinter.messagebox import askokcancel [as 別名]
def pickOkOrCancel(windowTitle,windowText):
    return messagebox.askokcancel(windowTitle,windowText) 
開發者ID:Sh3llcod3,項目名稱:Airscript-ng,代碼行數:4,代碼來源:gui_elements.py


注:本文中的tkinter.messagebox.askokcancel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。