当前位置: 首页>>代码示例>>Python>>正文


Python tkMessageBox.askyesno函数代码示例

本文整理汇总了Python中tkMessageBox.askyesno函数的典型用法代码示例。如果您正苦于以下问题:Python askyesno函数的具体用法?Python askyesno怎么用?Python askyesno使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了askyesno函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

    def update(self):
        com = self.comEntry.get()
        dir = self.fileEntry.get()
        user1_file = os.path.join("newest","user1.bin")
        files = [os.path.join(dir, "bin",file) for file in ["boot_v1.1.bin", user1_file, "esp_init_data_default.bin", "blank.bin"]]
        if any(not(os.path.exists(file)) for file in files):
            list = "\n".join(files)
            showerror("Fatal Error", "Did you choose the correct root directory?\nOne of these files does not exist:\n%s"%list)
            return

        commands = []
        commands.append(self.format_command(com, "0x00000", files[0]))
        commands.append(self.format_command(com, "0x01000", files[1]))
        commands.append(self.format_command(com, "0x7C000", files[2]))
        commands.append(self.format_command(com, "0x7E000", files[3]))

        for i,c in enumerate(commands):
            success = False
            while not success:
                print("calling: "+" ".join(c))
                p = subprocess.Popen(c, stdout=subprocess.PIPE, bufsize=1)
                for line in iter(p.stdout.readline, b''):
                    print line,
                p.stdout.close()
                p.wait()
                if p.poll()!=0:
                    if not askyesno("Warning", "Failed to connect.\nAre you sure your board is connected to the specified port?\n"
                                           "If so, try power cycling."):
                        return
                else:
                    if(i!=3):
                        askyesno("Power Cycle", "Success. Power cycle your board to continue.")
                    success = True
        showinfo("Success", "Firmware successfully updated!")
开发者ID:naosoft,项目名称:ESP8266_Interactive_Update_Tool,代码行数:34,代码来源:update_gui.py

示例2: update_db

    def update_db(self, old=None, new=None, content=None, askoverwrite=True):
        if old is None:
            old = self.db_container.selected_file.get()
        if new is None:
            new = self.db_container.selected_file.get().strip('*')
        if content is None:
            content = self.db_container.editor.get("1.0", END).strip()

        if old == new and askoverwrite:
            savechanges = tkMessageBox.askyesno("Save changes", "A file '{}' already exists. Overwrite?".format(new))
            if savechanges:
                self.project.dbs[old] = content
            else:
                logger.error('no name specified!')
                return -1
        elif old == new and not askoverwrite:
            self.project.dbs[old] = content
        else:
            if new in self.project.dbs:
                if askoverwrite:
                    savechanges = tkMessageBox.askyesno("Save changes", "A file '{}' already exists. Overwrite?".format(new))
                    if savechanges:
                        self.project.dbs[new] = content
                    else:
                        logger.error('no name specified!')
                        return -1
            else:
                self.project.dbs[new] = content
        return 1
开发者ID:danielnyga,项目名称:pracmln,代码行数:29,代码来源:mlnlearn.py

示例3: main

def main():
    
    #Initiate GUI in Python.
    root = Tk()
    #Hide root window
    root.withdraw()

    #Start program called: "CCTS Demo Program".
    w = Label(root, text="CCTS Demo Program")
    w.pack()
    
    #display author
    tkMessageBox.showinfo("CenturyLink Cloud Application", "Author: Andrew Nielsen, Date: 10/26/2015")
    
    #call userInput() method.
    userInput()
    
    #Start if statement with a loop to reintiate program.
    question = tkMessageBox.askyesno("CenturyLink Cloud Portal", "Would you like to create another sandbox account?")
    while question == True:
        userInput()
        response = tkMessageBox.askyesno("CenturyLink Cloud Portal", "Would you like to create another sandbox account?")
        if response == False:
            sys.exit(0)
    else:
        sys.exit(0)
