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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by xabbu, Wed Aug 25 13:53:48 2004 UTC revision 1.6 by xabbu, Fri Aug 27 21:14:02 2004 UTC
# Line 1  Line 1 
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    
 [wxID_WXDIALOG1, wxID_WXDIALOG1BTSAVE, wxID_WXDIALOG1BUTTON1,  
  wxID_WXDIALOG1STATICLINE1, wxID_WXDIALOG1STATICLINE2,  
  wxID_WXDIALOG1STATICTEXT1, wxID_WXDIALOG1STATICTEXT2,  
  wxID_WXDIALOG1STATICTEXT3, wxID_WXDIALOG1STATICTEXT4,  
  wxID_WXDIALOG1STATICTEXT5, wxID_WXDIALOG1TEXTCTRLPASSWORD,  
  wxID_WXDIALOG1TEXTCTRLRETRIEVAL, wxID_WXDIALOG1TEXTCTRLSERVER,  
  wxID_WXDIALOG1TEXTCTRLUSERNAME,  
 ] = map(lambda _init_ctrls: wxNewId(), range(14))  
9    
10  class wxDialog1(wxDialog):  
11    [wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE,
12     wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
13     wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
14     wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
15     wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,
16     wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,
17     wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5,
18     wxID_FRAGGLEDIALOGPREFSSTATICTEXT6, wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,
19     wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL,
20     wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,
21     wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,
22    ] = map(lambda _init_ctrls: wxNewId(), range(17))
23    
24    class fraggleDialogPrefs(wxDialog):
25      def _init_utils(self):      def _init_utils(self):
26          # generated method, don't edit          # generated method, don't edit
27          pass          pass
28    
29      def _init_ctrls(self, prnt):      def _init_ctrls(self, prnt):
30          # generated method, don't edit          # generated method, don't edit
31          wxDialog.__init__(self, id=wxID_WXDIALOG1, name='', parent=prnt,          wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS,
32                pos=wxPoint(344, 319), size=wxSize(366, 188),                name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(283, 313),
33                style=wxDEFAULT_DIALOG_STYLE, title='Netfraggle Preferences')                size=wxSize(366, 233), style=wxDEFAULT_DIALOG_STYLE,
34                  title='Netfraggle Preferences')
35          self._init_utils()          self._init_utils()
36          self.SetClientSize(wxSize(366, 188))          self.SetClientSize(wxSize(366, 233))
   
         self.btsave = wxButton(id=wxID_WXDIALOG1BTSAVE, label='Save',  
               name='btsave', parent=self, pos=wxPoint(8, 168), size=wxSize(64,  
               16), style=0)  
