Python tkMessageBox 模块,askokcancel() 实例源码

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

项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def detect_bemoss(self):
        cwd = os.getcwd()
        ui_path = cwd.replace('bemoss_gui','bemoss_web_ui')
        cassandra_path = cwd.replace('bemoss_gui','cassandra')
        env_path = cwd.replace('bemoss_gui','bemoss_os/env/bin')
        bemoss_is_installed = os.path.isdir(ui_path) and os.path.isdir(cassandra_path) and os.path.isdir(env_path)

        if bemoss_is_installed is False:
            tmp = tkMessageBox.askokcancel(title='Please install BEMOSS at first',
                                           message='You computer does not have BEMOSS installed, do you want to install BEMOSS right now?',
                                           parent=root)
            if tmp is True:
                self.install_bemoss()
                return
            else:
                return False
        else:
            return True
项目:chessboard_Chinese-chess    作者:JiNianLuo    | 项目源码 | 文件源码
def file_window(self):
        file_name = askopenfilename(parent=self.root, title='????', \
                                    filetypes=[('FEN Records', '*.fen'), ('Text Files', '*.txt'), ('All Files', '*.*')],
                                    initialdir='Resourses/', \
                                    initialfile='example.fen')
        # self.file = open(file_name, 'r')
        # self.play()
        # '''
        try:
            self.file = open(file_name, 'r')
            self.play()
        except IOError:
            if askokcancel('?????', '???????'):
                self.file_window()
            else:
                self.root.destroy()
                # '''
项目:chessboard_Chinese-chess    作者:JiNianLuo    | 项目源码 | 文件源码
def file_window(self):
        file_name = askopenfilename(parent=self.root, title='????', \
                                    filetypes=[('FEN Records', '*.fen'), ('Text Files', '*.txt'), ('All Files', '*.*')],
                                    initialdir='Resourses/', \
                                    initialfile='example.fen')
        # self.file = open(file_name, 'r')
        # self.play()
        # '''
        try:
            self.file = open(file_name, 'r')
            self.play()
        except IOError:
            if askokcancel('?????', '???????'):
                self.file_window()
            else:
                self.root.destroy()
                # '''
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def quit(self):
        ans = askokcancel('Verify exit', "Really quit?")
        if ans: Frame.quit(self)
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def MsgBox(title, text, style):
    box = [
        msg.showinfo,       msg.showwarning,    msg.showerror,
        msg.askquestion,    msg.askyesno,       msg.askokcancel,        msg.askretrycancel,
    ];
    tk.Tk().withdraw(); #Hide Main Window.
    if style in range(7):
        return box[style](title, text)
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def on_closing():
    if msg.askokcancel("Warning", "Do you want to quit?"):
        background.destroy()
        rospy.signal_shutdown("")
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def MsgBox(title, text, style):
    box = [
        msg.showinfo,       msg.showwarning,    msg.showerror,
        msg.askquestion,    msg.askyesno,       msg.askokcancel,        msg.askretrycancel,
    ];
    tk.Tk().withdraw(); #Hide Main Window.
    if style in range(7):
        return box[style](title, text)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_ok_cancel(self, title, message):
        return messagebox.askokcancel(title, message)
项目:heartbreaker    作者:lokori    | 项目源码 | 文件源码
def ask_quit():
    global proc
    if tkMessageBox.askokcancel("Quit", "You want to leave me? *sniff*"):
        try:
            proc.terminate()
        except:
            pass
        sys.exit()
        #root.destroy()

#-----------------------------------------
项目:K40-Whisperer    作者:jkramarz    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result


################################################################################
#                          Startup Application                                 #
################################################################################
项目:Circadia    作者:hooyah    | 项目源码 | 文件源码
def menu_newTheme(self):
        """ callback for new_theme menu item """

        sure = tkMessageBox.askokcancel(title='New Theme', message='sure?')
        if sure:
            self.newTheme()
项目:Circadia    作者:hooyah    | 项目源码 | 文件源码
def menu_loadTheme(self):
        """ callback for load_theme menu item """

        newTheme = tkFileDialog.askopenfilename(initialdir=self.themeRootPath, filetypes=[('Theme', '*.json')], title='Open Theme')
        if newTheme and not newTheme.startswith(self.themeRootPath):
            tkMessageBox.showerror(message='Theme not in root folder: '+self.themeRootPath)
            print newTheme, self.themeRootPath
            return

        if not newTheme or (self.theme and not tkMessageBox.askokcancel(title='Loading theme', message='current theme will be lost. continue?')):
            return

        pathname, filename = os.path.split(newTheme)
        basename, themename = os.path.split(pathname)
        self.loadTheme(themename)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
