11 |
[wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE, |
[wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE, |
12 |
wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, |
wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, |
13 |
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, |
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, |
14 |
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, |
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, wxID_FRAGGLEDIALOGPREFSBUTTONTEST, |
15 |
wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, |
wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, |
16 |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3, |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3, |
17 |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5, |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5, |
19 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL, |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL, |
20 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER, |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER, |
21 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME, |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME, |
22 |
] = map(lambda _init_ctrls: wxNewId(), range(17)) |
] = map(lambda _init_ctrls: wxNewId(), range(18)) |
23 |
|
|
24 |
class fraggleDialogPrefs(wxDialog): |
class fraggleDialogPrefs(wxDialog): |
|
def _init_utils(self): |
|
|
# generated method, don't edit |
|
|
pass |
|
|
|
|
25 |
def _init_ctrls(self, prnt): |
def _init_ctrls(self, prnt): |
26 |
# generated method, don't edit |
# generated method, don't edit |
27 |
wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS, |
wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS, |
28 |
name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(283, 313), |
name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(482, 310), |
29 |
size=wxSize(366, 233), style=wxDEFAULT_DIALOG_STYLE, |
size=wxSize(366, 233), style=wxDEFAULT_DIALOG_STYLE, |
30 |
title='Netfraggle Preferences') |
title='Netfraggle Preferences') |
31 |
self._init_utils() |
self._init_utils() |
82 |
|
|
83 |
self.comboBoxProfile = wxComboBox(choices=[], |
self.comboBoxProfile = wxComboBox(choices=[], |
84 |
id=wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, name='comboBoxProfile', |
id=wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, name='comboBoxProfile', |
85 |
parent=self, pos=wxPoint(80, 8), size=wxSize(124, 16), style=0, |
parent=self, pos=wxPoint(80, 8), size=wxSize(124, 21), style=0, |
86 |
validator=wxDefaultValidator, value='') |
validator=wxDefaultValidator, value='') |
87 |
self.comboBoxProfile.SetLabel('') |
self.comboBoxProfile.SetLabel('') |
88 |
|
EVT_COMBOBOX(self.comboBoxProfile, |
89 |
|
wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, |
90 |
|
self.OnComboboxprofileCombobox) |
91 |
|
|
92 |
self.staticText6 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT6, |
self.staticText6 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT6, |
93 |
label='Profile', name='staticText6', parent=self, pos=wxPoint(16, |
label='Profile', name='staticText6', parent=self, pos=wxPoint(16, |
96 |
self.buttonProfileSave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, |
self.buttonProfileSave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, |
97 |
label='Save', name='buttonProfileSave', parent=self, |
label='Save', name='buttonProfileSave', parent=self, |
98 |
pos=wxPoint(272, 8), size=wxSize(40, 16), style=0) |
pos=wxPoint(272, 8), size=wxSize(40, 16), style=0) |
99 |
|
EVT_BUTTON(self.buttonProfileSave, |
100 |
|
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, |
101 |
|
self.OnButtonprofilesaveButton) |
102 |
|
|
103 |
self.buttonProfileDel = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, |
self.buttonProfileDel = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, |
104 |
label='Delete', name='buttonProfileDel', parent=self, |
label='Delete', name='buttonProfileDel', parent=self, |
105 |
pos=wxPoint(320, 8), size=wxSize(40, 16), style=0) |
pos=wxPoint(320, 8), size=wxSize(40, 16), style=0) |
106 |
|
EVT_BUTTON(self.buttonProfileDel, |
107 |
|
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, |
108 |
|
self.OnButtonprofiledelButton) |
109 |
|
|
110 |
self.buttonProfileLoad = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, |
self.buttonProfileLoad = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, |
111 |
label='Load', name='buttonProfileLoad', parent=self, |
label='Load', name='buttonProfileLoad', parent=self, |
112 |
pos=wxPoint(216, 8), size=wxSize(48, 16), style=0) |
pos=wxPoint(216, 8), size=wxSize(48, 16), style=0) |
113 |
|
EVT_BUTTON(self.buttonProfileLoad, |
114 |
|
wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, |
115 |
|
self.OnButtonprofileloadButton) |
116 |
|
|
117 |
|
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 |
|
|
123 |
|
def _init_utils(self): |
124 |
|
# generated method, don't edit |
125 |
|
pass |
126 |
|
|
127 |
|
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 |
def __init__(self, parent): |
def __init__(self, parent): |
134 |
self.parent = parent |
self.parent = parent |
135 |
|
import __main__ |
136 |
|
self.engine = __main__.engine |
137 |
self._init_ctrls(parent) |
self._init_ctrls(parent) |
138 |
|
self.__init_profiles() |
139 |
|
|
140 |
def OnBtsaveButton(self, event): |
def OnBtsaveButton(self, event): |
141 |
|
|
142 |
# convert from utf-8: required for win32 |
# convert from utf-8: required for win32 |
155 |
event.Skip() |
event.Skip() |
156 |
|
|
157 |
def loadConfig(self): |
def loadConfig(self): |
158 |
engine = FraggleEngine() |
prefsfile = os.path.join(self.parent.engine.getDefaultDir(), 'prefs.xml') |
|
prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') |
|
159 |
self.parent.preferencesCtl.loadConfig(prefsfile) |
self.parent.preferencesCtl.loadConfig(prefsfile) |
160 |
|
|
161 |
def updateConfig(self): |
def updateConfig(self): |
162 |
config = self.parent.preferencesCtl.getConfig() |
config = self.parent.preferencesCtl.getConfig() |
163 |
self.textCtrlUsername.SetValue(config["username"]) |
try: |
164 |
self.textCtrlPassword.SetValue(config["password"]) |
self.textCtrlUsername.SetValue(config["username"]) |
165 |
self.textCtrlServer.SetValue(config["url"]) |
self.textCtrlPassword.SetValue(config["password"]) |
166 |
self.textCtrlRetrieval.SetValue(config["retrieval"]) |
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 |
def OnButton1Button(self, event): |
def OnButton1Button(self, event): |
175 |
self.Hide() |
self.Hide() |
176 |
event.Skip() |
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 |
|
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 |
|
event.Skip() |
205 |
|
|
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!") |