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

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

项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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"
项目:Circadia    作者:hooyah    | 项目源码 | 文件源码
def menu_saveThemeAs(self):
        """ callback for saveAs menu item """

        newTheme = tkFileDialog.askdirectory(mustexist=True, initialdir=self.themeRootPath, title='Open Theme')
        if newTheme and os.path.isdir(newTheme):
            if os.path.isfile(newTheme+os.path.sep+'theme.json'):
                if not tkMessageBox.askyesno(title='Save theme', message='Theme exists. Overwrite?'):
                    return
            self.saveTheme(newTheme)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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"
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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"
项目:xbmctopython    作者:pybquillast    | 项目源码 | 文件源码
def yesno(self, heading, line1, line2=None, line3=None, nolabel=None, yeslabel=None):
        """Show a dialog 'YES/NO'.

        heading: string or unicode - dialog heading.
        line1: string or unicode - line #1 text.
        line2: string or unicode - line #2 text.
        line3: string or unicode - line #3 text.
        nolabel: label to put on the no button.
        yeslabel: label to put on the yes button.

        Note:
            Returns True if 'Yes' was pressed, else False.

        Example:
            dialog = xbmcgui.Dialog()
            ret = dialog.yesno('XBMC', 'Do you want to exit this script?')
        """
        root = self.root
        prompt = [elem for elem in [line1, line2, line3] if elem]
        message = '\n'.join(prompt)
        ans = tkMessageBox.askyesno(heading, message, parent=root)
        root.destroy()
        return ans[0]
项目:Farmbot_GeneralAP    作者:SpongeYao    | 项目源码 | 文件源码
def on_exit(self):
        #When you click to exit, this function is called
        if tkMessageBox.askyesno("Exit", "Do you want to quit the application?"):
            self.store_para(gui_vars.saveParaPath, gui_vars.configName)
            print 'Close Main Thread...'
            self.main_run_judge= False
            self.ArdMntr.exit= True
            self.scanning_judge= False
            #self.CamMntr.stop_clean_buffer()
            #del(self.thread_main)
            self.thread_main.exit()
            print 'Close Arduino Thread...'
            #del(self.CamMntr.thread_clean_buffer)
            #print 'Close Scanning Thread...'
            #del(self.thread_scanning)
            print self.MaxSpeed

            self.CamMntr.release_cap()
            self.root.destroy()
