在我的程序中,我有一个烦人的弹出窗口,提醒用户去检查设置。我有一个复选框,如果选中,则应该永远不会再显示弹出窗口。我不知道该怎么做。选中复选框后,我需要程序向名为 tog_file.txt 的文本文件写入“true”。如果 tog_file.txt 中的文本为 true,则弹出窗口将永远不会再显示。代码:
def reminder():
global tog
tog = open("tog_file.txt", "r+b")
tog_r = tog.read()
if tog_r == "true":
print "true"
if tog_r == "":
global reminder
reminder = gtk.Window(gtk.WINDOW_TOPLEVEL)
reminder.set_position(gtk.WIN_POS_CENTER)
reminder.set_size_request(450, 205)
reminder.set_title("Info")
textbox = gtk.Label("Remember To Go Into The Settings Menu! There are Important Settings that Need to be Reviewed by you!")
textbox.set_justify(gtk.JUSTIFY_CENTER)
textbox.set_line_wrap(True)
button = gtk.Button("Close")
button.connect("clicked", reminder_close)
toggle = gtk.CheckButton("Don't Show This Message Again")
item_text = toggle.get_active()
if item_text == False:
print "no"
if item_text == True:
print "yea"
tog.write("true")
fixed = gtk.Fixed()
fixed.put(button, 300, 160)
fixed.put(toggle, 50, 165)
fixed.put(textbox, 50, 50)
reminder.add(fixed)
reminder.show_all()
def reminder_close(self):
reminder.destroy()
如果您需要任何其他信息,请发表评论。感谢 StackOverflow :)