本文整理汇总了Python中tkinter.messagebox.askokcancel函数的典型用法代码示例。如果您正苦于以下问题:Python askokcancel函数的具体用法?Python askokcancel怎么用?Python askokcancel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了askokcancel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_file_menuitem_clicked
def on_file_menuitem_clicked(self, itemid):
if itemid == 'file_new':
new = True
if self.is_changed:
new = openfile = messagebox.askokcancel( _('File changed'),
_('Changes not saved. Discard Changes?') )
if new:
self.previewer.remove_all()
self.tree_editor.remove_all()
self.properties_editor.hide_all()
self.currentfile = None
self.is_changed = False
self.project_name.configure(text=_('<None>'))
elif itemid == 'file_open':
openfile = True
if self.is_changed:
openfile = messagebox.askokcancel(_('File changed'),
_('Changes not saved. Open new file anyway?'))
if openfile:
options = { 'defaultextension': '.ui',
'filetypes':((_('pygubu ui'), '*.ui'), (_('All'), '*.*')) }
fname = filedialog.askopenfilename(**options)
if fname:
self.load_file(fname)
elif itemid == 'file_save':
if self.currentfile:
if self.is_changed:
self.do_save(self.currentfile)
else:
self.do_save_as()
elif itemid == 'file_saveas':
self.do_save_as()
elif itemid == 'file_quit':
self.quit()
示例2: dump
def dump(element):
path_ = path.get()
if path_ == '':
return
file_type = os.path.splitext(path_)[1]
call = callable_arr.get(file_type)
try:
arr = call(path_)
except Exception as e:
print(e)
messagebox.askokcancel('error', '不支持该文件类型')
return
if element == 'json':
content = json.dumps(arr, sort_keys=True)
with open(os.path.dirname(path_)+r'\target.json', 'w+') as f:
f.write(content)
messagebox.askyesno('成功', '转换成功!请查找target文件')
elif element == 'php':
php_str = '<?php \n' \
'return '
php_str = php_str + dump_php(arr) + ';'
with open(os.path.dirname(path_)+r'\target.php', 'wb') as f:
f.write(php_str.encode())
messagebox.askyesno('成功', '转换成功!请查找target文件')
示例3: toggleContestant
def toggleContestant(contestantClass):
global socket, voteTopLevel
disableButton() #disable all button presses
if contestantClass.uuid in [contestant.uuid for contestant in contestantList]: #if the given contestant class is in the list of contestants (ie if they are in the game) send a message to the server to remove the contestant from the game
if messagebox.askokcancel("Confirm", "Remove " + contestantClass.name + " from the Game?", parent=voteTopLevel): #confirm the user wants to remove the contetant from the game
network.sendMessage("removeContestant", contestantClass.uuid, socket)
else: #if the given contestantClass is not in the game send a message to the server to add the contestant to the game
if messagebox.askokcancel("Confirm", "Re-add " + contestantClass.name + " to the Game?", parent=voteTopLevel): #confirm the user wants to re-add the contestnt to the game
network.sendMessage("addContestant", contestantClass.uuid, socket)
示例4: sort
def sort():
logging.info("=============Sort job go!=================")
logText.delete(1.0, END)
logText.insert(END, '================go!====================\n')
sort_files(srcPath.get())
logging.info("=============Sort job done!=================\n")
logText.insert(END, '================done!====================\n')
logText.see(END)
messagebox.askokcancel('结果提示', '整理完毕')
示例5: removeLine
def removeLine(self,event):
index = self.listbox.curselection()[0]
selection = self.listbox.get(index)
if (index > 0):
confirmed = messagebox.askokcancel("Confirm","Remove Run %s?"%selection)
if confirmed:
self.listbox.delete(index)
else:
confirmed = messagebox.askokcancel("Halt Run While In Process?","Halt Run %s?"%selection)
if confirmed:
self.listbox.delete(index)
self.abort()
示例6: uninstall
def uninstall():
Tk().withdraw()
if messagebox.askokcancel("No Going Back!", "Uninstalling will remove the program "
"and all files from your computer!"):
try:
os.remove(path + "\DiscRead\Temp.txt")
except FileNotFoundError:
pass
try:
os.remove(path + "\DiscRead\Results.txt")
except FileNotFoundError:
pass
try:
os.remove(path + "\DiscRead\Info.txt")
except FileNotFoundError:
pass
try:
shutil.rmtree(path + "\DiscRead")
except FileNotFoundError:
pass
try:
shutil.move("DiscipleReading.exe", path + "\DiscipleReading.exe")
sys.exit(0)
except FileNotFoundError:
Tk().withdraw()
messagebox.showerror("Sorry!", "We are still working on finding a solution to uninstallation, but you'll"
"have to delete it manually in the meantime!. Please refer to 'Help'")
示例7: clear
def clear(self):
m = _('Está seguro de que quiere eliminar el diccionario?')
t = _('Eliminar Diccionario')
if messagebox.askokcancel(t, m, default='cancel', parent=self):
self.word_list.clear()
self.practice()
示例8: clear_caches
def clear_caches():
"""Wipe the cache times in configs.
This will force package resources to be extracted again.
"""
import gameMan
import packageLoader
restart_ok = messagebox.askokcancel(
title='Allow Restart?',
message='Restart the BEE2 to re-extract packages?',
)
if not restart_ok:
return
for game in gameMan.all_games:
game.mod_time = 0
game.save()
GEN_OPTS['General']['cache_time'] = '0'
for pack_id in packageLoader.packages:
packageLoader.PACK_CONFIG[pack_id]['ModTime'] = '0'
save() # Save any option changes..
gameMan.CONFIG.save_check()
GEN_OPTS.save_check()
packageLoader.PACK_CONFIG.save_check()
utils.restart_app()
示例9: pull_answers
def pull_answers(self):
msg = """This will disconnect all manual answers from the controller
They will have to be readded in order to select them"""
if messagebox.askokcancel("Pull Answers?", msg):
self.answers = get_answers.pull()
self.root_frame.destroy()
self.add_root_widgets()
示例10: on_edit_menuitem_clicked
def on_edit_menuitem_clicked(self, itemid):
if itemid == 'edit_item_up':
self.tree_editor.on_item_move_up(None)
elif itemid == 'edit_item_down':
self.tree_editor.on_item_move_down(None)
elif itemid == 'edit_item_delete':
do_delete = messagebox.askokcancel(_('Delete items'),
_('Delete selected items?'))
if do_delete:
self.tree_editor.on_treeview_delete_selection(None)
elif itemid == 'edit_copy':
self.tree_editor.copy_to_clipboard()
elif itemid == 'edit_paste':
self.tree_editor.paste_from_clipboard()
elif itemid == 'edit_cut':
self.tree_editor.cut_to_clipboard()
elif itemid == 'grid_up':
self.tree_editor.on_item_grid_move(WidgetsTreeEditor.GRID_UP)
elif itemid == 'grid_down':
self.tree_editor.on_item_grid_move(WidgetsTreeEditor.GRID_DOWN)
elif itemid == 'grid_left':
self.tree_editor.on_item_grid_move(WidgetsTreeEditor.GRID_LEFT)
elif itemid == 'grid_right':
self.tree_editor.on_item_grid_move(WidgetsTreeEditor.GRID_RIGHT)
elif itemid == 'edit_preferences':
self._edit_preferences()
示例11: confirm_quit
def confirm_quit(self):
winsound.PlaySound("SystemQuestion", winsound.SND_ASYNC)
if messagebox.askokcancel("Quit", "Do you want to quit?"):
# Prevents an exception if the boaster window has already been closed.
try:
self.hist_score_window.destroy_me()
except:
pass
if int(self.user_score.get()) > 0 or int(self.machine_score.get()) > 0:
empty = False
historic_score = open("histcore.dat", "rb")
try:
score = pickle.load(historic_score)
except EOFError:
empty = True
historic_score.close()
historic_score = open("histcore.dat", "wb")
if not empty:
pickle.dump([int(self.user_score.get()) + score[0],
int(self.machine_score.get()) + score[1]], historic_score)
else:
score = open("histcore.dat", "wb")
pickle.dump([int(self.user_score.get()), int(self.machine_score.get())], score)
historic_score.close()
file_name = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, None, 0) +\
"\Tic Tac Toe Score " + datetime.datetime.now().strftime\
("%Y-%m-%d_%H.%M.%d") + ".txt"
score_file = open(file_name, "w")
score_file.writelines(self.user_name + ": " + self.user_score.get() +
"\nMACHINE: " + self.machine_score.get())
score_file.close()
tkinter.messagebox.showinfo("Score", "Current score was saved to your Desktop")
self.main_window.destroy()
示例12: maybe_first_time_setup
def maybe_first_time_setup():
"""
Set up the user's notes directory/folder the first time they run
NoteBag.
Returns False if it failed, or needs to try again; returns True if
it succeeds, or doesn't need to happen at all.
"""
if not os.path.isfile(get_config_path(CONFIG_FILENAME)):
shutil.copy2(get_config_path(TEMPLATE_CONFIG_FILENAME),
get_config_path(CONFIG_FILENAME))
config = read_config(CONFIG_FILENAME)
if config.get("NoteBag", "Notes Directory"):
return True
if not messagebox.askokcancel(
"NoteBag Setup",
"Hi! It looks like this is your first time running NoteBag!\n"
"Please choose the folder where you would like NoteBag to keep your notes."
):
return False
notes_dir = filedialog.askdirectory(title="Notes Folder")
print(notes_dir)
if not notes_dir:
return False
config.set("NoteBag", "Notes Directory", notes_dir)
save_config(config, CONFIG_FILENAME)
return True
示例13: exitAll
def exitAll(self):
mExit = messagebox.askokcancel(title="Exit", message="pyBristol will exit now...")
if mExit > 0:
self.stopBristol()
self.bGui.destroy()
sys.exit()
return
示例14: import_csv
def import_csv(self):
OpenFilename = filedialog.askopenfilename(initialdir='./csv',
filetypes=[('CSV Datenbank', '.csv'), ('all files', '.*')])
if len(OpenFilename) == 0:
return
try:
main_auftragkonto_load = sd.get_main_auftragskonto(OpenFilename)
except Exception as ex1:
messagebox.showerror('Fehler beim Importieren',
'Importieren ist mit Fehler ' + repr(ex1) + ' fehlgeschlagen')
if main_auftragkonto_load != self.main_auftragskonto and self.main_auftragskonto is not None:
if not messagebox.askokcancel('Sicherheitsabfrage',
'Kontonummer des CSVs stimmt nicht mit bestehenden Daten überein. Trotzdem fortfahren?'):
return
try:
info = sd.load_data(OpenFilename)
except Exception as ex1:
messagebox.showerror('Fehler beim Importieren',
'Importieren ist mit Fehler ' + repr(ex1) + ' fehlgeschlagen')
self.EF1.first_plot_bool = True
q1.put('Update Plot')
messagebox.showinfo('Import Bericht',
'Eine csv Datei mit {Csv size} Einträgen wurde geladen. {#Duplicate} davon waren schon vorhanden und {#Imported} neue Einträge wurden importiert. Die Datenbank enthält nun {New size} Einträge'.format(
**info))
示例15: mhello
def mhello(dst, src):
name = mdst.get()
for i in range(len(illegalchars)):
name = name.replace(illegalchars[i],"_")
print(name)
if len(dst) <= 0 or len(name) <=0:
messagebox.showwarning("YO YOU MADE A MISTAKE $$$", "Your destination folder has to have a path and name!")
elif os.path.exists(dst + "\\" + name):
e = True
i = 1
while e:
if os.path.exists(dst+ "\\" +name+ str(i)):
i = i + 1
else:
e = False
if messagebox.askokcancel("Ya dingus!", "That folder already exists! \nRename to " + name + "("+ str(i) +")?"):
name = name + str(i)
print(name)
#e = None
#else:
#print("Copying from: "+ src + " To: "+ dst+ "\\" + name)
dst = dst + "\\" + name
print(dst)
try:
shutil.copytree(src, dst)
messagebox.showwarning("Alert", "Your backup has completed")
except:
messagebox.showwarning("Lazy error message", """Your folder name was invalid idk why lol,
try avoiding \"/ \ * ? : < > | \" ya dingus """)
return