开发者ID:Andrew-Nielsen,项目名称:Demo-Sandbox,代码行数:26,代码来源:CCTS.py

示例4: deleteItem

 def deleteItem(self, *args):
     # first get confirmation
     if self.info.typeMarker:
         # user
         name = self.info.username.get()
         if name == 'admin':
             tkMessageBox.showinfo("Not allowed", "Deleting the admin user is not allowed!")
             return 0
         if not tkMessageBox.askyesno(message='Are you sure you want to delete user ' + str(name) + '?',\
                                     icon='question', title='Confirm deletion'):
             return 0
     else:
         #this is a group, we need to be sure its not in use ...
         name = self.info.username.get()
         for auser in self.parent.users:
             if auser[2] == name:
                 tkMessageBox.showinfo("Group is still in use!", "User " + str(auser[0]) +\
                                       " is still a member of group " + str(name) + "!")
                 return 0
         if not tkMessageBox.askyesno(message='Are you sure you want to delete group ' + str(name) +\
                                      '?', icon='question', title='Confirm deletion'):
             return 0
     # now delete the item
     if not guifunctions.deleteData(self.parent, name, self.info.typeMarker):
         print "UPDATE Failed"
         return 0
     self.parent.reloadAccounts()
     return 1
开发者ID:docmeth02,项目名称:rewired-gui,代码行数:28,代码来源:accountframe.py

示例5: read_config_file

 def read_config_file(self):
     root=Tk()
     root.withdraw()
     if not os.path.exists(self.configfile):
         if not tkMessageBox.askyesno('ERROR',abedocs.ErrorMessages(101)):
             tkMessageBox.showerror('PROGRAM EXITING', abedocs.ErrorMessages(103))
             sys.exit(1)
     else:
         try:
             xmlroot=et.parse(self.configfile).getroot()
             xmlacnts=xmlroot.find('Accounts')
             for acnt in xmlacnts.getchildren():
                 acntname=acnt.attrib['email']
                 password=acnt.find('password').text
                 disabled=acnt.find('disabled').text
                 retries=acnt.find('retries').text
                 acttype=acnt.find('type').text
                 accountsdict[acntname]={'password':password,'disabled':disabled, 'retries':retries, 'type':acttype}
             xmlpreferences=xmlroot.find('Preferences')
             for preference in xmlpreferences.getchildren():
                 settingsdict[preference.tag]=preference.text
         except:
             if not tkMessageBox.askyesno('ERROR',abedocs.ErrorMessages(102)):
                 tkMessageBox.showerror('PROGRAM EXITING', abedocs.ErrorMessages(103))
                 sys.exit(1)
开发者ID:Amazingred,项目名称:ABRAhaM,代码行数:25,代码来源:ABRAhaM_CONFIGUI.py

示例6: OnDoubleClick

    def OnDoubleClick(self):
        """Called on a double-click on the icon."""
        self.status.set(self.path)
        
        # Directories: list them in window
        if os.path.isdir(self.path):
            dirmax = int(self.textbox.limits[3].get())
            dirsize = os.path.getsize(self.path)
            if dirsize > dirmax:
                basename = os.path.basename(self.path)
                txt = "%s may contain a very large number of files.\nDisplay anyway?" % (basename)
                if not askyesno("Warning", txt):
                    return
            
            cmd = "ls -lF %s " % self.path
            out = getoutput(cmd)
            filelisting = self.path + "\n" + out
            self.textbox.clear()
            self.textbox.settext(filelisting)

        # view text files in window (sometimes pdfs slip thru)   
        elif self.ext != ".pdf" and Spiderutils.istextfile(self.path):
            # check if html files are sent to browser
            if self.ext == ".html" or self.ext == ".htm":
                browser = self.textbox.limits[4].get()
                if browser:
                    webbrowser.open(self.path)
                    return
                
            textmax = self.textbox.limits[2]
            tmax = int(textmax.get())
            textsize = os.path.getsize(self.path)

            if textsize > tmax:
                basename = os.path.basename(self.path)
                txt = "%s is %d bytes.\nDisplay anyway?" % (basename, textsize)
                if not askyesno("Warning", txt):
                    return
            try:
                fp = open(self.path,'r')
                B = fp.readlines()
            except:
                pass
            fp.close()
            self.textbox.clear()
            for line in B:
                self.textbox.component('text').insert(END, str(line))

        # binaries
        else:
            spidertype = Spiderutils.isSpiderBin(self.path)
            if spidertype != 0:  #== "image":
                infotxt = self.getSpiderInfo(self.path)
                self.textbox.clear()
                self.textbox.component('text').insert(END, infotxt)
                if spidertype == "image":
                    self.putImage(self.path, clear=0)
            
            elif self.ext.lower() in self.imagetypes:
                self.putImage(self.path)
