/[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.5 by xabbu, Thu Aug 26 23:10:11 2004 UTC revision 1.9 by joko, Mon Aug 30 12:51:36 2004 UTC
# Line 9  def create(parent): Line 9  def create(parent):
9    
10    
11  [wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE,  [wxID_FRAGGLEDIALOGPREFS, wxID_FRAGGLEDIALOGPREFSBTSAVE,
12   wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSSTATICLINE1,   wxID_FRAGGLEDIALOGPREFSBUTTON1, wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
13   wxID_FRAGGLEDIALOGPREFSSTATICLINE2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,   wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
14     wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
15     wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,
16   wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,   wxID_FRAGGLEDIALOGPREFSSTATICTEXT2, wxID_FRAGGLEDIALOGPREFSSTATICTEXT3,
17   wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5,   wxID_FRAGGLEDIALOGPREFSSTATICTEXT4, wxID_FRAGGLEDIALOGPREFSSTATICTEXT5,
18   wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,   wxID_FRAGGLEDIALOGPREFSSTATICTEXT6, wxID_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,
19   wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL,   wxID_FRAGGLEDIALOGPREFSTEXTCTRLRETRIEVAL,
20   wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,   wxID_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,
21   wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,   wxID_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,
22  ] = map(lambda _init_ctrls: wxNewId(), range(14))  ] = map(lambda _init_ctrls: wxNewId(), range(17))
23    
24  class fraggleDialogPrefs(wxDialog):  class fraggleDialogPrefs(wxDialog):
25      def _init_utils(self):      def _init_utils(self):
# Line 28  class fraggleDialogPrefs(wxDialog): Line 30  class fraggleDialogPrefs(wxDialog):
30          # generated method, don't edit          # generated method, don't edit
31          wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS,          wxDialog.__init__(self, id=wxID_FRAGGLEDIALOGPREFS,
32                name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(283, 313),                name='fraggleDialogPrefs', parent=prnt, pos=wxPoint(283, 313),
33                size=wxSize(366, 188), style=wxDEFAULT_DIALOG_STYLE,                size=wxSize(366, 233), style=wxDEFAULT_DIALOG_STYLE,
34                title='Netfraggle Preferences')                title='Netfraggle Preferences')
35          self._init_utils()          self._init_utils()
36          self.SetClientSize(wxSize(366, 188))          self.SetClientSize(wxSize(366, 233))
37    
38          self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE,          self.btsave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBTSAVE,
39                label='Save  and Close', name='btsave', parent=self,                label='Save  and Close', name='btsave', parent=self,
40                pos=wxPoint(8, 168), size=wxSize(96, 16), style=0)                pos=wxPoint(8, 208), size=wxSize(96, 16), style=0)
41          EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE,          EVT_BUTTON(self.btsave, wxID_FRAGGLEDIALOGPREFSBTSAVE,
42                self.OnBtsaveButton)                self.OnBtsaveButton)
43    
44          self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1,          self.button1 = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTON1,
45                label='Cancel', name='button1', parent=self, pos=wxPoint(112,                label='Cancel', name='button1', parent=self, pos=wxPoint(112,
46                168), size=wxSize(56, 16), style=0)                208), size=wxSize(56, 16), style=0)
47          EVT_BUTTON(self.button1, wxID_FRAGGLEDIALOGPREFSBUTTON1,          EVT_BUTTON(self.button1, wxID_FRAGGLEDIALOGPREFSBUTTON1,
48                self.OnButton1Button)                self.OnButton1Button)
49    
50          self.staticText1 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT1,          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_FRAGGLEDIALOGPREFSSTATICTEXT2,          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_FRAGGLEDIALOGPREFSTEXTCTRLUSERNAME,          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_FRAGGLEDIALOGPREFSTEXTCTRLPASSWORD,          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_FRAGGLEDIALOGPREFSSTATICTEXT3,          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_FRAGGLEDIALOGPREFSTEXTCTRLSERVER,          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    
# Line 82  class fraggleDialogPrefs(wxDialog): Line 84  class fraggleDialogPrefs(wxDialog):
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_FRAGGLEDIALOGPREFSSTATICLINE1,          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_FRAGGLEDIALOGPREFSSTATICLINE2,          self.comboBoxProfile.SetLabel('')
92                name='staticLine2', parent=self, pos=wxPoint(0, 56),          EVT_COMBOBOX(self.comboBoxProfile,
93                size=wxSize(368, 8), style=0)                wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE,
94                  self.OnComboboxprofileCombobox)
95    
96            self.staticText6 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT6,
97                  label='Profile', name='staticText6', parent=self, pos=wxPoint(16,
98                  8), size=wxSize(48, 16), style=0)
99    
100            self.buttonProfileSave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
101                  label='Save', name='buttonProfileSave', parent=self,
102                  pos=wxPoint(272, 8), size=wxSize(40, 16), style=0)
103            EVT_BUTTON(self.buttonProfileSave,
104                  wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE,
105                  self.OnButtonprofilesaveButton)
106    
107            self.buttonProfileDel = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
108                  label='Delete', name='buttonProfileDel', parent=self,
109                  pos=wxPoint(320, 8), size=wxSize(40, 16), style=0)
110            EVT_BUTTON(self.buttonProfileDel,
111                  wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL,
112                  self.OnButtonprofiledelButton)
113    
114            self.buttonProfileLoad = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
115                  label='Load', name='buttonProfileLoad', parent=self,
116                  pos=wxPoint(216, 8), size=wxSize(48, 16), style=0)
117            EVT_BUTTON(self.buttonProfileLoad,
118                  wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD,
119                  self.OnButtonprofileloadButton)
120    
121        def __init_profiles(self):
122            list = self.parent.preferencesCtl.getProfileList()
123            print list
124            for i in list:
125                self.comboBoxProfile.Append(i)
126            
127      def __init__(self, parent):      def __init__(self, parent):
128          self.parent = parent          self.parent = parent
129          self._init_ctrls(parent)          self._init_ctrls(parent)
130            self.__init_profiles()
131            
132      def OnBtsaveButton(self, event):      def OnBtsaveButton(self, event):
133    
134          # convert from utf-8: required for win32          # convert from utf-8: required for win32
# Line 112  class fraggleDialogPrefs(wxDialog): Line 147  class fraggleDialogPrefs(wxDialog):
147          event.Skip()          event.Skip()
148    
149      def loadConfig(self):      def loadConfig(self):
150          engine = FraggleEngine()          prefsfile = os.path.join(self.parent.preferencesCtl.getDefaultDir(), 'prefs.xml')
         prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml')  
