Search code examples
pythongtkgladegedit

How can I stop a function from loading if a check box is ticked in GTK Python


I am writing a program with a main menu, and several buttons that open different windows of the application. After the main menu pops up, I have rigged the code so that a popup window comes up right on top of the main menu. The popup tells you to visit the settings menu, and gives you a checkbox that says "Don't show this window again". The idea is that if you tick that box, the popup will never popup again. The popup window is a function called reminder(). Early on in the program I call the reminder() function to get it to popup. The checkbox is linked to a function called reminder_toggled(). I need to know how I would write the reminder_toggled() function to make sure that the reminder() function does not run ever again. If any additional info is required just post a comment, I'll be checking this post every 5 minutes.

Thanks StackOverflow :)


Solution

  • Instead of calling reminder_toggled() function whenever the checkbox (say reminder_checkbox) is toggled, reminder() function should first check whether the reminder_checkbox is checked before executing further

    def reminder():
        if reminder_checkbox.get_active():
            .
            .
            .
    

    (get_active() documentation)

    Moreover, the reminder_checkbox's state should be stored in a config file on exit & loaded on startup of app.