1 |
#Boa:Dialog:wxDialog1 |
#Boa:Dialog:fraggleDialogPrefs |
2 |
|
|
3 |
from wxPython.wx import * |
from wxPython.wx import * |
4 |
|
from fraggleEngine import * |
5 |
|
|
6 |
def create(parent): |
def create(parent): |
7 |
return wxDialog1(parent) |
return fraggleDialogPrefs(parent) |
8 |
|
|
9 |
[wxID_WXDIALOG1, wxID_WXDIALOG1BTSAVE, wxID_WXDIALOG1BUTTON1, |
|
10 |
wxID_WXDIALOG1STATICLINE1, wxID_WXDIALOG1STATICLINE2, |
|
11 |
wxID_WXDIALOG1STATICTEXT1, wxID_WXDIALOG1STATICTEXT2, |
[wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE, |
12 |
wxID_WXDIALOG1STATICTEXT3, wxID_WXDIALOG1STATICTEXT4, |
wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSSTATICLINE1, |
13 |
wxID_WXDIALOG1STATICTEXT5, wxID_WXDIALOG1TEXTCTRLPASSWORD, |
wxID_FRAGGLEDIALOGPREFSSTATICLINE2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1, |
14 |
wxID_WXDIALOG1TEXTCTRLRETRIEVAL, wxID_WXDIALOG1TEXTCTRLSERVER, |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3, |
15 |
wxID_WXDIALOG1TEXTCTRLUSERNAME, |
wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5, |
16 |
|
wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD, |
17 |
|
wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL, |
18 |
|
wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER, |
19 |
|
wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME, |
20 |
] = map(lambda _init_ctrls: wxNewId(), range(14)) |
] = map(lambda _init_ctrls: wxNewId(), range(14)) |
21 |
|
|
22 |
class wxDialog1(wxDialog): |
class fraggleDialogPrefs(wxDialog): |
23 |
def _init_utils(self): |
def _init_utils(self): |
24 |
# generated method, don't edit |
# generated method, don't edit |
25 |
pass |
pass |
26 |
|
|
27 |
def _init_ctrls(self, prnt): |
def _init_ctrls(self, prnt): |
28 |
# generated method, don't edit |
# generated method, don't edit |
29 |
wxDialog.__init__(self, id=wxID_WXDIALOG1, name='', parent=prnt, |
wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS, |
30 |
pos=wxPoint(344, 319), size=wxSize(366, 188), |
name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(283, 313), |
31 |
style=wxDEFAULT_DIALOG_STYLE, title='Netfraggle Preferences') |
size=wxSize(366, 188), style=wxDEFAULT_DIALOG_STYLE, |
32 |
|
title='Netfraggle Preferences') |
33 |
self._init_utils() |
self._init_utils() |
34 |
self.SetClientSize(wxSize(366, 188)) |
self.SetClientSize(wxSize(366, 188)) |
35 |
|
|
36 |
self.btsave = wxButton(id=wxID_WXDIALOG1BTSAVE, label='Save', |
self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE, label='Save', |
37 |
name='btsave', parent=self, pos=wxPoint(8, 168), size=wxSize(64, |
name='btsave', parent=self, pos=wxPoint(8, 168), size=wxSize(64, |
38 |
16), style=0) |
16), style=0) |
39 |
|
EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE, |
40 |
|
self.OnBtsaveButton) |
41 |
|
|
42 |
self.button1 = wxButton(id=wxID_WXDIALOG1BUTTON1, label='Cancel', |
self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1, |
43 |
name='button1', parent=self, pos=wxPoint(80, 168), size=wxSize(56, |
label='Cancel', name='button1', parent=self, pos=wxPoint(80, 168), |
44 |
16), style=0) |
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) |
16), size=wxSize(47, 13), 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) |
40), 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, 16), |
58 |
size=wxSize(80, 16), style=0, value='') |
size=wxSize(80, 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, 40), |
62 |
size=wxSize(80, 16), style=0, value='') |
size=wxSize(80, 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, 64), 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, 64), |
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.staticLine1 = wxStaticLine(id=wxID_FRAGGLEDIALOGPREFSSTATICLINE1, |
86 |
name='staticLine1', parent=self, pos=wxPoint(0, 144), |
name='staticLine1', parent=self, pos=wxPoint(0, 144), |
87 |
size=wxSize(368, 0), style=0) |
size=wxSize(368, 0), style=0) |
88 |
|
|
89 |
self.staticLine2 = wxStaticLine(id=wxID_WXDIALOG1STATICLINE2, |
self.staticLine2 = wxStaticLine(id=wxID_FRAGGLEDIALOGPREFSSTATICLINE2, |
90 |
name='staticLine2', parent=self, pos=wxPoint(0, 56), |
name='staticLine2', parent=self, pos=wxPoint(0, 56), |
91 |
size=wxSize(368, 8), style=0) |
size=wxSize(368, 8), style=0) |
92 |
|
|
93 |
def __init__(self, parent): |
def __init__(self, parent): |
94 |
|
self.parent = parent |
95 |
self._init_ctrls(parent) |
self._init_ctrls(parent) |
96 |
|
|
97 |
|
def OnBtsaveButton(self, event): |
98 |
|
|
99 |
|
# convert from utf-8: required for win32 |
100 |
|
import codecs |
101 |
|
(UTF8_encode, UTF8_decode, |
102 |
|
UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8') |
103 |
|
self.parent.preferencesCtl.setConfig( |
104 |
|
UTF8_encode(self.textCtrlUsername.GetValue())[0], |
105 |
|
UTF8_encode(self.textCtrlPassword.GetValue())[0], |
106 |
|
UTF8_encode(self.textCtrlServer.GetValue())[0], |
107 |
|
UTF8_encode(self.textCtrlRetrieval.GetValue())[0] |
108 |
|
) |
109 |
|
|
110 |
|
self.parent.preferencesCtl.saveConfig() |
111 |
|
event.Skip() |
112 |
|
|
113 |
|
def loadConfig(self): |
114 |
|
engine = FraggleEngine() |
115 |
|
prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') |
116 |
|
self.parent.preferencesCtl.loadConfig(prefsfile) |
117 |
|
|
118 |
|
def updateConfig(self): |
119 |
|
config = self.parent.preferencesCtl.getConfig() |
120 |
|
self.textCtrlUsername.SetValue(config["username"]) |
121 |
|
self.textCtrlPassword.SetValue(config["password"]) |
122 |
|
self.textCtrlServer.SetValue(config["url"]) |
123 |
|
self.textCtrlRetrieval.SetValue(config["retrieval"]) |
124 |
|
|
125 |
|
def OnButton1Button(self, event): |
126 |
|
self.Hide() |
127 |
|
event.Skip() |
128 |
|
|