第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在關(guān)閉python應(yīng)用程序的事件中附加方法?

如何在關(guān)閉python應(yīng)用程序的事件中附加方法?

函數(shù)式編程 2021-05-14 16:12:27
我需要解決以下面臨的問題。我有一個Tkinter UI,其中有3個按鈕(“注冊”,“鎖定文件夾”和“解鎖文件夾”)。與所有應(yīng)用程序一樣,右上角有一個十字按鈕。請參考以下快照。因此,想法是,當用戶通過此UI解鎖其文件夾,然后按下十字按鈕時,必須關(guān)閉該文件夾以及該用戶可能已打開的所有文件夾內(nèi)容。下面是關(guān)閉文件夾的代碼。def lockFolder_crossButton():    if userName.get()!='':      answer_folder = getFolderName()     #####check if the folder has already been locked or not!!!!*********      if os.path.exists('./secretFolder/'+userName.get()):          LockFolder.lockFolders(userName.get(), answer_folder)    global timer_active    timer_active = 'no'    window.destroy()上面的代碼存在于類“ openApplication.py”中,該類在運行該應(yīng)用程序時啟動。以下Faceface.launch.pyw類的代碼導(dǎo)入此類。#!python2.7import sys, osscriptdir, script = os.path.split(__file__)pkgdir = os.path.join(scriptdir, 'pkgs')sys.path.insert(0, pkgdir)os.environ['PYTHONPATH'] = pkgdir + os.pathsep + os.environ.get('PYTHONPATH', '')# APPDATA should always be set, but in case it isn't, try user home# If none of APPDATA, HOME, USERPROFILE or HOMEPATH are set, this will fail.appdata = os.environ.get('APPDATA', None) or os.path.expanduser('~')if 'pythonw' in sys.executable:    # Running with no console - send all stdstream output to a file.    kw = {'errors': 'replace'} if (sys.version_info[0] >= 3) else {}    sys.stdout = sys.stderr = open(os.path.join(appdata, script+'.log'), 'w', **kw)else:    # In a console. But if the console was started just for this program, it    # will close as soon as we exit, so write the traceback to a file as well.    def excepthook(etype, value, tb):        "Write unhandled exceptions to a file and to stderr."        import traceback        traceback.print_exception(etype, value, tb)        with open(os.path.join(appdata, script+'.log'), 'w') as f:            traceback.print_exception(etype, value, tb, file=f)    sys.excepthook = excepthookif __name__ == '__main__':    from openApplication import self    self那么,有什么想法要解決的嗎?您如何建議解決該問題?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 126 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號