• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python messagebox.askyesnocancel函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: close_tab

    def close_tab(self,*event):
        """
"for_save" does not close the tab at all but asks to save it
"already_saved" immediately closes the tab even if unsaved
"already_saved_self_managed" same but does not open a blank tab if 0 tab
anything else would be a combination of the two above
"""
        def kill_tab(self,tab_index, open_at_least_one=True):
            del self.model.tabs_html[tab_index]
            del self.text_fields[tab_index]
            self.html_text_tabs.forget(tab_index)
            if len(self.model.tabs_html) > 0:
                self.html_text_tabs.select(0)
                self.model.selected_tab = 0
            elif open_at_least_one:
                self.model.start_mod = "blank"
                self.model._start_new_session()
        
        tab_index = self.model.selected_tab
        current_object = self.model.tabs_html[tab_index]
        if event[0] == "for_save":
            if not current_object.saved:
                answer = messagebox.askyesnocancel(
                    title=_("Attention"),
                    message=_("Voulez vous sauvegarder avant de fermer l'onglet %s?" %
                              (self.html_text_tabs.tab(tab_index,option='text')))
                    ) # True False or None 
                if answer and not self.model.save_html_file():
                        return "cancel"
                elif answer is None: # Cancel or X pressed
                    return "cancel"
            return "no_cancel"
        elif event[0] == "already_saved":
            kill_tab(self,tab_index)
        elif event[0] == "already_saved_self_managed":
            kill_tab(self,tab_index, False)
        else: # manual tab_closing
            if not current_object.saved:
                answer = messagebox.askyesnocancel(
                    title=_("Attention"),
                    message=_("Voulez vous sauvegarder avant de fermer cet onglet ?"))
                if answer: # Yes
                    if self.model.save_html_file():
                        kill_tab(self,tab_index)
                elif answer is None: pass # Cancel or X pressed
                else :
                    kill_tab(self,tab_index) # No
            else:
                kill_tab(self,tab_index)
开发者ID:GrosSacASac,项目名称:WebSpree,代码行数:49,代码来源:GraphicalUserInterfaceTk.py


示例2: save_session_dialog

 def save_session_dialog(self,*event):
     
     path_list = []
     for tab_not_closed_index in range(len(self.model.tabs_html)-1,-1,-1):
         if self.model.tabs_html[tab_not_closed_index].save_path:
             path_list.insert(0,self.model.tabs_html[tab_not_closed_index].save_path)
      # True False or None 
     answer = messagebox.askyesnocancel(
         title=_(u"Question"),
         message=_(u"Voulez vous sauvegarder la session dans un fichier spécifique ?")
     )
     if answer:
        file_path = filedialog.asksaveasfilename(defaultextension=JSON["defaultextension"],
                                              initialdir=self.model.guess_dir(),
                                              filetypes=JSON["filetypes"],
                                              initialfile="webspree_session.json")
        if file_path:
            session_object = {
                "webspree":"webspree_session",
                "version": "1.1.0",
                "path_list": path_list,
                "tab_index": self.model.selected_tab,
                "zoom": self.zoom_level,
                "edit_mod": self.mode.get()
            }
                
            JSON_TEXT = json.dumps(session_object,sort_keys=False, indent=4, separators=(',',':'))
            codecs.open(file_path, 'w', "utf-8").write(JSON_TEXT)
     elif not answer:
         self.model.set_option("previous_files_opened", path_list)
     elif answer is None:
         pass
开发者ID:GrosSacASac,项目名称:WebSpree,代码行数:32,代码来源:GraphicalUserInterfaceTk.py


示例3: main

def main():
    top = tix.Tk()

    nb = tix.NoteBook(top, width=300, height=200)
    nb.pack(expand=True, fill="both")

    nb.add("page1", label="text")
    f1 = tix.Frame(nb.subwidget("page1"))
    st = tix.ScrolledText(f1)
    st.subwidget("text").insert("1.0", "Here is where the text goes...")
    st.pack(expand=True)
    f1.pack()

    nb.add("page2", label="Message Boxes")
    f2 = tix.Frame(nb.subwidget("page2"))
    # 通过联合使用expand,fill和anchor,在窗口大小改变时,可以精确地控制小部件的行为
    tix.Button(f2, text="error", bg="lightblue", command=lambda t="error", m="This is bad!": mb.showerror(t, m)).pack(fill="x",
                                                                                                                      expand=True)
    tix.Button(f2, text="info", bg="pink", command=lambda t="info", m="Information": mb.showinfo(t, m)).pack(fill="x", expand=True)
    tix.Button(f2, text="warning", bg="yellow", command=lambda t="warning", m="Don't do it!": mb.showwarning(t, m)).pack(fill="x",
                                                                                                                         expand=True)
    tix.Button(f2, text="question", bg="green", command=lambda t="question", m="Will I?": mb.askquestion(t, m)).pack(fill="x",
                                                                                                                     expand=True)
    tix.Button(f2, text="yes - no", bg="lightgrey", command=lambda t="yes - no", m="Are you sure?": mb.askyesno(t, m)).pack(
            fill="x", expand=True)
    tix.Button(f2, text="yes - no - cancel", bg="black", fg="white",
               command=lambda t="yes - not - cancel", m="Last chance...": mb.askyesnocancel(t, m)).pack(fill="x", expand=True)

    f2.pack(side="top", fill="x")
    top.mainloop()
