/[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.14 - (hide annotations)
Sun Sep 5 00:21:10 2004 UTC (19 years, 10 months ago) by xabbu
Branch: MAIN
CVS Tags: HEAD
Changes since 1.13: +10 -13 lines
File MIME type: text/x-python
+Fixed File Menu Modules item on Posix system. Gotta do testing on Windows with it.

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

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