1 |
#Boa:Dialog:fraggleDialogPrefs |
2 |
|
3 |
from wxPython.wx import * |
4 |
|
5 |
def create(parent): |
6 |
return fraggleDialogPrefs(parent) |
7 |
|
8 |
[wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE, |
9 |
wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSSTATICLINE1, |
10 |
wxID_FRAGGLEDIALOGPREFSSTATICLINE2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, |
11 |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3, |
12 |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5, |
13 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD, |
14 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL, |
15 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER, |
16 |
wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME, |
17 |
] = map(lambda _init_ctrls: wxNewId(), range(14)) |
18 |
|
19 |
class fraggleDialogPrefs(wxDialog): |
20 |
def _init_utils(self): |
21 |
# generated method, don't edit |
22 |
pass |
23 |
|
24 |
def _init_ctrls(self, prnt): |
25 |
# generated method, don't edit |
26 |
wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS, |
27 |
name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(283, 313), |
28 |
size=wxSize(366, 188), style=wxDEFAULT_DIALOG_STYLE, |
29 |
title='Netfraggle Preferences') |
30 |
self._init_utils() |
31 |
self.SetClientSize(wxSize(366, 188)) |
32 |
|
33 |
self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE, label='Save', |
34 |
name='btsave', parent=self, pos=wxPoint(8, 168), size=wxSize(64, |
35 |
16), style=0) |
36 |
EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE, |
37 |
self.OnBtsaveButton) |
38 |
|
39 |
self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1, |
40 |
label='Cancel', name='button1', parent=self, pos=wxPoint(80, 168), |
41 |
size=wxSize(56, 16), style=0) |
42 |
|
43 |
self.staticText1 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, |
44 |
label='Username', name='staticText1', parent=self, pos=wxPoint(16, |
45 |
16), size=wxSize(47, 13), style=0) |
46 |
|
47 |
self.staticText2 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, |
48 |
label='Password', name='staticText2', parent=self, pos=wxPoint(16, |
49 |
40), size=wxSize(53, 16), style=0) |
50 |
|
51 |
self.textCtrlUsername = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME, |
52 |
name='textCtrlUsername', parent=self, pos=wxPoint(80, 16), |
53 |
size=wxSize(80, 16), style=0, value='') |
54 |
|
55 |
self.textCtrlPassword = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD, |
56 |
name='textCtrlPassword', parent=self, pos=wxPoint(80, 40), |
57 |
size=wxSize(80, 16), style=0, value='') |
58 |
|
59 |
self.staticText3 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT3, |
60 |
label='Server URL', name='staticText3', parent=self, |
61 |
pos=wxPoint(16, 64), size=wxSize(58, 16), style=0) |
62 |
|
63 |
self.textCtrlServer = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER, |
64 |
name='textCtrlServer', parent=self, pos=wxPoint(80, 64), |
65 |
size=wxSize(272, 16), style=0, |
66 |
value='http://your.server.com/netfraggle.php') |
67 |
|
68 |
self.staticText4 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, |
69 |
label='Topic Retrieval Interval', name='staticText4', parent=self, |
70 |
pos=wxPoint(16, 144), size=wxSize(120, 16), style=0) |
71 |
|
72 |
self.textCtrlRetrieval = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL, |
73 |
name='textCtrlRetrieval', parent=self, pos=wxPoint(128, 144), |
74 |
size=wxSize(40, 16), style=0, value='') |
75 |
|
76 |
self.staticText5 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT5, |
77 |
label='Seconds', name='staticText5', parent=self, pos=wxPoint(176, |
78 |
144), size=wxSize(56, 16), style=0) |
79 |
|
80 |
self.staticLine1 = wxStaticLine(id=wxID_FRAGGLEDIALOGPREFSSTATICLINE1, |
81 |
name='staticLine1', parent=self, pos=wxPoint(0, 144), |
82 |
size=wxSize(368, 0), style=0) |
83 |
|
84 |
self.staticLine2 = wxStaticLine(id=wxID_FRAGGLEDIALOGPREFSSTATICLINE2, |
85 |
name='staticLine2', parent=self, pos=wxPoint(0, 56), |
86 |
size=wxSize(368, 8), style=0) |
87 |
|
88 |
def __init__(self, parent): |
89 |
self.parent = parent |
90 |
self._init_ctrls(parent) |
91 |
|
92 |
def OnBtsaveButton(self, event): |
93 |
|
94 |
# convert from utf-8: required for win32 |
95 |
import codecs |
96 |
(UTF8_encode, UTF8_decode, |
97 |
UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8') |
98 |
self.parent.preferencesCtl.setConfig( |
99 |
UTF8_encode(self.textCtrlUsername.GetValue())[0], |
100 |
UTF8_encode(self.textCtrlPassword.GetValue())[0], |
101 |
UTF8_encode(self.textCtrlServer.GetValue())[0], |
102 |
UTF8_encode(self.textCtrlRetrieval.GetValue())[0] |
103 |
) |
104 |
|
105 |
self.parent.preferencesCtl.saveConfig() |
106 |
event.Skip() |