37    
38          self.button1 = wxButton(id=wxID_WXDIALOG1BUTTON1, label='Cancel',          self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE,
39                name='button1', parent=self, pos=wxPoint(80, 168), size=wxSize(56,                label='Save  and Close', name='btsave', parent=self,
40                16), style=0)                pos=wxPoint(8, 208), size=wxSize(96, 16), style=0)
41            EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE,
42                  self.OnBtsaveButton)
43    
44            self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1,
45                  label='Cancel', name='button1', parent=self, pos=wxPoint(112,
46                  208), size=wxSize(56, 16), style=0)
47            EVT_BUTTON(self.button1, wxID_FRAGGLEDIALOGPREFSBUTTON1,
48                  self.OnButton1Button)
49    
50          self.staticText1 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT1,          self.staticText1 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,
51                label='Username', name='staticText1', parent=self, pos=wxPoint(16,                label='Username', name='staticText1', parent=self, pos=wxPoint(16,
52                16), size=wxSize(47, 13), style=0)                72), size=wxSize(47, 16), style=0)
53    
54          self.staticText2 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT2,          self.staticText2 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT2,
55                label='Password', name='staticText2', parent=self, pos=wxPoint(16,                label='Password', name='staticText2', parent=self, pos=wxPoint(16,
56                40), size=wxSize(53, 16), style=0)                96), size=wxSize(53, 16), style=0)
57    
58          self.textCtrlUsername = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLUSERNAME,          self.textCtrlUsername = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,
59                name='textCtrlUsername', parent=self, pos=wxPoint(80, 16),                name='textCtrlUsername', parent=self, pos=wxPoint(80, 72),
60                size=wxSize(80, 16), style=0, value='')                size=wxSize(88, 16), style=0, value='')
61    
62          self.textCtrlPassword = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLPASSWORD,          self.textCtrlPassword = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,
63                name='textCtrlPassword', parent=self, pos=wxPoint(80, 40),                name='textCtrlPassword', parent=self, pos=wxPoint(80, 96),
64                size=wxSize(80, 16), style=0, value='')                size=wxSize(88, 16), style=0, value='')
65    
66          self.staticText3 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT3,          self.staticText3 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,
67                label='Server URL', name='staticText3', parent=self,                label='Server URL', name='staticText3', parent=self,
68                pos=wxPoint(16, 64), size=wxSize(58, 16), style=0)                pos=wxPoint(16, 120), size=wxSize(58, 16), style=0)
69    
70          self.textCtrlServer = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLSERVER,          self.textCtrlServer = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,
71                name='textCtrlServer', parent=self, pos=wxPoint(80, 64),                name='textCtrlServer', parent=self, pos=wxPoint(80, 120),
72                size=wxSize(272, 16), style=0,                size=wxSize(272, 16), style=0,
73                value='http://your.server.com/netfraggle.php')                value='http://your.server.com/netfraggle.php')
74    
75          self.staticText4 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT4,          self.staticText4 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT4,
76                label='Topic Retrieval Interval', name='staticText4', parent=self,                label='Topic Retrieval Interval', name='staticText4', parent=self,
77                pos=wxPoint(16, 144), size=wxSize(120, 16), style=0)                pos=wxPoint(16, 144), size=wxSize(120, 16), style=0)
78    
79          self.textCtrlRetrieval = wxTextCtrl(id=wxID_WXDIALOG1TEXTCTRLRETRIEVAL,          self.textCtrlRetrieval = wxTextCtrl(id=wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL,
80                name='textCtrlRetrieval', parent=self, pos=wxPoint(128, 144),                name='textCtrlRetrieval', parent=self, pos=wxPoint(128, 144),
81                size=wxSize(40, 16), style=0, value='')                size=wxSize(40, 16), style=0, value='')
82    
83          self.staticText5 = wxStaticText(id=wxID_WXDIALOG1STATICTEXT5,          self.staticText5 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT5,
84                label='Seconds', name='staticText5', parent=self, pos=wxPoint(176,                label='Seconds', name='staticText5', parent=self, pos=wxPoint(176,
85                144), size=wxSize(56, 16), style=0)                144), size=wxSize(56, 16), style=0)
86    
87          self.staticLine1 = wxStaticLine(id=wxID_WXDIALOG1STATICLINE1,          self.comboBoxProfile = wxComboBox(choices=[],
88                name='staticLine1', parent=self, pos=wxPoint(0, 144),                id=wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, name='comboBoxProfile',
89                size=wxSize(368, 0), style=0)                parent=self, pos=wxPoint(80, 8), size=wxSize(124, 16), style=0,
90                  validator=wxDefaultValidator, value='')
91          self.staticLine2 = wxStaticLine(id=wxID_WXDIALOG1STATICLINE2,          self.comboBoxProfile.SetLabel('')
92                name='staticLine2', parent=self, pos=wxPoint(0, 56),  
93                size=wxSize(368, 8), style=0)          self.staticText6 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT6,
94                  label='Profile', name='staticText6', parent=self, pos=wxPoint(16,
95                  8), size=wxSize(48, 16), style=0)
96    
97            self.buttonProfileSave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
98                  label='Save', name='buttonProfileSave', parent=self,
99                  pos=wxPoint(272, 8), size=wxSize(40, 16), style=0)
100    
101            self.buttonProfileDel = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
102                  label='Delete', name='buttonProfileDel', parent=self,
103                  pos=wxPoint(320, 8), size=wxSize(40, 16), style=0)
104    
105            self.buttonProfileLoad = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
106                  label='Load', name='buttonProfileLoad', parent=self,
107                  pos=wxPoint(216, 8), size=wxSize(48, 16), style=0)
108    
109      def __init__(self, parent):      def __init__(self, parent):
110            self.parent = parent
111          self._init_ctrls(parent)          self._init_ctrls(parent)
112    
113        def OnBtsaveButton(self, event):
114    
115            # convert from utf-8: required for win32
116            import codecs
117            (UTF8_encode, UTF8_decode,
118                UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8')
119            self.parent.preferencesCtl.setConfig(
120                    UTF8_encode(self.textCtrlUsername.GetValue())[0],
121                    UTF8_encode(self.textCtrlPassword.GetValue())[0],
122                    UTF8_encode(self.textCtrlServer.GetValue())[0],
123                    UTF8_encode(self.textCtrlRetrieval.GetValue())[0]
124                )
125            
126            self.parent.preferencesCtl.saveConfig()
127            self.Hide()
128            event.Skip()
129    
130        def loadConfig(self):
131            engine = FraggleEngine()
132            prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml')
133            self.parent.preferencesCtl.loadConfig(prefsfile)
134            
135        def updateConfig(self):
136            config = self.parent.preferencesCtl.getConfig()
137            self.textCtrlUsername.SetValue(config["username"])
138            self.textCtrlPassword.SetValue(config["password"])    
139            self.textCtrlServer.SetValue(config["url"])
140            self.textCtrlRetrieval.SetValue(config["retrieval"])
141    
142        def OnButton1Button(self, event):
143            self.Hide()
144            event.Skip()
145            

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

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