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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations)
Wed Sep 1 20:56:32 2004 UTC (20 years, 2 months ago) by xabbu
Branch: MAIN
Changes since 1.10: +7 -2 lines
File MIME type: text/x-python
+FraggleDialogModules class creation for handling the module configuration
+FraggleDialogPrefs fixed missing funtion _init_utils(self)

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

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