开发者ID:L1nwatch,项目名称:Mac-Python-3.X,代码行数:30,代码来源:learn_notebook.py


示例4: ensure_saved

 def ensure_saved (self):
     """
         ensures modified project will be saved before next step;
         returns True when all is OK, False if dialog has been
         cancelled or any other trouble fired up;
     """
     # inits
     response = self.YES
     # got to save first?
     if self.project_modified:
         # ask for saving
         response = MB.askyesnocancel(
             _("Question"),
             _("Project has been modified. Save it?")
         )
         # user answered 'yes'
         if response == self.YES:
             # save project
             response = self.slot_save()
         # end if
     # end if
     # CANCEL=None, NO=False, YES=True
     return (
         response and self.is_good_file_format(self.project_path)
     )
开发者ID:PabloSajnovsky,项目名称:tkScenarist,代码行数:25,代码来源:project_file_management.py


示例5: prompt_save

 def prompt_save(self, editor):
     fname = editor.fpathname or editor.fname
     msg = "Save '%s' before closing?" % fname
     ans = askyesnocancel(message=msg)
     if ans:
         # return cancel if selected save and then not saved
         return True if self.save(editor) else None
     return ans
开发者ID:RobinManoli,项目名称:VisualPython,代码行数:8,代码来源:filemenu.py


示例6: main

def main():
    # 为了不让空窗口出现,必须导入主Tkinter模块并实例化顶层Tk对象.然后通过调用withdraw()让对象不可见
    tk = tkinter.Tk()
    tk.withdraw()  # 去掉空窗口

    print(dir(mb))

    # 注意,一些函数返回字符串,比如ok,而其他函数则返回布尔结果.最好在交互式提示符上实验它们,以便知道返回值的类型.
    # 注意,当出现Cancel时,单击它会返回None
    mb.showinfo("Title", "Your message here")
    mb.showerror("An Error", "Oops!")
    mb.showwarning("Title", "This may not work...")
    mb.askyesno("Title", "Do you love me?")
    mb.askokcancel("Title", "Are you well?")
    mb.askquestion("Title", "How are you?")
    mb.askretrycancel("Title", "Go again?")
    mb.askyesnocancel("Title", "Are you well?")
开发者ID:L1nwatch,项目名称:Mac-Python-3.X,代码行数:17,代码来源:test_tkinter.py


示例7: messages

 def messages(self):
     print("info", showinfo("Spam", "Egg Information"))
     print("warning", showwarning("Spam", "Egg Warning"))
     print("error", showerror("Spam", "Egg Alert"))
     print("question", askquestion("Spam", "Question?"))
     print("proceed", askokcancel("Spam", "Proceed?"))
     print("yes/no", askyesno("Spam", "Got it?"))
     print("yes/no/cancel", askyesnocancel("Spam", "Want it?"))
     print("try again", askretrycancel("Spam", "try again?"))
开发者ID:plassen,项目名称:oreilly-python-2,代码行数:9,代码来源:dialogdemo.py


示例8: beforeleave

 def beforeleave(self):
     if self.unsaved:
         henji = messagebox.askyesnocancel('还未保存','真的要退出吗?修改已生效,但若不保存'
                                           ',重启程序后将恢复。\n保存?不保存?返回?')
         if henji is True: self.mem_save()
         elif henji is False: pass
         elif henji is None: return
         else: raise RuntimeError
     self.maintop.flashMemberCheckbox()
     self.top.destroy()
开发者ID:Ceilopty,项目名称:coc-war-manager,代码行数:10,代码来源:my_menu.py


示例9: save

def save():
	state=messagebox.askyesnocancel(message='Do you want to create a new version?', icon='question', title='CAUTION!')
	if state: # dupe
		dupeFile()
		saveActn()
	elif state==False: # don't dupe
		if messagebox.askyesno(message='Are you sure you want to overwrite the existing files?', icon='question', title='CAUTION!'):
			saveActn()
		else:
			dupeFile()
			saveActn()
开发者ID:flytape8490,项目名称:apa,代码行数:11,代码来源:apa.py


示例10: load_game

 def load_game(self):
     if self.active_profile is not None:
         a = messagebox.askyesnocancel(
             "Game is loaded",
             "Do you wish to save your current game?",
         )
         if a is None:
             return
         elif a is True:
             self.save_game()
     MyDialog(self.tkRoot, "What if your fighter's name?", self, "recreate_player")
开发者ID:EJ-Esteban,项目名称:PunchArena_v2,代码行数:11,代码来源:Punch_mainmenu.py


示例11: onCmdChooseFile

	def onCmdChooseFile(self,extra=None):
		'''文件选择'''
##		oldstat=self.stat
##		if self.stat==const.StatPlaying and self.timerid:
##			self.pauseShow(const.StatPaused)
		f=tkFileDialog.askopenfilenames(parent=self.root,title='Choose file(s) to show',
			initialdir=self.c.recent_dir,
			filetypes=[('Text','*.txt *.log'),('Python', '*.py *.pyw'), ('All files', '*')] )
		if f:
			flist=self.root.tk.splitlist(f) # http://psf.upfronthosting.co.za/roundup/tracker/issue5712 workaround: http://code.activestate.com/lists/python-tkinter-discuss/2016/
			if len(flist)>5:
				self.logger.info('一次最多添加5个文件,多余的会被丢弃,你选择了 %d个',len(flist))
				flist=flist[:5]
			for i,onefile in enumerate(flist):
				self.logger.debug('multi file %02d/%d: %s',i,len(flist),onefile)

			addorreplace=tkMessageBox.askyesnocancel('Add or replace','add the file(s) to your file list? (press "no" will replace current file list)',default=tkMessageBox.YES)
			self.logger.debug('addorreplace=%s',addorreplace)
			self.c.recent_dir=os.path.split(flist[0])[0]
			if addorreplace==None:
				self.logger.debug('do nothing')
			elif addorreplace==True: # add
				self.c.file.extend([i,0] for i in flist)
				# 更新filelist菜单
				for i in flist:
					self.cur_list_menu.add_radiobutton(label=os.path.basename(i),command=self.onCmdSwitchFile,
						value=i,variable=self.vFile)
				# 从recent中删除当前文件列表中存在的
				self.c.recent=[i for i in self.c.recent if i[0] not in (j[0] for j in self.c.file)]
				self.logger.debug('add done. new file list: %s',self.c.file)

			elif addorreplace==False: # replace
				if self.stat==const.StatPlaying:
					self.pausePanel(const.StatPaused4Switch)

				# 从recent中删除当前文件列表中存在的
				self.c.recent=[i for i in self.c.recent if i[0] not in (j[0] for j in self.c.file)]
				self.cur_list_menu.delete(0,len(self.c.file)-1) # 删掉filelist菜单
				# 当前文件列表入recent
				for t in reversed(self.c.file):
					self.c.recent.insert(0,t)
				del self.c.file[:]
				# 新文件入当前文件列表
				self.c.file.extend([[i,0] for i in flist])
				# 从recent中删除当前文件列表中存在的
				self.c.recent=[i for i in self.c.recent if i[0] not in (j[0] for j in self.c.file)]
				# 构造新filelist菜单
				self.c.cur=0
				for idx,i in enumerate(self.c.file):
					self.cur_list_menu.add_radiobutton(label=os.path.split(i[0])[1],command=self.onCmdSwitchFile,
						value=i[0],variable=self.vFile)
					if idx==self.c.cur:
						self.cur_list_menu.invoke(idx)
				self.logger.debug('replace done. new file list: %s\nnew recent: %s',self.c.file,self.c.recent)
开发者ID:liveonnet,项目名称:mytestzone,代码行数:54,代码来源:panels.py


示例12: okayToContinue

 def okayToContinue(self):
     reply = messagebox.askyesnocancel(
                "Saída",
                "Deseja salvar as alterações antes de sair?", parent=self)
     if reply is None:
         return False
     elif reply and len(self.nome.get()) > 0:
         self.salvar(self)
         return True
     else:
         return True
开发者ID:daleathan,项目名称:cadastro,代码行数:11,代码来源:cadastro.py


示例13: Clear_Program

 def Clear_Program (self, event = None):
     save = messagebox.askyesnocancel (title = "Save?", message = "Do you want to save this file?")
     #cancel
     if save == None:
         return
     #save file
     elif save == True:
         self.Save_Program()
     #don't save
     self.document_name = None
     self.root.title("Webpage")
     self.HTML_box.replace("1.0", "end", "")
开发者ID:JennaMcCarter,项目名称:Portfolio,代码行数:12,代码来源:Main.py


