Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where clicking Cancel in the Preferences dialog does not reset widgets #138

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

jrezai
Copy link
Contributor

@jrezai jrezai commented Jul 20, 2022

This pull request fixes a bug in the Preferences window where Preferences changes are not 'cancelled' when the Cancel button is clicked.

How to reproduce the bug:

  1. Open the Preferences window
  2. Make a change (any change).
    For example, change the default layout manager to something else
  3. Click the Cancel button.
  4. Re-open the Preferences window.
  5. You'll notice that the setting that you changed was not cancelled.

This puts the Preferences window into an asynchronous state, meaning that the setting was technically not saved (if you close and re-open Pygubu Designer, you'll notice that the setting was not actually saved, which is good). But the preferences window now reflects an incorrect state until you restart Pygubu Designer.

Similarly, when a custom widget .py file gets added to the list (or removed from the list), clicking on 'Cancel' and re-opening the Preferences window will not show the original custom widget list.

Why this bug occurs:

The widgets in the Preferences window are tied to Tk variables. So when the user interacts with any of the widgets, the Tk variables are immediately changed, so even when the user clicks Cancel, the Tk variables have already been changed at that point.

What this pull request does:

Change # 1)
Now when the Cancel button gets clicked (or if the user closes the window from the window manager), it will restore the Tk variables back to what they were before the changes that were made by the user. Similarly, it will now restore the custom widgets list to what it was before the user made any changes to it.

Change # 2)
In the Preferences dialog: when the Preferences dialog closes (Cancel or OK), any combo boxes that had focus will no longer have their text selected/highlighted the next time the preferences window opens. This is primarily a cosmetic/design change.

For example, right now if you the Preferences window and change the default layout manager, click OK.
When you re-open the Preferences window, that combo box will have its text highlighted/selected. This pull request will prevent the combo box from having its text selected when the Preferences dialog opens.

@alejandroautalan
Copy link
Owner

Great! Thank You Jobin for your support.

@alejandroautalan alejandroautalan merged commit e18e1c3 into alejandroautalan:master Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants