1 #!/usr/bin/python3
   2 # -*- coding: utf-8 -*-
   3 # see also:  https://wxpython.org/Phoenix/docs/html/wx.lib.agw.persist.html#persistent-overview
   4 import sys
   5 if __name__ == '__main__':
   6     import wx , os
   7     import wx.lib.agw.persist as PM
   8 
   9     class xf(wx.Frame):
  10         def __init__(self, parent):
  11             wx.Frame.__init__(self, parent, -1, " window maintains size and position after restart ")
  12 
  13             self.Bind(wx.EVT_CLOSE, self.OnClose)
  14 
  15             self._persistMgr = PM.PersistenceManager.Get()
  16             _configFile = os.path.join(os.getcwd(), "persist-saved-cfg")    # getname()
  17             self._persistMgr.SetPersistenceFile(_configFile)
  18             if not self._persistMgr.RegisterAndRestoreAll(self): print (" no workie  ")
  19 
  20         def OnClose(self, event):
  21             self._persistMgr.SaveAndUnregister()
  22             event.Skip()
  23 
  24     a = wx.App()
  25     f = xf(None)
  26     selff  =f
  27     parenta=a
  28 
  29     p=a.Traits.StandardPaths.Get()
  30     print  (str(                         wx.GetUserHome()                  )) #  /home/...
  31     print  (str(                         wx.StandardPaths.GetDataDir(p)    )) #  /usr/share/main
  32     uh=  wx.GetUserHome()
  33     dd=  wx.StandardPaths.GetDataDir(p)  # this .py src works with python3 as well as python2
  34 
  35     f.Show    ()
  36     a.MainLoop()


CategoryHomepage

persist (last edited 2017-06-19 18:20:52 by ffx)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.