/[cvs]/nfo/projects/netfraggle/bin/fraggleDialogPrefs.py
ViewVC logotype

Diff of /nfo/projects/netfraggle/bin/fraggleDialogPrefs.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by xabbu, Wed Aug 25 13:53:48 2004 UTC revision 1.13 by xabbu, Sat Sep 4 20:26:01 2004 UTC
# Line 1  Line 1 
1  #Boa:Dialog:wxDialog1  #Boa:Dialog:fraggleDialogPrefs
2    
3  from wxPython.wx import *  from wxPython.wx import *
4    from fraggleEngine import *
5    
6    import FraggleDialogModules
7    
8  def create(parent):  def create(parent):
9      return wxDialog1(parent)      return fraggleDialogPrefs(parent)
10    
 [wxID_WXDIALOG1, wxID_WXDIALOG1BTSAVE, wxID_WXDIALOG1BUTTON1,  
  wxID_WXDIALOG1STATICLINE1, wxID_WXDIALOG1STATICLINE2,  
  wxID_WXDIALOG1STATICTEXT1, wxID_WXDIALOG1STATICTEXT2,  
  wxID_WXDIALOG1STATICTEXT3, wxID_WXDIALOG1STATICTEXT4,  
  wxID_WXDIALOG1STATICTEXT5, wxID_WXDIALOG1TEXTCTRLPASSWORD,  
  wxID_WXDIALOG1TEXTCTRLRETRIEVAL, wxID_WXDIALOG1TEXTCTRLSERVER,  
  wxID_WXDIALOG1TEXTCTRLUSERNAME,  
 ] = map(lambda _init_ctrls: wxNewId(), range(14))  
11    
 class wxDialog1(wxDialog):  
     def _init_utils(self):  
         # generated method, don't edit  
         pass  