开发者ID:spider-em,项目名称:SPIDER,代码行数:60,代码来源:xplor.py

示例7: destroy

 def destroy(self):
    """ See if we want to save before closing """
    from tkMessageBox import askyesno
    if not self.safe_close: 
       Toplevel.destroy(self)
       return
    if not hasattr(self, 'fname'):
       # No filename?  We have to ask to save
       if askyesno('Save File?', 'Do you want to save the text in this '
                   'window?', parent=self):
          self.saveastext()
       Toplevel.destroy(self)
       return
    # If we are here, we want to ask to save
    if self.original_state is DISABLED and self.up_to_date:
       # Already up-to-date
       Toplevel.destroy(self)
    elif self.original_state is NORMAL or not self.up_to_date:
       # Now we have to do text comparison. Yuck
       file_text = open(self.fname, 'r').read()
       window_text = str(self.text.get('0.0', END))
       if file_text != window_text:
          if askyesno('Save File?', 'Do you want to save the text in this '
                      'window?', parent=self):
             self.savetext()
       Toplevel.destroy(self)
       return
开发者ID:swails,项目名称:spam,代码行数:27,代码来源:spam_windows.py

示例8: __doExit

 def __doExit(this):
     this.__timeLbl.set(" ")
     this.__msgLbl.set(" ")
     if this.__isChanged:
         if tkMessageBox.askyesno("", "Phone book has changed!\nSave it first?"):
             this.__doSave()
     if tkMessageBox.askyesno("", "Really Quit?"):
         this.__root.quit()
开发者ID:Informania,项目名称:PDS,代码行数:8,代码来源:phoneBook.py

示例9: ask_quit

def ask_quit():
	status.config(text="Quiting")
	if tkMessageBox.askyesno("Quit", "Do you want to Quit?"):
		if tkMessageBox.askyesno("Delete Temporary Files", "Do you want to remove the temporary files?"):	
			path = os.path.dirname(os.path.abspath(__file__))+'/temp/'
			if os.path.exists(path):
				shutil.rmtree(path)	
		root.destroy()
开发者ID:raunaqrox,项目名称:skiManga,代码行数:8,代码来源:gui.py

示例10: askYesorNo

def askYesorNo(message, title=None, parent=None):
    " returns True or False "
    if title == None: title = 'Warning'
    if parent != None:
        ret = askyesno(title, message, parent=parent)
    else:
        ret = askyesno(title, message)
    return ret
开发者ID:spider-em,项目名称:SPIDER,代码行数:8,代码来源:spiderGUtils.py

示例11: obtenerSpinbox

def obtenerSpinbox():
	#print(valor.get())
	tkMessageBox.showinfo("Mensaje","Tu seleccionaste " + valor.get())
	tkMessageBox.showwarning("Advertencia","Esto es un mensaje de Advertencia")
	tkMessageBox.askquestion("Pregunta 1", "Cualquier cosa")
	tkMessageBox.askokcancel("Pregunta 2", "Cualquier cosa")
	tkMessageBox.askyesno("Pregunta 3", "Cualquier cosa") #Responde en boleano a diferencia del question
	tkMessageBox.askretrycancel("Pregunta 1", "Cualquier cosa")
