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

Python messagebox.askokcancel函数代码示例

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

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



在下文中一共展示了askokcancel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:codetestcode,项目名称:pygubu,代码行数:34,代码来源:main.py


示例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文件')
开发者ID:wujunwei,项目名称:PythonTest,代码行数:25,代码来源:transform.py


示例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)
开发者ID:william1616,项目名称:WeakestLink,代码行数:9,代码来源:control.py


示例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('结果提示', '整理完毕')
开发者ID:DaniuLi,项目名称:hello,代码行数:10,代码来源:FilesSort.py


示例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()
开发者ID:Dabrill,项目名称:HaworthLab,代码行数:12,代码来源:GuiUber.py


示例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'")
开发者ID:MANA624,项目名称:MiscRep,代码行数:27,代码来源:DiscipleReading.py


示例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()
开发者ID:aledruetta,项目名称:vocapy,代码行数:7,代码来源:vocapy.py


示例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()
开发者ID:Coolasp1e,项目名称:BEE2.4,代码行数:31,代码来源:optionWindow.py


示例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()
开发者ID:muddyfish,项目名称:PPCG-Life,代码行数:7,代码来源:nice_gui.py


示例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()
开发者ID:DaZhu,项目名称:pygubu,代码行数:26,代码来源:main.py


示例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()
开发者ID:r01k,项目名称:Tic_Tac_Toe,代码行数:34,代码来源:board.py


示例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
开发者ID:Sodel-the-Vociferous,项目名称:NoteBag,代码行数:32,代码来源:NoteBag.py


示例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
开发者ID:adorableGNU,项目名称:pyBristol,代码行数:7,代码来源:pyBristol.py


示例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))
开发者ID:JannickWeisshaupt,项目名称:BankingAccountManager,代码行数:27,代码来源:main.py


示例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
开发者ID:WormGush,项目名称:Backup_Gui,代码行数:32,代码来源:main.py


示例16: apply_changes

def apply_changes():
    values_changed = any(
        item.package.enabled != item.state
        for item in
        pack_items.values()
    )
    if not values_changed:
        # We don't need to do anything!
        window.withdraw()
        window.grab_release()
        return

    if messagebox.askokcancel(
            title=_('BEE2 - Restart Required!'),
            message=_('Changing enabled packages requires a restart.\nContinue?'),
            master=window,
            ):
        window.withdraw()
        window.grab_release()
        for item in UI['details'].items:
            pack = item.package
            if pack.id != packageLoader.CLEAN_PACKAGE:
                pack.enabled = item.state
        PACK_CONFIG.save_check()
        utils.restart_app()
开发者ID:BenVlodgi,项目名称:BEE2.4,代码行数:25,代码来源:packageMan.py


示例17: callback

 def callback(e):
     if askokcancel(
         title='BEE2 - Open URL?',
         message=_('Open "{}" in the default browser?').format(url),
         parent=self,
     ):
         webbrowser.open(url)
开发者ID:BenVlodgi,项目名称:BEE2.4,代码行数:7,代码来源:richTextBox.py


示例18: timer_event

def timer_event():
    global scores_value, scores_text, number_of_shots, shoots, best_scores, gun

    # проверяем на столкновение снаряда с каждым шариком
    for shell in shells_on_fly:
        for ball in balls:
            # d1 - расстояние между центром снаряда и шарика
            d1 = sqrt((shell._x + shell._R - ball._x - ball._R)**2 + (shell._y + shell._R - ball._y - ball._R)**2)
            d2 = shell._R + ball._R
            if d1 <= d2:
                ball.explode()
                shell.explode()
                scores_value.set(scores_value.get()-1)
    scores_text["textvariable"]=scores_value
    number_of_shots["text"] = 'Выстрелов: '+str(shoots)

    if scores_value.get() == 0:
        scores_value.set(Ball.initial_number)
        if best_scores > shoots:
            best_scores = shoots
        canvas.delete(gun._avatar)
        if messagebox.askokcancel("Итоги игры", 'Потрачено снарядов:'+str(shoots)+'\nЛучший результат:'+str(best_scores)+'\nСыграем ещё?'):
            reset_game()
        else:
            root.destroy()

    for ball in balls:
        ball.fly()
    for shell in shells_on_fly:
        shell.fly()

    canvas.after(timer_delay, timer_event)
开发者ID:MihaiDibani,项目名称:KPK-Python2016,代码行数:32,代码来源:gun.py


示例19: askroot

 def askroot(self):
   dir=filedialog.askdirectory(title="Select Comcraft Source Directory",mustexist=True, initialdir=self.ccdir)
   if dir and os.path.exists(os.path.join(dir,"net\\comcraft\\src")):
     self.config.merge('settings',{'comcraft_root':dir.replace('/','\\')})
   else:
     if messagebox.askokcancel("Not found","Could not locate source, reselect folder?"):
       self.askroot()
开发者ID:MassimoS,项目名称:ComcraftModLoader,代码行数:7,代码来源:CCMLGen.py


示例20: removeComponent

    def removeComponent(_id):
        if MyInventory.component_items[_id][0] != None:
            uses_left = int(MyInventory.component_items[_id][1].uses)
            item_name = MyInventory.component_items[_id][1].name
            
            msg = 'Move "' + item_name + '" to your inventory?'
            if uses_left == 0:
                msg = 'WARNING: 0 uses are left for "' + item_name + \
                      '", this item will be deleted.' 
            answer = messagebox.askokcancel("Remove Active Component Item", msg)

            if answer:
                MyInventory.component_effects.pop(MyInventory.component_items[_id][1].item_type, None)
                MyInventory.api.unequip_item(MyInventory.component_items[_id][1])
                MyInventory.component_items[_id][0].destroy()
                MyInventory.component_items[_id][0] = None

                MyInventory.my_inventory.addItem(MyInventory.component_items[_id][1])
                MyInventory.api.set_active(MyInventory.component_items[_id][1], 'False')
 
                # shift all items to the left on the gui if any visual node gaps
                for i in range(_id+1, MyInventory.max_components, 1):
                    if MyInventory.component_items[i][0] != None:
                        MyInventory.resetComponent(MyInventory.component_items[i][1], i)
                        MyInventory.component_items[i][0].destroy()
                        MyInventory.component_items[i][0] = None
                        
                if MyInventory.components_count > 0:
                    MyInventory.components_count -= 1
开发者ID:MSU-CS-Software-Engineering,项目名称:habitgame,代码行数:29,代码来源:inventory.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python messagebox.askquestion函数代码示例发布时间:2022-05-27
下一篇:
Python font.Font类代码示例发布时间: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