Using "preferences"

Suppose my entry point is:

class MyApp( wx.App ):
    def OnInit(self):
        #read in config?
        #set wx.App.myConfigData?
        frame = MyFirstFrame(None,"Some title")
        frame.Show(True)
        self.SetTopWindow(frame)

So this is where to read in the initial prefs into (e.g.) a dict, then have the Preferences panel modify that dict and have the various logic throughout the app use it as well...

If I'm mistaken, please stop me before I hurt myself =) Otherwise, thanks for this very helpful pointer.

···

-----Original Message-----
From: Henning.Ramm@mediapro-gmbh.de
[mailto:Henning.Ramm@mediapro-gmbh.de]
Sent: Thursday, June 30, 2005 1:38 PM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] Using "preferences"

>Hmm... Actually, that could work out, if I understand it
>correctly. I've never had occasion to use wx.App before
>
>So every class that is part of an application shares a wx.App
>object? And as such, I can have references to
>wx.GetApp().objPrefs that all point to the same Prefs object,
>regardless of which class is referring to it?
>
>I'm gonna try it out while I wait with bated breath for a response.

Inherit your main class from wx.App and create the main frame
of your app in this class' __init__.
Call your config reader also in this __init__. Perhaps make
your own config class (perhaps derived from dict) that can
read & write a (XML) file.

I'd send you my code, but it does a lot of stuff that will
only confuse you (it's a two-step inherited twisted+wx app
class that keeps a proxy database connection, keeps track of
running processes etc.), and it would be a lot of work to
sort that out.

Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org

Maybe I misunderstand your goals, but this sounds like a job for wx.Config()

class MyApp( wx.App ):
    def OnInit(self):
        self.SetVendor('me')
        self.SetApplication('myprogram')
        config = wx.Config()
        title_setting = config.Read('Title', "Some title")
        frame = MyFirstFrame(None,title_setting)
        frame.Show(True)
        self.SetTopWindow(frame)

# viola, it is really that simple.
# you can do confg = wx.Config() anywhere in your app. Given that the app
# has vendor and application properties set the same, it will access the same
# config file/registry.

Levis, Chris wrote:

···

Suppose my entry point is:

class MyApp( wx.App ):
   def OnInit(self):
       #read in config?
       #set wx.App.myConfigData?
       frame = MyFirstFrame(None,"Some title")
       frame.Show(True)
       self.SetTopWindow(frame)

So this is where to read in the initial prefs into (e.g.) a dict, then have the Preferences panel modify that dict and have the various logic throughout the app use it as well...

If I'm mistaken, please stop me before I hurt myself =) Otherwise, thanks for this very helpful pointer.

-----Original Message-----
From: Henning.Ramm@mediapro-gmbh.de [mailto:Henning.Ramm@mediapro-gmbh.de] Sent: Thursday, June 30, 2005 1:38 PM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] Using "preferences"

Hmm... Actually, that could work out, if I understand it correctly. I've never had occasion to use wx.App before

So every class that is part of an application shares a wx.App object? And as such, I can have references to wx.GetApp().objPrefs that all point to the same Prefs object, regardless of which class is referring to it?

I'm gonna try it out while I wait with bated breath for a response.
     

Inherit your main class from wx.App and create the main frame of your app in this class' __init__.
Call your config reader also in this __init__. Perhaps make your own config class (perhaps derived from dict) that can read & write a (XML) file.

I'd send you my code, but it does a lot of stuff that will only confuse you (it's a two-step inherited twisted+wx app class that keeps a proxy database connection, keeps track of running processes etc.), and it would be a lot of work to sort that out.

Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org