开发者ID:LIch1994,项目名称:CodigosMT,代码行数:8,代码来源:Interfaz.py

示例12: generateImage

    def generateImage(self):
        bookheight = int(self.BOOKHEIGHT.get())
        booksheets = int(self.BOOKSHEETS.get())
        text = str(self.RENDERTEXT.get())
        font = self.SelectedFont.get()

        print text + " using font " + font
        print str(bookheight) + "mm high, " + str(booksheets) + " sheets wide"

        from PIL import Image, ImageFont, ImageDraw
        IMAGEMODE = "1" #monochrome bitmap
        #create monochrome bitmap image, 10*booksheets wide, bookheight high, 0=black, 1=white
        image = Image.new(IMAGEMODE, (booksheets*10,bookheight), 1)
        from tkMessageBox import showinfo
        #showinfo("Mode", image.mode)

        draw = ImageDraw.Draw(image)
        #fontheight = bookheight*4/5 #scale text to 80% of book height
        fontheight = bookheight

        renderfont = ImageFont.truetype(font,fontheight)
        print "Text Size " + str(draw.textsize(text, renderfont))
        print "Image Size " + str(image.size)

        #offset to attempt to centre font rather than bottom aligned (upward shift by 5%)
        #print (bookheight/-20)
        draw.text((0,(bookheight/-20)), text, fill=0, font=renderfont)

        filename = text + " using " + font + " - " + str(bookheight) + "mm, " + str(booksheets) + "p.bmp"
        image.save(filename)

        image = image.convert("L")
        image = RemoveWhiteColumns(image)
        image = image.resize((booksheets,bookheight))
        image.save(filename)


        image.show()
        from tkMessageBox import askyesno
        if(askyesno("Continue?", "Preview ok? Continue?")):
        #print px
            document = OpenAndInitialiseDocX(filename)
            print "Document opened"

            CalculateAndWriteDocX(document, image)

            document.save(filename + ".docx")
        #else:
            #filename is not defined, program should exit
            #print "No Filename provided to Open"


        #todo add exception handling and ask for filename.
        #print "Complete"
        #image.save("blahoutput.bmp")

        if not askyesno("Another?", "Create another from Text?"):
            self.quit()
开发者ID:markrattigan,项目名称:bookorigamicalc,代码行数:58,代码来源:Bookword+calculations.py

示例13: save_primer_from_edit

    def save_primer_from_edit(self, parent_window=None):
        """Save the primer in the DB when doing a primer Edit"""
        if not parent_window:
            parent_window = self.eval_win

        # Check if the primer name has been changed first, and ask for confirmation of rename

        if self.primername_var.get() != self.edit_primer_name or not self.edit_primer_name:
            import tkMessageBox
            ok = tkMessageBox.askyesno('Primer Name altered',
                                       'Rename primer and save?\n',
                                       parent=parent_window)
            if not ok:
                self.primername_var.set(self.edit_primer_name)
                return
            #rename primer based on value in entry widget
            else:
                new_name=self.primername_var.get()
                if new_name:
                    #only rename if there isn't already a primer with the same name
                    if not self.data['primer_dict'].has_key(new_name):
                        self.data['primer_dict'][new_name]=self.data['primer_dict'][self.edit_primer_name].copy()
                        del self.data['primer_dict'][self.edit_primer_name]
                        self.edit_primer_name = new_name
                        self.i_parent.new_name = new_name
                    #otherwise don't allow rename
                    else:
                        tkMessageBox.showwarning('Primer name already present',
                                     'Primer name already present.\nPlease choose another name',
                                     parent=parent_window)
                        return


        # Update the sequence and description fields for the primer
        DNA=self.eval_var.get()
        # Validation check if primer is changed (maybe by mistake)
        if not DNA:
            ok = tkMessageBox.askyesno('No sequence entered',
                                        'No sequence entered.\nDo you wish to save anyway?',
                                        parent=parent_window)
            if not ok:
                return

        import mutation
        ok,DNA_sequence=mutation.check_DNA(DNA)
        self.data['primer_dict'][self.edit_primer_name]['sequence']=DNA_sequence
        self.data['primer_dict'][self.edit_primer_name]['description']=self.descr_var.get()

        #print 'Primer Info:',self.edit_primer_name,self.data['primer_dict'][self.edit_primer_name]

        # Clear all graphics
        if getattr(self,'pDB',None):
            self.pDB.clear_pDB_objects()

        # Close the window
        self.eval_win.destroy()
        return