项目:MACE-AL    作者:julmaxi    | 项目源码 | 文件源码
def request_next_annotation(self, *arg):
        value = self.user_tag_value.get()

        if value == "":
            self.root.bell()
            return

        if value not in self.annotation_state.parser_predictions.value_set:
            res = tkMessageBox.askokcancel(
                "New Tag",
                "You are about to introduce the new tag '{}'. Proceed?".format(value))
            if res is False:
                return
            else:
                self.combobox.configure(values=sorted(
                    list(self.annotation_state.parser_predictions.value_set) + [value]))

        self.annotation_state.process_annotation(self.current_request, value)

        comment_value = self.comment_box.get("1.0", END).strip()
        if len(comment_value) > 0:
            self.write_comment(self.current_request.token,
                               comment_value, value)
            self.comment_box.delete("1.0", END)

        if self.autosave:
            self.save_state()

        self.get_next_request()
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:f-engrave    作者:stephenhouser    | 项目源码 | 文件源码
def message_ask_ok_cancel(title, mess):
    if VERSION == 3:
        result=tkinter.messagebox.askokcancel(title, mess)
    else:
        result=tkMessageBox.askokcancel(title, mess)
    return result

############################################################################
# routine takes an x and a y coords and does a coordinate transformation   #
# to a new coordinate system at angle from the initial coordinate system   #
# Returns new x,y tuple                                                    #
############################################################################
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ResetToDefaultConfigCmd(self):
        q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame)
        if q:
            status = pijuice.config.SetDefaultConfiguration()
            if status['error'] != 'NO_ERROR':
                tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def PiJuiceGuiOnclosing():
    #if tkMessageBox.askokcancel("Quit", "Do you want to quit?"):
    if not os.path.exists(os.path.dirname(PiJuiceConfigDataPath)):
        print os.path.dirname(PiJuiceConfigDataPath)
        os.makedirs(os.path.dirname(PiJuiceConfigDataPath)) 
    #try:
    with open(PiJuiceConfigDataPath , 'w+') as outputConfig:
        json.dump(pijuiceConfigData, outputConfig, indent=2)
    #except:
        #print 
    root.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ResetToDefaultConfigCmd(self):
        q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame)
        if q:
            status = pijuice.config.SetDefaultConfiguration()
            if status['error'] != 'NO_ERROR':
                tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def PiJuiceGuiOnclosing():
    #if tkMessageBox.askokcancel("Quit", "Do you want to quit?"):
    if not os.path.exists(os.path.dirname(PiJuiceConfigDataPath)):
        print os.path.dirname(PiJuiceConfigDataPath)
        os.makedirs(os.path.dirname(PiJuiceConfigDataPath)) 
    #try:
    with open(PiJuiceConfigDataPath , 'w+') as outputConfig:
        json.dump(pijuiceConfigData, outputConfig, indent=2)
    #except:
        #print 
    root.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ResetToDefaultConfigCmd(self):
        q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame)
        if q:
            status = pijuice.config.SetDefaultConfiguration()
            if status['error'] != 'NO_ERROR':
                tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ResetToDefaultConfigCmd(self):
        q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame)
        if q:
            status = pijuice.config.SetDefaultConfiguration()
            if status['error'] != 'NO_ERROR':
                tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def PiJuiceGuiOnclosing():
    #if tkMessageBox.askokcancel("Quit", "Do you want to quit?"):
    if not os.path.exists(os.path.dirname(PiJuiceConfigDataPath)):
        print os.path.dirname(PiJuiceConfigDataPath)
        os.makedirs(os.path.dirname(PiJuiceConfigDataPath)) 
    #try:
    with open(PiJuiceConfigDataPath , 'w+') as outputConfig:
        json.dump(pijuiceConfigData, outputConfig, indent=2)
    #except:
        #print 
    root.destroy()
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def _ResetToDefaultConfigCmd(self):
        q = tkMessageBox.askokcancel('Reset Configuration','Warning! This action will reset PiJuice HAT configuration to default settings.', parent=self.frame)
        if q:
            status = pijuice.config.SetDefaultConfiguration()
            if status['error'] != 'NO_ERROR':
                tkMessageBox.showerror('Reset to default configuration', status['error'], parent=self.frame)
项目:PiJuice    作者:PiSupply    | 项目源码 | 文件源码
def PiJuiceGuiOnclosing():
    #if tkMessageBox.askokcancel("Quit", "Do you want to quit?"):
    if not os.path.exists(os.path.dirname(PiJuiceConfigDataPath)):
        print os.path.dirname(PiJuiceConfigDataPath)
        os.makedirs(os.path.dirname(PiJuiceConfigDataPath)) 
    #try:
    with open(PiJuiceConfigDataPath , 'w+') as outputConfig:
        json.dump(pijuiceConfigData, outputConfig, indent=2)
    #except:
        #print 
    root.destroy()