151          self.parent.preferencesCtl.loadConfig(prefsfile)          self.parent.preferencesCtl.loadConfig(prefsfile)
152                    
153      def updateConfig(self):      def updateConfig(self):
154          config = self.parent.preferencesCtl.getConfig()          config = self.parent.preferencesCtl.getConfig()
155          self.textCtrlUsername.SetValue(config["username"])          try:
156          self.textCtrlPassword.SetValue(config["password"])                  self.textCtrlUsername.SetValue(config["username"])
157          self.textCtrlServer.SetValue(config["url"])              self.textCtrlPassword.SetValue(config["password"])    
158          self.textCtrlRetrieval.SetValue(config["retrieval"])              self.textCtrlServer.SetValue(config["url"])
159                self.textCtrlRetrieval.SetValue(config["retrieval"])
160            except TypeError:
161                self.textCtrlUsername.SetValue("username")
162                self.textCtrlPassword.SetValue("password")    
163                self.textCtrlServer.SetValue("url")
164                self.textCtrlRetrieval.SetValue("retrieval")
165                
166      def OnButton1Button(self, event):      def OnButton1Button(self, event):
167          self.Hide()          self.Hide()
168          event.Skip()          event.Skip()
169    
170        def OnButtonprofilesaveButton(self, event):
171            username = self.textCtrlUsername.GetValue()
172            password = self.textCtrlPassword.GetValue()    
173            url = self.textCtrlServer.GetValue()
174            retrieval = self.textCtrlRetrieval.GetValue()
175            self.parent.preferencesCtl.setConfig(username,password,url,retrieval)
176            i = self.parent.preferencesCtl.appendProfile(self.comboBoxProfile.GetValue(),self.parent.preferencesCtl.configList)
177            if i == 0:
178                self.comboBoxProfile.Append(self.comboBoxProfile.GetValue())
179            
180            self.parent.preferencesCtl.saveProfiles()
181            event.Skip()
182    
183        def OnButtonprofileloadButton(self, event):
184            self.parent.preferencesCtl.loadProfile(self.comboBoxProfile.GetValue())
185            self.updateConfig()
186            event.Skip()
187    
188        def OnButtonprofiledelButton(self, event):
189            self.parent.preferencesCtl.deleteProfile(self.comboBoxProfile.GetValue())
190            self.comboBoxProfile.Delete(self.comboBoxProfile.FindString(self.comboBoxProfile.GetValue()))
191            self.parent.preferencesCtl.saveProfiles()
192            self.updateConfig()
193            event.Skip()
194    
195        def OnComboboxprofileCombobox(self, event):
196            event.Skip()
197                    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

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