项目:pyry3d_chimera_extension    作者:mdobrychlop    | 项目源码 | 文件源码
def ss_choose_outdir(self):
        Paths.ss_outpath = P3F.ig_choose_output_folder(
                            self.page3,
                            self.outdir_entry
                            )
        if Paths.ss_outpath != "":
            rly = tkMessageBox.askyesno(
                    "Warning",
                    "All files in "+Paths.ss_outpath+" will be deleted. Continue?"
                     )
            if rly is True:
                self.autoscore_button.configure(state="normal")
                self.simulation_button.configure(state="normal")
            else:
                self.outdir_entry.configure(entry_state="normal")
                self.autoscore_button.configure(state="disabled")
                self.simulation_button.configure(state="disabled")
                Paths.ss_outpath = ""
        else:
            self.outdir_entry.configure(entry_state="normal")
            Paths.ss_outpath = ""
            self.autoscore_button.configure(state="disabled")
            self.simulation_button.configure(state="disabled")
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(title, message)
项目:AWS-SSL-Manager    作者:adaranutsa    | 项目源码 | 文件源码
def deleteSSL(self):
        resposnse = messagebox.askyesno(title="Do you want to continue?",
                                        message="Are you sure that you want to delete " + self.certsList.get(ACTIVE))
        if resposnse == True:
            try:
                self.iamClient.delete_server_certificate(ServerCertificateName=self.certsList.get(ACTIVE))
                self.message.info("Deleting SSL", "SSL deleted")
                self.getSSLList()
            except:
                self.message.error("Something happened", "There was an error\n" + str(sys.exc_info()[0]))

    # Function to set the AWS profile from input box
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(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 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_yes_no(self, title, message):
        return messagebox.askyesno(title, message)
项目:SPGL    作者:wynand1004    | 项目源码 | 文件源码
def ask_yes_no(self, title, message):
        return messagebox.askyesno(title, message)
项目:Circadia    作者:hooyah    | 项目源码 | 文件源码
def saveit(self):

        doit = tkMessageBox.askyesno("save gamma curve", "overwrite?")
        if doit:
            keys = [ [self.gamma_red[x][0], (self.gamma_red[x][1], self.gamma_green[x][1], self.gamma_blue[x][1])] for x in range(self.num_ctrl)]
            grad = { 'gamma':keys}
            with open('gamma_grad.json', 'w') as outfile:
                json.dump(grad, outfile)
                print 'written.'
项目:Circadia    作者:hooyah    | 项目源码 | 文件源码
def menu_overrideTheme(self):
        """ callback for save menu item """

        if self.themePath == "":
            self.menu_saveThemeAs()
            return
        themebase, themename = os.path.split(self.themePath)
        if not tkMessageBox.askyesno(title='Save theme', message='Overwrite existing theme "%s"?'%themename):
            return
        self.saveTheme(self.themePath)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def close_window(self):
        yes = tkmessage.askyesno("Exit", "Do you really want to quit?")
        if yes:
            self.close()
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
        self.DeactivateCurrentConfig()
        #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.SaveAllChangedConfigs()
        self.ActivateConfigChanges()
        self.SetKeysType()
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
        self.DeactivateCurrentConfig()
        #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.SaveAllChangedConfigs()
        self.ActivateConfigChanges()
        self.SetThemeType()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
        self.DeactivateCurrentConfig()
        #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.SaveAllChangedConfigs()
        self.ActivateConfigChanges()
        self.SetKeysType()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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
        self.DeactivateCurrentConfig()
        #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.SaveAllChangedConfigs()
        self.ActivateConfigChanges()
        self.SetThemeType()
项目:madchess    作者:iogf    | 项目源码 | 文件源码
def issuedMatch(self):
        info = self.host.pool.queue[0]

        ok = askyesno('Challenge', 
                      'There is a challenge %s!' % str(info))

        if ok:
            self.acceptMatch()
        else:
            self.refuseMatch()
项目:madchess    作者:iogf    | 项目源码 | 文件源码
def issuedTakeOneBack(self):
        info = self.host.pool.queue[0]

        ok = askyesno('Challenge', 
                      'Your opponent requested a take one back ! Accept it?')

        if ok:
            self.acceptTakeOneBack()
        else:
            self.refuseTakeOneBack()
项目:madchess    作者:iogf    | 项目源码 | 文件源码
def issuedTakeTwoBack(self):
        info = self.host.pool.queue[0]

        ok = askyesno('Challenge', 
                      'Your opponent requested a take two back ! Accept it?')

        if ok:
            self.acceptTakeTwoBack()
        else:
            self.refuseTakeTwoBack()
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def launch_pymod_update(self):
        # Gets the latest release number from network.
        try:
            update_found = pmup.check_for_updates(self.pymod_version, self.pymod_revision)
        except Exception, e:
            self.show_error_message("Connection Error", "Can not obtain the latest PyMod version number beacause of the following error: '%s'" % e)
            return False

        if not update_found:
            self.show_warning_message("Update Canceled", "Your PyMod version (%s.%s) is already up to date." % (self.pymod_version, self.pymod_revision))
            return False

        # Ask for update confirmation.
        title = "Update PyMod?"
        message = "Would you like to update your current PyMod version (%s.%s) to the latest stable one available online (%s)? You will need to restart PyMOL in order to use the new version." % (self.pymod_version, self.pymod_revision, update_found)
        answer = tkMessageBox.askyesno(title, message, parent=self.main_window)
        if not answer:
            return False

        # Fetches the latest stable version files of PyMod.
        try:
            plugin_zipfile_temp_name = pmup.fetch_plugin_zipfile()
        except Exception, e:
            self.show_error_message("Connection Error", "Can not fetch the latest PyMod files beacause of the following error: '%s'" % e)
            return False

        if not plugin_zipfile_temp_name:
            return False

        # Installs the new PyMod version.
        pymod_plugin_dir = os.path.dirname(os.path.dirname(__file__))
        update_results = pmup.update_pymod(plugin_zipfile_temp_name, pymod_plugin_dir)
        if update_results[0]:
            self.show_info_message("Update Successful", "PyMod has been updated to version %s. Please restart PyMOL in order to use the updated PyMod version." % (update_found))
        else:
            self.show_error_message("Update Failed", update_results[1])
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def confirm_close(self, parent=None):
        """
        Asks confirmation when the main window is closed by the user.
        """
        parent_window = None
        if parent == None:
            parent_window = self.main_window
        else:
            parent_window = parent
        answer = tkMessageBox.askyesno(message="Are you really sure you want to exit PyMod?", title="Exit PyMod?", parent=parent_window)
        if answer:
            self.main_window.destroy()
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def begin_new_project_from_main_menu(self):
        answer = tkMessageBox.askyesno(message="Are you really sure you want to begin a new PyMod project? If you do not save your current project, its data will be permanently lost.", title="Begin New Project?", parent=self.main_window)
        if not answer:
            return None
        self.start_new_project()


    ##################
    # Save projects. #
    ##################
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def sequence_save(self, element):
        """
        Save a single sequence to a file.
        """
        remove_indels_choice = False
        if "-" in element.my_sequence:
            remove_indels_choice = tkMessageBox.askyesno(message="Would you like to remove indels from the sequence when saving it to a file?", title="Save File", parent=self.main_window)

        filepath=asksaveasfilename(filetypes=[("fasta","*.fasta")],parent=self.main_window)

        if not filepath == "":
            dirpath = os.path.dirname(filepath)
            filename = os.path.splitext(os.path.basename(filepath))[0]
            self.build_sequences_file([element], filename, file_format="fasta", remove_indels=remove_indels_choice, use_structural_information=False, new_directory=dirpath)
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def delete_alignment_from_the_left_pane(self):
        title = "Delete Cluster?"
        message = "Are you sure you want to delete %s?" % (self.get_cluster().my_header)
        choice = tkMessageBox.askyesno(message=message, title=title, parent=pymod.main_window)
        if choice:
            pymod.delete_alignment(self.get_cluster())
        pymod.gridder()
项目:firesave    作者:kactusken    | 项目源码 | 文件源码
def AskReplace():
    if tkMessageBox.askyesno("Replace save file?",
                             "Do you want to replace your existing save file?\nBackup of original will be created.") == True:
        replace_path = "%s_%d" % (ent_SaveFile.get(), int(time.time()))

        os.rename(ent_SaveFile.get(), replace_path)
        DebugPrint(" + Backed up save file to %s" % (replace_path))

        os.rename(ent_OutputFile.get(), ent_SaveFile.get())
        DebugPrint(" + Replace old save file with new save file")

# Function to alphabetize wrestler list
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def yesNoBox(self, title, message):
        self.topLevel.update_idletasks()
        return MessageBox.askyesno(title, message)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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()
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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()
项目:PIEFACE    作者:jcumby    | 项目源码 | 文件源码
def find_updates(self, verbose=True):
        """ Run check_update and as user whether to update. """
        if self.check_update():
            if tkMessageBox.askyesno('Download update', 'An updated version of PIEFACE exists, do you want to download it?'):
                webbrowser.open('https://github.com/jcumby/PIEFACE/releases/latest')
        else:
            if verbose:
                tkMessageBox.showinfo('Update','PIEFACE is up to date')
项目:SandmanChess    作者:ThomasMadappattu    | 项目源码 | 文件源码
def decide_who_plays(self):
            if tkMessageBox.askyesno(" White ?", "Engine plays White  ?"):
                    self.playerMovesFirst = True
                    self.draw_player_move_first()
项目:pyry3d_chimera_extension    作者:mdobrychlop    | 项目源码 | 文件源码
def check_dir(self, dire):
        if not os.path.exists(dire):
            os.makedirs(dire)
        else:
            def go_ahead_then(dire):
                shutil.rmtree(dire)
                os.makedirs(dire)
            wte = tkMessageBox.askyesno(
                                "Warning",
                                "All files in\n" +
                                dire +
                                "\nwill be deleted. Continue?"
                                )
            if wte:
                wtd = tkMessageBox.askyesno("Warning", "Are you sure?")
                if wtd:
                    go_ahead_then(dire)
                    print "Files erased. Continuing."
                    return 1
                else:
                    tkMessageBox.showinfo(
                        "PyRy3D info", "Choose a different directory \n\
                         and try again."
                         )
                    return 0
            else:
                tkMessageBox.showinfo(
                    "PyRy3D info",
                    "Choose a different directory \n and try again."
                    )
                return 0
项目:pyry3d_chimera_extension    作者:mdobrychlop    | 项目源码 | 文件源码
def new_session(self):
        rly = tkMessageBox.askyesno(
                "Warning",
                "This will close all opened models. Continue?"
                )
        if rly is True:
            self.clear()
            self.clear_button.configure(state="normal")
            self.open_button.configure(state="normal")
            self.dens_button.configure(state="normal")
            self.comp_button.configure(state="normal")
            self.new_session_button.configure("disabled")
            chimera.runCommand("close all")
项目:pyry3d_chimera_extension    作者:mdobrychlop    | 项目源码 | 文件源码
def openandsaveall(self):
        if len(self.complist) <= 1:
            tkMessageBox.showinfo(
                "PyRy3D info",
                "You must add at least two structures."
                )
        else:
            rly1 = True
            if Paths.mappath == "" or Paths.mappath == ():
                rly1 = tkMessageBox.askyesno(
                        "Warning",
                        "No shape descriptor provided. Continue?"
                        )

            if rly1 is True:
                rly2 = tkMessageBox.askyesno(
                        "Warning",
                        "This will close all opened models before loading new data. Continue?"
                        )
                if rly2 is True:
                    runCommand("close all")
                    P1F.opencommand(Paths.mappath, self.complist)
                    P1F.writeAllPDBs(Paths.temppath, Paths.mappath)
                    runCommand("windowsize 9999 9999")
                    self.open_button.configure(state="disabled")
                    self.dens_button.configure(state="disabled")
                    self.comp_button.configure(state="disabled")
                    self.clear_button.configure(state="disabled")
                    self.new_session_button.configure(state="normal")
                    self.notebook.tab(1).configure(state="normal")
                    self.notebook.tab(2).configure(state="normal")
                    self.notebook.tab(3).configure(state="normal")
                    self.notebook.tab(3).configure(state="normal")

    # ----- FUNCTIONS TRIGGERED BY WIDGETS ON THE --- SECOND PAGE ---
项目:RSSscpi    作者:luksan    | 项目源码 | 文件源码
def zero_cal():
    ok = tkMessageBox.askyesno("Zero power sensor", "Perform zero level adjust? (Disconnect sensor from the signal source)")
    if ok:
        sensor.cal_zero()
        sensor.send_OPC()
        print("Zeroing sensor. Please wait.")
        wait_on_queue_progress_bar(sensor.event_queue, 6)
        tkMessageBox.showinfo("Zero power sensor", "Zero cal complete. Reconnect the power sensor to the signal source.")
项目:unmessage    作者:AnemoneLabs    | 项目源码 | 文件源码
def delete(self):
        if askyesno(title='Deletion',
                    message='Are you sure you wish to delete this '
                            'conversation?'):
            self.peer.delete_conversation(self.conversation.contact.name)
            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.'))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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 in 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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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 in 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
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def start_new_project(self):
        """
        Starts up a new job.
        """
        self.initialize_project_data()
        # Cheks for PyMod configuration file.
        self.configuration_file_error = False

        # If it is not found, then treat this session as the first one and asks the user to input
        # the 'PyMod Directory' path before beginning the first PyMod job.
        if not os.path.isfile(self.cfg_file_path):
            self.show_first_time_usage_message()
            self.show_pymod_directory_selection_window()

        # The configuration file is found.
        else:
            try:
                # Check if there is 'pymod_temp_directory' left by the PyMod installer script.
                if not self.check_installer_script_temp_directory():
                    # Get values options for each PyMod tool and start a new PyMod job.
                    self.initialize_session()
                # If there is a 'pymod_temp_directory' (the installer script has been used before
                # this last PyMod session).
                else:
                    # The installer script was run before configuring PyMod for the first time (it
                    # left an empty configuratio file).
                    if self.check_empty_configuration_file():
                        self.show_first_time_usage_message()
                        self.show_pymod_directory_selection_window()
                    # The installer script was run after the first PyMod session (in order to
                    # install some missing tools).
                    else:
                        self.initialize_session()

            except Exception, e:
                self.show_configuration_file_error(e, "read")
                title = 'Configuration file repair'
                message = "Would you like to delete PyMod configuration file and build a new functional copy of it?"
                repair_choice = tkMessageBox.askyesno(title, message)
                self.configuration_file_error = True
                if repair_choice:
                    self.show_pymod_directory_selection_window()
                else:
                    self.main_window.destroy()
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def check_sequences_level(self):
        """
        This method is used to ask the user a confirmation before performing an alignment in certain
        situations (for example when building an alignment only with sequences belonging to the same
        cluster).
        """
        proceed_with_alignment = False
        self.clusters_are_involved = False

        # ---
        # For regular alignments.
        # ---
        if self.alignment_strategy == "regular-alignment":

            self.rebuild_single_alignment_choice = False
            self.extract_siblings_choice = False

            if len(self.involved_clusters_mi_list) == 1 and len(self.childless_mothers_mi_list) == 0:
                # If there is only one cluster selected with all its elements: the user might want to
                # rebuild an alignment with all its elements, ask confirmation.
                if self.involved_clusters_mi_list == self.selected_clusters_mi_list:
                    title = "Rebuild alignment?"
                    message = "Would you like to rebuild the alignment with all its sequences?"
                    proceed_with_alignment = tkMessageBox.askyesno(title, message, parent=self.main_window)
                    self.rebuild_single_alignment_choice = proceed_with_alignment
                else:
                    title = "Extract children?"
                    message = "Would you like to extract the selected children and build a new alignment?"
                    proceed_with_alignment = tkMessageBox.askyesno(title, message, parent=self.main_window)
                    self.extract_siblings_choice = proceed_with_alignment

            elif len(self.involved_clusters_mi_list) > 0:
                self.clusters_are_involved = True
                proceed_with_alignment = True

            elif len(self.involved_clusters_mi_list) == 0:
                proceed_with_alignment = True

        # ---
        # For profile alignments.
        # ---
        elif self.alignment_strategy == "profile-alignment":
            proceed_with_alignment = True
            self.clusters_are_involved = True

        return proceed_with_alignment
项目:pymod    作者:pymodproject    | 项目源码 | 文件源码
def dope_from_main_menu(self):
        """
        Called when users decide calculate DOPE of a structure loaded in PyMod.
        """
        # Checks if the DOPE profiles can be computed.
        selection = self.get_selected_sequences()
        if not self.modeller.can_be_launched():
            self.show_error_message("MODELLER Error", "MODELLER is missing. In order to compute DOPE scores of a structure, MODELLER has to be installed.")
            return False
        if len(selection) == 0:
            self.show_error_message("Selection Error", "Please select at least one structure to assess.")
            return False
        if not self.all_sequences_have_structure():
            self.show_error_message("Selection Error", "Please select only elements that have a 3D structure currently loaded in PyMOL.")
            return False
        if len(set([seq.mother_index for seq in selection])) != 1:
            self.show_error_message("Selection Error", "You can assess multiple structures DOPE only if they are aligned in the same cluster.")
            return False

        # Ask users if they would like to color the sequences according to their DOPE values.
        title = "Color Option"
        message = "Would you like to color the selected sequences by their DOPE values, once they have been calculated?"
        color_by_dope_choice = tkMessageBox.askyesno(message=message, title=title, parent=pymod.main_window)

        # Initializes MODELLER.
        if self.modeller.run_internally():
            env = modeller.environ()
            env.io.atom_files_directory = []
            env.io.atom_files_directory.append(".")
            env.io.hetatm = True
            env.io.water = True
            env.libs.topology.read(file='$(LIB)/top_heav.lib')
            env.libs.parameters.read(file='$(LIB)/par.lib')
        else:
            env = None

        # Actually computes the DOPE scores of the polypeptide chains in the user selection.
        for element in selection:
            self.compute_dope(element,env=env)

        # Assigns to each residue of the selected chains a correspoding color according to its DOPE.
        self.assign_dope_items(selection)

        # Color the elements.
        if color_by_dope_choice:
            for element in selection:
                element.color_element_by_dope()
        self.gridder()

        # Shows the DOPE profiles plot.
        dope_graph_mode = None
        if len(selection) == 1:
            dope_graph_mode = "single"
        elif len(selection) >= 2:
            dope_graph_mode = "multiple"

        # Prepares the data to show in the plot.
        dope_plot_data = self.prepare_dope_plot_data(selection, mode = dope_graph_mode)

        # Shows the plot.
        self.show_dope_plot(dope_plot_data)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
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 in 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 >>self.tkconsole.stderr, \
                         "IDLE internal error in runcode()"
                self.showtraceback()
                self.tkconsole.endexecuting()
            else:
                if self.tkconsole.canceled:
                    self.tkconsole.canceled = False
                    print >>self.tkconsole.stderr, "KeyboardInterrupt"
                else:
                    self.showtraceback()
        finally:
            if not use_subprocess:
                try:
                    self.tkconsole.endexecuting()
                except AttributeError:  # shell may have closed
                    pass