项目:GenChannelApks    作者:TigerBetree    | 项目源码 | 文件源码
def start(self):
        print('--------------Start Gen Apk-------------------')

        # ?????
        # if os.path.exists(apks_dir):
        #     shutil.rmtree(apks_dir)

        # ??apk?temp??
        cmd_extract = r'java -jar %s\apktool\apktool_2.0.2.jar d -f -s %s\%s -o %s\temp' % (self.setupdir, self.setupdir, self.filename, self.setupdir)
        os.system(cmd_extract)

        # ??AndroidManifest.xml
        if os.path.exists('%s\AndroidManifest.xml' % self.setupdir):
            os.remove('%s\AndroidManifest.xml' % self.setupdir)
        manifest_path = r'%s\temp\AndroidManifest.xml' % self.setupdir
        shutil.copyfile(manifest_path, '%s\AndroidManifest.xml' % self.setupdir)

        # ?????
        for channel in self.channellist:
            print('[Gen Apk] channel : %s' % channel)
            self.modify_channel(channel)

        # ??????
        if os.path.exists('%s\temp' % self.setupdir):
            shutil.rmtree('%s\temp' % self.setupdir)
        if os.path.exists('%s\AndroidManifest.xml' % self.setupdir):
            os.remove('%s\AndroidManifest.xml' % self.setupdir)

        flag = tkMessageBox.askokcancel("??", "????!")
        if flag:
            os.system("explorer.exe %s" % self.apkdir)
        print('--------------Done-------------------')


    # ?????
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def okBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askokcancel(title, message)
项目:FFT-spectrum-analyzer    作者:ariquezada    | 项目源码 | 文件源码
def on_closing(self):
        if (self.f_saved==False):
            if tkMessageBox.askokcancel("Quit", "Sampled data not saved. Do you wanto to quit?"):
                root.destroy()
        else:
            root.destroy()
项目:FFT-spectrum-analyzer    作者:ariquezada    | 项目源码 | 文件源码
def on_closing(self):
        if (self.f_saved==False):
            if tkMessageBox.askokcancel("Quit", "Sampled data not saved. Do you wanto to quit?"):
                root.destroy()
        else:
            root.destroy()
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def del_dat(self):
        cnt = tkMessageBox.askokcancel(title='Reconfirmation',
                                       message='Are you sure to delete the data?',
                                       parent=self.frame3)
        if cnt is True:
            cas_dir = self.bemoss_dir.replace('bemoss_os/', 'cassandra/')
            path = cas_dir + 'data'
            shutil.rmtree(path)
        else:
            return
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def del_cas(self):
        cnt = tkMessageBox.askokcancel(title='Reconfirmation',
                                       message='Are you sure to delete the file?',
                                       parent=self.frame3)
        if cnt is True:
            path = self.bemoss_dir + '/cassandra_settings.txt'
            os.remove(path)
        else:
            return
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def close(self):
        "Extend EditorWindow.close()"
        if self.executing:
            response = tkMessageBox.askokcancel(
                "Kill?",
                "The 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
        # Wait for poll_subprocess() rescheduling to stop
        self.text.after(2 * self.pollinterval, self.close2)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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,
                                           master=self.editwin.text)
        return confirm
项目:pylemanager    作者:lucasmenendez    | 项目源码 | 文件源码
def execAction(self):
        if not self.action is None:
            action = getattr(self.controller, self.action)     
            location = self.current_dir

            selection = self.getSelection()
            if len(selection) > 0:
                location = selection[0]
            if len(self.items_selected) > 0:
                if tkMessageBox.askokcancel(self.action.capitalize(), "Are you sure? This action can be permanent"): 
                    if action(self.items_selected, location):
                        self.action = None
                    else:
                        tkMessageBox.showerror("Ops", "An error occurred :(")            
                    self.reloadMainList()
项目:SFC_models    作者:brianr747    | 项目源码 | 文件源码
def install_examples(): # pragma: no cover
    """
    Pops up windows to allow the user to choose a directory for installation
    of sfc_models examples.

    Uses tkinter, which is installed in base Python (modern versions).
    :return:
    """
    if not mbox.askokcancel(title='sfc_models Example Installation',
                            message=validate_str):
        return
    target = fdog.askdirectory(title='Choose directory to for sfc_models examples installation')
    if target == () or target == '':
        return
    install_example_scripts.install(target)
项目:chessboard_Chinese-chess    作者:JiNianLuo    | 项目源码 | 文件源码
def play(self):
        self.erase()
        self.paint_board()
        try:
            self.put_chess()
        except IndexError:
            if askokcancel('????', '???????'):
                self.file_window()
            else:
                self.root.destroy()

    # ????FEN????
项目:chessboard_Chinese-chess    作者:JiNianLuo    | 项目源码 | 文件源码
def play(self):
        self.erase()
        self.paint_board()
        try:
            self.put_chess()
        except IndexError:
            if askokcancel('????', '???????'):
                self.file_window()
            else:
                self.root.destroy()

    # ????FEN????