开发者ID:shambo001,项目名称:peat,代码行数:57,代码来源:evaluate_primer.py

示例14: setAuthKey

 def setAuthKey(self):
     key = self.entry_key.get()
     if not self.keyLooksValid(key):
         if not tkMessageBox.askyesno("Invalid Key", "That key looks invalid to me. Are you sure?"):
             return False
     
     fh = open(self.getKeyPath(), 'w+')
     fh.write(key)
     fh.close()
     tkMessageBox.askyesno('Saved', "AuthKey Saved!")
开发者ID:danny6167,项目名称:FSSetAuthKey,代码行数:10,代码来源:FSSetAuthKey.py

示例15: continue_deployment

def continue_deployment():
    host_deploy_process_map = {}
    global  virt_g, phy_g, canvas, host_config_map
    # create configuration generator
    update_color_virtual_network(virt_g.nodes(), 'g')
    update_color_physical_network(phy_g.nodes(), 'r')
    canvas.draw()
    [error_msg, ret_code, dir] = generate_configuration(config_java_jar)
    if ret_code != 0:
        messagebox.showerror(title="Error From Configuration Generator", message=error_msg)
        sys.exit(1)
    host_config_ini = dir+'/host-config-exp.ini'
    host_config_map = read_host_config_file(host_config_ini)
    host_config_map_len = len(host_config_map)
    if host_config_map_len == 0:
        messagebox.showerror(title="Error From Configuration Generator",
                             message='something went wrong with configuration generator')
        sys.exit(1)
    messagebox.showinfo(title='Physical Host', message='Establishing connection to physical hosts')
    for host, [ip, cfg_file] in host_config_map.iteritems():
        [scp_ret_code, scp_out, scp_err] = copy_to_remote([cfg_file, create_vne_py], 'root', ip, '~/')
        if scp_ret_code != 0:
            is_exit = messagebox.askyesno(title='Physical Host', message='Error in communicating to '+ host +
                                          '\nDo you want to continue?')
            if is_exit == messagebox.NO:
                sys.exit(1)
        else:
            update_color_physical_network([host])
            canvas.draw()
    for host_name, [ip, cfg_file] in host_config_map.iteritems():
        #print 'before launch ' + host_name
        file_name = cfg_file.split('/')[-1]
        dep_process = launch_deployment_on_remote_host(ip, file_name)
        host_deploy_process_map[dep_process.stdout.fileno()] = [host_name, dep_process]
        poller.register(dep_process.stdout.fileno(), select.EPOLLHUP)
    i = 0
    no_process = len(host_deploy_process_map)
    while i < no_process:
        complet_fds = monitor_deployment_process()
        print complet_fds
        i += len(complet_fds)
        for fd in complet_fds:
            [host_name, dep_process] = host_deploy_process_map.pop(fd)
            dep_process.wait()
            print dep_process.returncode
            if dep_process.returncode == 0:
                update_networks_according_to_mapping(host_name)
            else:
                is_exit = messagebox.askyesno(title='Physical Host', message='Error while deploying on '+ host_name +
                                                                             '\nDo you want to continue?')
                if is_exit == messagebox.YES:
                    sys.exit(1)
    connect_vm_button.config(state='normal')
    continue_button.config(state='disabled')
    return
开发者ID:hksoni,项目名称:DiG,代码行数:55,代码来源:dig-deploy-final.py


注:本文中的tkMessageBox.askyesno函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。