12    
13    [wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE,
14     wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSBUTTONMODULES,
15     wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
16     wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
17     wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, wxID_FRAGGLEDIALOGPREFSBUTTONTEST,
18     wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,
19     wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,
20     wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5,
21     wxID_FRAGGLEDIALOGPREFSSTATICTEXT6, wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,
22     wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL,
23     wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,
24     wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,
25    ] = map(lambda _init_ctrls: wxNewId(), range(19))
26    
27    class fraggleDialogPrefs(wxDialog):
28      def _init_ctrls(self, prnt):      def _init_ctrls(self, prnt):
29          # generated method, don't edit          # generated method, don't edit
30          wxDialog.__init__(self, id=wxID_WXDIALOG1, name='', parent=prnt,          wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS,
31                pos=wxPoint(344, 319), size=wxSize(366, 188),                name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(482, 310),
32                style=wxDEFAULT_DIALOG_STYLE, title='Netfraggle Preferences')                size=wxSize(374, 260), style=wxDEFAULT_DIALOG_STYLE,
33          self._init_utils()                title='Netfraggle Preferences')
34          self.SetClientSize(wxSize(366, 188))          self.SetClientSize(wxSize(366, 233))
35    
36          self.btsave = wxButton(id=wxID_WXDIALOG1BTSAVE, label='Save',          self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE,
37                name='btsave', parent=self, pos=wxPoint(8, 168), size=wxSize(64,                label='Save  and Close', name='btsave', parent=self,
38                16), style=0)                pos=wxPoint(8, 208), size=wxSize(96, 16), style=0)
39            EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE,
40          self.button1 = wxButton(id=wxID_WXDIALOG1BUTTON1, label='Cancel',                self.OnBtsaveButton)
41                name='button1', parent=self, pos=wxPoint(80, 168), size=wxSize(56,  
42                16), style=0)          self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1,
43                  label='Cancel', name='button1', parent=self, pos=wxPoint(112,
44                  208), size=wxSize(56, 16), style=0)
45            EVT_BUTTON(self.button1, wxID_FRAGGLEDIALOGPREFSBUTTON1,
46                  self.OnButton1Button)
47    
48          self.staticText1 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT1,          self.staticText1 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,
49                label='Username', name='staticText1', parent=self, pos=wxPoint(16,                label='Username', name='staticText1', parent=self, pos=wxPoint(16,
50                16), size=wxSize(47, 13), style=0)                72), size=wxSize(47, 16), style=0)
51    
52          self.staticText2 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT2,          self.staticText2 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT2,
53                label='Password', name='staticText2', parent=self, pos=wxPoint(16,                label='Password', name='staticText2', parent=self, pos=wxPoint(16,
54                40), size=wxSize(53, 16), style=0)                96), size=wxSize(53, 16), style=0)
55    
56          self.textCtrlUsername = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLUSERNAME,          self.textCtrlUsername = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,
57                name='textCtrlUsername', parent=self, pos=wxPoint(80, 16),                name='textCtrlUsername', parent=self, pos=wxPoint(80, 72),
58                size=wxSize(80, 16), style=0, value='')                size=wxSize(88, 16), style=0, value='')
59    
60          self.textCtrlPassword = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLPASSWORD,          self.textCtrlPassword = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,
61                name='textCtrlPassword', parent=self, pos=wxPoint(80, 40),                name='textCtrlPassword', parent=self, pos=wxPoint(80, 96),
62                size=wxSize(80, 16), style=0, value='')                size=wxSize(88, 16), style=0, value='')
63    
64          self.staticText3 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT3,          self.staticText3 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,
65                label='Server URL', name='staticText3', parent=self,                label='Server URL', name='staticText3', parent=self,
66                pos=wxPoint(16, 64), size=wxSize(58, 16), style=0)                pos=wxPoint(16, 120), size=wxSize(58, 16), style=0)
67    
68          self.textCtrlServer = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLSERVER,          self.textCtrlServer = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,
69                name='textCtrlServer', parent=self, pos=wxPoint(80, 64),                name='textCtrlServer', parent=self, pos=wxPoint(80, 120),
70                size=wxSize(272, 16), style=0,                size=wxSize(272, 16), style=0,
71                value='http://your.server.com/netfraggle.php')                value='http://your.server.com/netfraggle.php')
72    
73          self.staticText4 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT4,          self.staticText4 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT4,
74                label='Topic Retrieval Interval', name='staticText4', parent=self,                label='Topic Retrieval Interval', name='staticText4', parent=self,
75                pos=wxPoint(16, 144), size=wxSize(120, 16), style=0)                pos=wxPoint(16, 144), size=wxSize(120, 16), style=0)
76    
77          self.textCtrlRetrieval = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLRETRIEVAL,          self.textCtrlRetrieval = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL,
78                name='textCtrlRetrieval', parent=self, pos=wxPoint(128, 144),                name='textCtrlRetrieval', parent=self, pos=wxPoint(128, 144),
79                size=wxSize(40, 16), style=0, value='')                size=wxSize(40, 16), style=0, value='')
80    
81          self.staticText5 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT5,          self.staticText5 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT5,
82                label='Seconds', name='staticText5', parent=self, pos=wxPoint(176,                label='Seconds', name='staticText5', parent=self, pos=wxPoint(176,
83                144), size=wxSize(56, 16), style=0)                144), size=wxSize(56, 16), style=0)
84    
85          self.staticLine1 = wxStaticLine(id=wxID_WXDIALOG1STATICLINE1,          self.comboBoxProfile = wxComboBox(choices=[],
86                name='staticLine1', parent=self, pos=wxPoint(0, 144),                id=wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, name='comboBoxProfile',
87                size=wxSize(368, 0), style=0)                parent=self, pos=wxPoint(80, 8), size=wxSize(124, 21), style=0,
88                  validator=wxDefaultValidator, value='')
89          self.staticLine2 = wxStaticLine(id=wxID_WXDIALOG1STATICLINE2,          self.comboBoxProfile.SetLabel('')
90                name='staticLine2', parent=self, pos=wxPoint(0, 56),          EVT_COMBOBOX(self.comboBoxProfile,
91                size=wxSize(368, 8), style=0)                wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE,
92                  self.OnComboboxprofileCombobox)
93    
94            self.staticText6 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT6,
95                  label='Profile', name='staticText6', parent=self, pos=wxPoint(16,
96                  8), size=wxSize(48, 16), style=0)
97    
98            self.buttonProfileSave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
99                  label='Save', name='buttonProfileSave', parent=self,
100                  pos=wxPoint(272, 8), size=wxSize(40, 16), style=0)
101            EVT_BUTTON(self.buttonProfileSave,
102                  wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
103                  self.OnButtonprofilesaveButton)
104    
105            self.buttonProfileDel = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
106                  label='Delete', name='buttonProfileDel', parent=self,
107                  pos=wxPoint(320, 8), size=wxSize(40, 16), style=0)
108            EVT_BUTTON(self.buttonProfileDel,
109                  wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
110                  self.OnButtonprofiledelButton)
111    
112            self.buttonProfileLoad = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
113                  label='Load', name='buttonProfileLoad', parent=self,
114                  pos=wxPoint(216, 8), size=wxSize(48, 16), style=0)
115            EVT_BUTTON(self.buttonProfileLoad,
116                  wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
117                  self.OnButtonprofileloadButton)
118    
119            self.buttonTest = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONTEST,
120                  label=u'&Test Account', name=u'buttonTest', parent=self,
121                  pos=wxPoint(264, 208), size=wxSize(96, 16), style=0)
122            EVT_BUTTON(self.buttonTest, wxID_FRAGGLEDIALOGPREFSBUTTONTEST,
123                  self.OnButtonTestButton)
124    
125            self.buttonModules = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONMODULES,
126                  label='Modules', name='buttonModules', parent=self,
127                  pos=wxPoint(264, 184), size=wxSize(96, 16), style=0)
128            EVT_BUTTON(self.buttonModules, wxID_FRAGGLEDIALOGPREFSBUTTONMODULES,
129                  self.OnButtonModulesButton)
130    
131        def __init_profiles(self):
132            list = self.parent.preferencesCtl.getProfileList()
133            print list
134            for i in list:
135                self.comboBoxProfile.Append(i)
136            
137      def __init__(self, parent):      def __init__(self, parent):
138            self.parent = parent
139            import __main__
140            self.engine = __main__.engine
141          self._init_ctrls(parent)          self._init_ctrls(parent)
142            self.dialogModules = FraggleDialogModules.create(self)
143            self.__init_profiles()
144            
145        def OnBtsaveButton(self, event):
146    
147            # convert from utf-8: required for win32
148            import codecs
149            (UTF8_encode, UTF8_decode,
150                UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8')
151            self.parent.preferencesCtl.setConfig(
152                    UTF8_encode(self.textCtrlUsername.GetValue())[0],
153                    UTF8_encode(self.textCtrlPassword.GetValue())[0],
154                    UTF8_encode(self.textCtrlServer.GetValue())[0],
155                    UTF8_encode(self.textCtrlRetrieval.GetValue())[0]
156                )
157            
158            self.parent.preferencesCtl.saveConfig()
159            self.Hide()
160            event.Skip()
161    
162        def loadConfig(self):
163            prefsfile = os.path.join(self.parent.engine.getDefaultDir(), 'prefs.xml')
164            self.parent.preferencesCtl.loadConfig(prefsfile)
165            
166        def updateConfig(self):
167            config = self.parent.preferencesCtl.getConfig()
168            try:
169                self.textCtrlUsername.SetValue(config["username"])
170                self.textCtrlPassword.SetValue(config["password"])    
171                self.textCtrlServer.SetValue(config["url"])
172                self.textCtrlRetrieval.SetValue(config["retrieval"])
173            except TypeError:
174                self.textCtrlUsername.SetValue("username")
175                self.textCtrlPassword.SetValue("password")    
176                self.textCtrlServer.SetValue("url")
177                self.textCtrlRetrieval.SetValue("retrieval")
178                
179        def OnButton1Button(self, event):
180            self.Hide()
181            event.Skip()
182    
183        def OnButtonprofilesaveButton(self, event):
184            username = self.textCtrlUsername.GetValue()
185            password = self.textCtrlPassword.GetValue()    
186            url = self.textCtrlServer.GetValue()
187            retrieval = self.textCtrlRetrieval.GetValue()
188            self.parent.preferencesCtl.setConfig(username,password,url,retrieval)
189            i = self.parent.preferencesCtl.appendProfile(self.comboBoxProfile.GetValue(),self.parent.preferencesCtl.configList)
190            if i == 0:
191                self.comboBoxProfile.Append(self.comboBoxProfile.GetValue())
192            
193            self.parent.preferencesCtl.saveProfiles()
194            event.Skip()
195    
196        def OnButtonprofileloadButton(self, event):
197            self.parent.preferencesCtl.loadProfile(self.comboBoxProfile.GetValue())
198            self.updateConfig()
199            event.Skip()
200    
201        def OnButtonprofiledelButton(self, event):
202            self.parent.preferencesCtl.deleteProfile(self.comboBoxProfile.GetValue())
203            self.comboBoxProfile.Delete(self.comboBoxProfile.FindString(self.comboBoxProfile.GetValue()))
204            self.parent.preferencesCtl.saveProfiles()
205            self.updateConfig()
206            event.Skip()
207    
208        def OnComboboxprofileCombobox(self, event):
209            event.Skip()
210    
211        def OnButtonTestButton(self, event):
212            #event.Skip()
213            if self.engine.authenticate(self.textCtrlServer.GetValue(), self.textCtrlUsername.GetValue(), self.textCtrlPassword.GetValue()):
214                wxMessageBox("Authentication successful!")
215            else:
216                wxMessageBox("Authentication failed!")
217    
218        def OnButtonModulesButton(self, event):
219            self.dialogModules.Show()
220            #self.parent.dialogModules.Hide()
221            event.Skip()

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.13

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed