/[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.5 - (hide annotations)
Thu Aug 26 23:10:11 2004 UTC (20 years, 2 months ago) by xabbu
Branch: MAIN
Changes since 1.4: +6 -5 lines
File MIME type: text/x-python
xmlrpc class added

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     def create(parent):
7 xabbu 1.2 return fraggleDialogPrefs(parent)
8 xabbu 1.1
9 xabbu 1.4
10    
11 xabbu 1.2 [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 xabbu 1.1 ] = map(lambda _init_ctrls: wxNewId(), range(14))
21    
22 xabbu 1.2 class fraggleDialogPrefs(wxDialog):
23 xabbu 1.1 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 xabbu 1.2 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 xabbu 1.1 self._init_utils()
34     self.SetClientSize(wxSize(366, 188))
35    
36 xabbu 1.5 self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE,
37     label='Save and Close', name='btsave', parent=self,
38     pos=wxPoint(8, 168), 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     168), 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     16), size=wxSize(47, 13), style=0)
51    
52 xabbu 1.2 self.staticText2 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT2,
53 xabbu 1.1 label='Password', name='staticText2', parent=self, pos=wxPoint(16,
54     40), size=wxSize(53, 16), style=0)
55    
56 xabbu 1.2 self.textCtrlUsername = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,
57 xabbu 1.1 name='textCtrlUsername', parent=self, pos=wxPoint(80, 16),
58     size=wxSize(80, 16), style=0, value='')
59    
60 xabbu 1.2 self.textCtrlPassword = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,
61 xabbu 1.1 name='textCtrlPassword', parent=self, pos=wxPoint(80, 40),
62     size=wxSize(80, 16), style=0, value='')
63    
64 xabbu 1.2 self.staticText3 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,
65 xabbu 1.1 label='Server URL', name='staticText3', parent=self,
66     pos=wxPoint(16, 64), size=wxSize(58, 16), style=0)
67    
68 xabbu 1.2 self.textCtrlServer = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,
69 xabbu 1.1 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 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.2 self.staticLine1 = wxStaticLine(id=wxID_FRAGGLEDIALOGPREFSSTATICLINE1,
86 xabbu 1.1 name='staticLine1', parent=self, pos=wxPoint(0, 144),
87     size=wxSize(368, 0), style=0)
88    
89 xabbu 1.2 self.staticLine2 = wxStaticLine(id=wxID_FRAGGLEDIALOGPREFSSTATICLINE2,
90 xabbu 1.1 name='staticLine2', parent=self, pos=wxPoint(0, 56),
91     size=wxSize(368, 8), style=0)
92    
93     def __init__(self, parent):
94 xabbu 1.2 self.parent = parent
95 xabbu 1.1 self._init_ctrls(parent)
96 xabbu 1.2
97     def OnBtsaveButton(self, event):
98 joko 1.3
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 xabbu 1.2 self.parent.preferencesCtl.saveConfig()
111 xabbu 1.5 self.Hide()
112 xabbu 1.2 event.Skip()
113 xabbu 1.4
114     def loadConfig(self):
115     engine = FraggleEngine()
116     prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml')
117     self.parent.preferencesCtl.loadConfig(prefsfile)
118    
119     def updateConfig(self):
120     config = self.parent.preferencesCtl.getConfig()
121     self.textCtrlUsername.SetValue(config["username"])
122     self.textCtrlPassword.SetValue(config["password"])
123     self.textCtrlServer.SetValue(config["url"])
124     self.textCtrlRetrieval.SetValue(config["retrieval"])
125    
126     def OnButton1Button(self, event):
127     self.Hide()
128     event.Skip()
129    

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