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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Wed Aug 25 21:43:00 2004 UTC (19 years, 10 months ago) by xabbu
Branch: MAIN
Changes since 1.3: +22 -0 lines
File MIME type: text/x-python
Preferences Dialog closes now(Cancel). Settings are saved in the right location.

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

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