示例14: quit

 def quit(self):
     if self.settings_dirty.get() or self.project_dirty.get():
         savechanges = messagebox.askyesnocancel("Save changes", "You have unsaved project changes. Do you want to save them before quitting?")
         if savechanges is None:
             return
         elif savechanges:
             self.noask_save_project()
         self.master.destroy()
     else:
         # write gui settings and destroy
         self.write_gconfig()
         self.master.destroy()
开发者ID:bbferka,项目名称:pracmln,代码行数:12,代码来源:mlnquery.py


示例15: onClosing

    def onClosing(self):
        if self._modified:
            _choice = messagebox.askyesnocancel("Speichern/Beenden",
                                                "Vor dem Beenden speichern?")
            if _choice is False:
                pass
            elif _choice is True:
                self._saveAll()
            else:
                return False

        self._master.destroy()
开发者ID:hpcchkop,项目名称:schuhlager,代码行数:12,代码来源:binokel.py


示例16: check

 def check(self, master):
     if not self.view.changed():
         return True
     choice = messagebox.askyesnocancel(
         "I'm helping you",
         "Looks like you have changed things and not saved, do you want to now?",
         default=messagebox.CANCEL,
         icon=messagebox.QUESTION,
         parent=master)
     if choice == True:
         return self.save(master)
     else:
         return (choice == False) # If cancelled then will be None
开发者ID:andyrooger,项目名称:PuzzleSolver,代码行数:13,代码来源:puzzlesaver.py


示例17: close

 def close(self, *discard):
     logger.info("Closing")
     if self.text.edit_modified():
         logger.info("File has been modified and not saved")
         save = messagebox.askyesnocancel(title="Close file",
                                          message="File {} has unsaved changes. Save?".format(self.fname))
         if save is None:
             return False
         elif save is True:
             self.save()
         else:
             logger.warning("Changes not saved")
     return True
开发者ID:matsjoyce,项目名称:specter,代码行数:13,代码来源:codeeditor.py


示例18: on_closing

 def on_closing():
     if Pianokey.boo:
         answer = messagebox.askyesnocancel("Quit", "You're still recording! Do you want to save?")
         if answer == None:
             master.destroy()                
             return None
         elif answer:
             filewriter()
             master.destroy()
         else:
             master.destroy()
     else:
         master.destroy()
开发者ID:trishutiwari,项目名称:PythonFinalProject,代码行数:13,代码来源:gui2.py


示例19: wclose

    def wclose(self, event=0):
        if self.parent.title()[0] == "*":
            save = messagebox.askyesnocancel("Save file", "You have unsaved changes.\nDo you want to save before closing?")

            if save == True:
                self.save_file()
                if self.parent.title()[0] == "*":
                    self.wclose()
                else:
                    root.destroy()

            elif save == False:
                root.destroy()
        else:
            root.destroy()
开发者ID:ssebs,项目名称:greenBerry,代码行数:15,代码来源:gb_ide.py


示例20: fileOpen

def fileOpen(fvpTree):

    global curFilePath, curFileName,fileOptions, unsavedChanges
    newFilePath =()
    newCal = []
    visibleComps = []
    #1. Unsaved Changes
    if (unsavedChanges == 1):
        yN = messagebox.askyesnocancel(title = "Unsaved Changes",message = "You have Unsaved Changes. Would you like to save?")
        if(yN == None):
            return
        elif (yN == True):
            fileSave()

    
    #2. Open file
    fileOptions['title'] = 'Open'
    newFilePath = filedialog.askopenfilename(**fileOptions)
    if (len(newFilePath) != 0):

        newFileName = newFilePath[newFilePath.rfind('/')+1:]
        
        
        #3. Run Wrapper for readCalFile
        status = readAndDisplayComp(str(newFilePath),fvpTree)
        if (status == "OK"):
   
            callCalInfo(fvpTree.cal.pointer,fvpTree.cal.visibleComps)

            #Make menu options, fvp buttons and Change title bar
            fileMenu.entryconfigure('Save',state = NORMAL)
            fileMenu.entryconfigure('Save as...',state = NORMAL)
            fileMenu.entryconfigure('Combine...',state = NORMAL)
            fileMenu.entryconfigure('Filter...',state = NORMAL)
            toDoMenu.entryconfigure('To-do List...',state = NORMAL)
            exEvBut.configure(state = NORMAL)
            exXBut.configure(state = NORMAL)
            showSelBut.configure(stat = DISABLED)

            curFilePath = newFilePath
            curFileName = newFileName
            updateTitlebar("xcal - "+curFileName)
        else:
            status = "Failed to open \""+newFileName+"\"\n" + status
            writeToTextLog(textLog,"&SEP&")
            writeToTextLog(textLog,status)
开发者ID:Cikro,项目名称:BrickBreaker,代码行数:46,代码来源:xcal_noSQL.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python messagebox.showerror函数代码示例发布时间:2022-05-27
下一篇:
Python messagebox.askyesno函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap