--- nfo/projects/netfraggle/bin/fraggleDialogPrefs.py 2004/08/25 16:56:59 1.2 +++ nfo/projects/netfraggle/bin/fraggleDialogPrefs.py 2004/08/26 23:10:11 1.5 @@ -1,10 +1,13 @@ #Boa:Dialog:fraggleDialogPrefs from wxPython.wx import * +from fraggleEngine import * def create(parent): return fraggleDialogPrefs(parent) + + [wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE, wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSSTATICLINE1, wxID_FRAGGLEDIALOGPREFSSTATICLINE2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, @@ -30,15 +33,17 @@ self._init_utils() self.SetClientSize(wxSize(366, 188)) - self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE, label='Save', - name='btsave', parent=self, pos=wxPoint(8, 168), size=wxSize(64, - 16), style=0) + self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE, + label='Save and Close', name='btsave', parent=self, + pos=wxPoint(8, 168), size=wxSize(96, 16), style=0) EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE, self.OnBtsaveButton) self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1, - label='Cancel', name='button1', parent=self, pos=wxPoint(80, 168), - size=wxSize(56, 16), style=0) + label='Cancel', name='button1', parent=self, pos=wxPoint(112, + 168), size=wxSize(56, 16), style=0) + EVT_BUTTON(self.button1, wxID_FRAGGLEDIALOGPREFSBUTTON1, + self.OnButton1Button) self.staticText1 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, label='Username', name='staticText1', parent=self, pos=wxPoint(16, @@ -90,7 +95,35 @@ self._init_ctrls(parent) def OnBtsaveButton(self, event): - self.parent.preferencesCtl.setConfig(self.textCtrlUsername.GetValue(),self.textCtrlPassword.GetValue(), - self.textCtrlServer.GetValue(),self.textCtrlRetrieval.GetValue()) + + # convert from utf-8: required for win32 + import codecs + (UTF8_encode, UTF8_decode, + UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8') + self.parent.preferencesCtl.setConfig( + UTF8_encode(self.textCtrlUsername.GetValue())[0], + UTF8_encode(self.textCtrlPassword.GetValue())[0], + UTF8_encode(self.textCtrlServer.GetValue())[0], + UTF8_encode(self.textCtrlRetrieval.GetValue())[0] + ) + self.parent.preferencesCtl.saveConfig() + self.Hide() + event.Skip() + + def loadConfig(self): + engine = FraggleEngine() + prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') + self.parent.preferencesCtl.loadConfig(prefsfile) + + def updateConfig(self): + config = self.parent.preferencesCtl.getConfig() + self.textCtrlUsername.SetValue(config["username"]) + self.textCtrlPassword.SetValue(config["password"]) + self.textCtrlServer.SetValue(config["url"]) + self.textCtrlRetrieval.SetValue(config["retrieval"]) + + def OnButton1Button(self, event): + self.Hide() event.Skip() + \ No newline at end of file