我需要解决以下面临的问题。
我有一个Tkinter UI,其中有3个按钮(“注册”,“锁定文件夹”和“解锁文件夹”)。与所有应用程序一样,右上角有一个十字按钮。请参考以下快照。
因此,想法是,当用户通过此UI解锁其文件夹,然后按下十字按钮时,必须关闭该文件夹以及该用户可能已打开的所有文件夹内容。
下面是关闭文件夹的代码。
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”中,该类在运行该应用程序时启动。
以下Faceface.launch.pyw类的代码导入此类。
#!python2.7
import sys, os
scriptdir, 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 = excepthook
if __name__ == '__main__':
from openApplication import self
self
那么,有什么想法要解决的吗?您如何建议解决该问题?
相关分类