【发布时间】:2016-07-30 11:34:05
【问题描述】:
我想要一个带有“不再显示”的窗口(顶层窗口)。如果选中此框,我不希望它再次显示此窗口。
import configparser
from tkinter import *
config = configparser.RawConfigParser() #my ini file
config.add_section('Section1')
config.set('Section1', 'a_bool', 'False')
with open('settings.ini', 'w') as configfile:
config.write(configfile)
root = Tk()
def var_states(): #write to ini file
global mt
print(config.read('ayrlar.ini'))
if var1 == True:
config.set('Section1', 'a_bool', 'True')
with open('settings.ini', 'w') as configfile:
config.write(configfile)
global window
window.destroy()
elif var1 == False:
config.set('Section1', 'a_bool', 'False')
with open('settings.ini', 'w') as configfile:
config.write(configfile)
global window
window.destroy()
var1 = config.getboolean('Section1', 'a_bool')
def show(): #if checkbox is true
global window #dont show
window= Toplevel(root)
Checkbutton(window, text="Don't show me again", variable=var1).place(x=0, y=0)
Button(window, text='Okey', command=var_states).place(x=0, y=25)
root.after(10,show)
root.mainloop()
再次运行时,我不想显示此窗口。我如何使用ConfigParser 做到这一点?
【问题讨论】:
-
Stack Overflow 不是代码编写服务。
-
你可以看到我的代码我只想要我的代码问题为什么不工作
标签: python tkinter configparser