Saving the application's state
Many applications provide some functionality that remembers the window size, location, and other visual settings that a user may have left the UI in during its last usage. Adding such a feature can be accomplished in different ways. The wx.lib
package provides a PersistentControls
library that can be used to store the state of a window and its child controls to a file and can then restore the state to the controls at the next launch of the application. In this recipe, we will take a look at how to integrate PersistentControls
into an application.
How to do it…
Here are the steps that you need to perform:
First, we will define our app's
App
object and setAppName
:import wx import wx.lib.agw.persist as PERSIST class MyApp(wx.App): def OnInit(self): self.SetAppName("PersistControls") self.frame = MyFrame(None, title="Save State") self.frame.Show() return True
Next, we will make a
Panel
for the app's main window that has a couple...