1 |
#!/usr/bin/env python |
# Copyright (c) 2003 by Intevation GmbH |
2 |
# generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003 |
# Authors: |
3 |
|
# Jonathan Coles <[email protected]> |
4 |
|
# |
5 |
|
# This program is free software under the GPL (>=v2) |
6 |
|
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
8 |
import os, sys |
import os, sys |
9 |
from wxPython.wx import * |
from wxPython.wx import * |
10 |
|
|
19 |
|
|
20 |
ID_PROJ_ADVANCED = 4001 |
ID_PROJ_ADVANCED = 4001 |
21 |
ID_PROJ_PROJCHOICE = 4002 |
ID_PROJ_PROJCHOICE = 4002 |
22 |
ID_PROJ_SAVEAS = 4003 |
ID_PROJ_ADDTOLIST = 4003 |
23 |
ID_PROJ_NEW = 4004 |
ID_PROJ_NEW = 4004 |
24 |
ID_PROJ_TRY = 4005 |
ID_PROJ_TRY = 4005 |
25 |
ID_PROJ_REVERT = 4006 |
ID_PROJ_REVERT = 4006 |
37 |
|
|
38 |
class ProjFrame(NonModalDialog): |
class ProjFrame(NonModalDialog): |
39 |
|
|
40 |
def __init__(self, parent, name, receiver, *args, **kwds): |
def __init__(self, parent, name, title, receiver): |
41 |
"""Initialize the projection dialog. |
"""Initialize the projection dialog. |
42 |
|
|
43 |
receiver -- An object that implements the following methods: |
receiver -- An object that implements the following methods: |
46 |
""" |
""" |
47 |
|
|
48 |
self.receiver = receiver |
self.receiver = receiver |
49 |
self.originalProjection = -1 |
self.haveTried = False |
50 |
self.curProjPanel = None |
self.curProjPanel = None |
51 |
|
|
52 |
self.projPanels = [] |
self.projPanels = [] |
59 |
self.projPanels.append( |
self.projPanels.append( |
60 |
("latlong", _("Geographic"), GeoPanel)) |
("latlong", _("Geographic"), GeoPanel)) |
61 |
|
|
62 |
NonModalDialog.__init__(self, parent, name, "") |
NonModalDialog.__init__(self, parent, name, title) |
63 |
# originally generate by wxGlade |
# originally generate by wxGlade |
64 |
self.panel_1 = wxPanel(self, -1) |
self.panel_1 = wxPanel(self, -1) |
65 |
self.panel_edit = wxPanel(self, -1) |
self.panel_edit = wxPanel(self, -1) |
66 |
self.panel_buttons = wxPanel(self, -1) |
self.panel_buttons = wxPanel(self, -1) |
67 |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
68 |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED |wxLB_SORT) |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED|wxLB_SORT) |
69 |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
70 |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
71 |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
76 |
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
77 |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
78 |
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
79 |
self.button_add = wxButton(self.panel_edit, ID_PROJ_SAVEAS, |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
80 |
_("Add to List")) |
_("Add to List")) |
81 |
self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try")) |
self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try")) |
82 |
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert")) |
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert")) |
87 |
self.__do_layout() |
self.__do_layout() |
88 |
# wxGlade |
# wxGlade |
89 |
|
|
90 |
|
self.originalProjection = self.receiver.GetProjection() |
91 |
|
|
92 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
93 |
|
|
94 |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
103 |
|
|
104 |
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
105 |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
106 |
EVT_BUTTON(self, ID_PROJ_SAVEAS, self._OnSaveAs) |
EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) |
107 |
|
|
108 |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
109 |
|
|
|
def GetReceiver(self): |
|
|
return self.receiver |
|
|
|
|
110 |
def _OnTry(self, event): |
def _OnTry(self, event): |
111 |
self.__SetProjection() |
self.__SetProjection() |
112 |
|
self.haveTried = True |
113 |
|
|
114 |
def _OnRevert(self, event): |
def _OnRevert(self, event): |
115 |
if self.originalProjection != -1: |
if self.haveTried: |
116 |
self.receiver.SetProjection(self.originalProjection) |
self.receiver.SetProjection(self.originalProjection) |
117 |
|
self.haveTried = False |
118 |
|
|
119 |
def _OnOK(self, event): |
def _OnOK(self, event): |
120 |
self.__SetProjection() |
self.__SetProjection() |
124 |
self.Close() |
self.Close() |
125 |
|
|
126 |
def _OnNew(self, event): |
def _OnNew(self, event): |
127 |
self.__DoOnNew() |
|
128 |
|
# clear all selections |
129 |
|
sel = self.availprojs.GetSelections() |
130 |
|
for index in sel: |
131 |
|
self.availprojs.SetSelection(index, False) |
132 |
|
|
133 |
|
self.projname.Clear() |
134 |
|
|
135 |
|
# supply a projection panel if there wasn't one |
136 |
|
if self.curProjPanel is None: |
137 |
|
self.projchoice.SetSelection(0) |
138 |
|
self.__DoOnProjChoice() |
139 |
|
|
140 |
|
self.curProjPanel.Clear() |
141 |
|
|
142 |
def _OnSave(self, event): |
def _OnSave(self, event): |
143 |
|
|
151 |
newproj = self.__GetProjection() |
newproj = self.__GetProjection() |
152 |
|
|
153 |
if newproj is not None: |
if newproj is not None: |
154 |
projfile.Remove(proj) |
projfile.Replace(proj, newproj) |
|
projfile.Add(newproj) |
|
155 |
try: |
try: |
156 |
WriteProjFile(projfile) |
WriteProjFile(projfile) |
157 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
158 |
wxMessageDialog(self, |
self.__ShowError(projfile.GetFilename(), errstr) |
159 |
_("The following error occured:\n") + |
self.availprojs.SetClientData([newproj, projfile]) |
|
projfile.GetFileName() + "\n" + errstr, |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
|
|
self.__FillAvailList() |
|
160 |
|
|
161 |
def _OnSaveAs(self, event): |
def _OnAddToList(self, event): |
162 |
|
|
163 |
proj = self.__GetProjection() |
proj = self.__GetProjection() |
164 |
if proj is not None: |
if proj is not None: |
166 |
try: |
try: |
167 |
WriteProjFile(self.__usrProjFile) |
WriteProjFile(self.__usrProjFile) |
168 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
169 |
wxMessageDialog(self, |
self.__ShowError(self.__userProjFile.GetFilename(), errstr) |
|
_("The following error occured:\n") + |
|
|
self.__usrProjFile.GetFileName() + "\n" + errstr, |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
|
|
self.__FillAvailList() |
|
|
|
|
|
return |
|
|
|
|
|
"""Save the projection somewhere. |
|
|
|
|
|
There are three important cases to consider. |
|
|
1. the file already exists and the user wants to overwrite it. |
|
|
2. the file already exists and the user wants to append the |
|
|
current projection to the end of the file |
|
|
3. the file doesn't exist and the user wants to create it |
|
|
|
|
|
The list of available projections is then updated. |
|
|
""" |
|
|
|
|
|
proj = Projection(self.curProjPanel.GetParameters()) |
|
|
if self.projname.GetValue() != "": |
|
|
proj.SetName(self.projname.GetValue()) |
|
|
|
|
|
dlg = wxFileDialog(self, _("Save As"), style = wxSAVE) |
|
|
if dlg.ShowModal() == wxID_OK: |
|
|
path = dlg.GetPath() |
|
170 |
|
|
171 |
if os.access(path, os.F_OK): |
self.__FillAvailList() |
|
# file already exists. |
|
|
if os.access(path, os.W_OK | os.R_OK): |
|
|
|
|
|
# is it a .proj file? |
|
|
try: |
|
|
projFile = ReadProjFile(path) |
|
|
except: |
|
|
# obviously not. |
|
|
dlg = wxMessageDialog(self, |
|
|
path + _(" already exists. Overwrite?"), |
|
|
_(""), |
|
|
wxYES | wxNO) |
|
|
|
|
|
if dlg.ShowModal() == wxID_YES: |
|
|
projFile = ProjFile(path) |
|
|
else: |
|
|
return # returning early |
|
|
else: |
|
|
# ask the user to overwrite or append |
|
|
dlg = wxMessageDialog(self, |
|
|
_("The selected projection file already exists.\n"+ |
|
|
"The current projection can be added to the " + |
|
|
"file, or it can completely replace the " + |
|
|
"selected file.\n\nShould the current " + |
|
|
"projection be added to the file?"), |
|
|
_("Question"), |
|
|
wxYES | wxNO | wxICON_QUESTION) |
|
|
|
|
|
if dlg.ShowModal() == wxID_NO: |
|
|
projFile = ProjFile(path) |
|
|
else: |
|
|
# can't access the file |
|
|
dlg = wxMessageDialog(self, |
|
|
_("Couldn't access ") + path, |
|
|
_(""), |
|
|
wxOK | wxICON | wxICON_EXCLAMATION) |
|
|
return |
|
|
|
|
|
else: |
|
|
# file doesn't exist. make a new one. |
|
|
projFile = ProjFile(path) |
|
|
|
|
|
# |
|
|
# if we get this far we have a valid projFile and |
|
|
# can just write the file |
|
|
# |
|
|
projFile.Add(proj) |
|
|
try: |
|
|
WriteProjFile(projFile) |
|
|
self.__FillAvailList() |
|
|
except IOError, (errno, errstr): |
|
|
wxMessageDialog(self, |
|
|
_("The following error occured:\n") + |
|
|
dlg.GetPath() + "\n" + errstr, |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
|
|
dlg.Destroy() |
|
172 |
|
|
173 |
def _OnProjAvail(self, event): |
def _OnProjAvail(self, event): |
174 |
self.__DoOnProjAvail() |
self.__DoOnProjAvail() |
186 |
self.__usrProjFile.Add(proj) |
self.__usrProjFile.Add(proj) |
187 |
WriteProjFile(self.__usrProjFile) |
WriteProjFile(self.__usrProjFile) |
188 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
189 |
wxMessageDialog(self, |
self.__ShowError(dlg.GetPath(), errstr) |
|
_("The following error occured:\n") + |
|
|
dlg.GetPath() + "\n" + errstr, |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
|
190 |
|
|
191 |
self.__FillAvailList() |
self.__FillAvailList() |
192 |
|
|
193 |
dlg.Destroy() |
dlg.Destroy() |
194 |
|
|
195 |
def _OnExport(self, event): |
def _OnExport(self, event): |
|
proj = self.__GetProjection() |
|
196 |
|
|
197 |
if proj is None: return |
sel = self.availprojs.GetSelections() |
198 |
|
assert len(sel) != 0, "button should be disabled" |
199 |
|
|
200 |
dlg = wxFileDialog(self, _("Export"), |
dlg = wxFileDialog(self, _("Export"), |
201 |
style = wxSAVE|wxOVERWRITE_PROMPT) |
style = wxSAVE|wxOVERWRITE_PROMPT) |
202 |
|
|
203 |
if dlg.ShowModal() == wxID_OK: |
if dlg.ShowModal() == wxID_OK: |
204 |
path = dlg.GetPath() |
path = dlg.GetPath() |
205 |
|
|
206 |
projFile = ProjFile(path) |
projFile = ProjFile(path) |
207 |
projFile.Add(proj) |
|
208 |
|
for i in sel: |
209 |
|
proj = self.availprojs.GetClientData(i)[CLIENT_PROJ] |
210 |
|
if proj is not None: |
211 |
|
projFile.Add(proj) |
212 |
|
|
213 |
try: |
try: |
214 |
WriteProjFile(projFile) |
WriteProjFile(projFile) |
215 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
216 |
wxMessageDialog(self, |
self.__ShowError(dlg.GetPath(), errstr) |
|
_("The following error occured:\n") + |
|
|
dlg.GetPath() + "\n" + errstr, |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
|
217 |
|
|
218 |
dlg.Destroy() |
dlg.Destroy() |
219 |
|
|
248 |
try: |
try: |
249 |
WriteProjFile(projfile) |
WriteProjFile(projfile) |
250 |
except IOError, (errno, errstr): |
except IOError, (errno, errstr): |
251 |
wxMessageDialog(self, |
self.__ShowError(projfile.GetFilename(), errstr) |
|
_("The following error occured:\n") + |
|
|
projfile.GetFileName() + "\n" + errstr, |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
|
|
|
|
252 |
|
|
253 |
self.__FillAvailList() |
self.__FillAvailList() |
254 |
|
|
260 |
if newselection != -1 and self.availprojs.GetCount() > 0: |
if newselection != -1 and self.availprojs.GetCount() > 0: |
261 |
self.availprojs.SetSelection(newselection) |
self.availprojs.SetSelection(newselection) |
262 |
|
|
263 |
|
self.__VerifyButtons() |
264 |
|
|
265 |
def _OnProjName(self, event): |
def _OnProjName(self, event): |
266 |
self.__VerifyButtons() |
self.__VerifyButtons() |
267 |
|
|
268 |
|
def __ShowError(self, filename, errstr): |
269 |
|
wxMessageDialog(self, |
270 |
|
_("The following error occured:\n") + |
271 |
|
filename + "\n" + errstr, |
272 |
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
273 |
|
|
274 |
def __VerifyButtons(self): |
def __VerifyButtons(self): |
275 |
|
"""Enable or disable the appropriate buttons based on the |
276 |
|
current state of the dialog. |
277 |
|
""" |
278 |
|
|
279 |
sel = self.availprojs.GetSelections() |
sel = self.availprojs.GetSelections() |
280 |
|
|
281 |
self.button_import.Enable(True) |
self.button_import.Enable(True) |
285 |
|
|
286 |
self.panel_edit.Enable(True) |
self.panel_edit.Enable(True) |
287 |
|
|
288 |
|
for ctrl in [self.button_import, |
289 |
|
self.button_export, |
290 |
|
self.button_remove, |
291 |
|
self.button_save, |
292 |
|
self.button_add, |
293 |
|
self.projchoice, |
294 |
|
self.projname, |
295 |
|
self.panel_edit]: |
296 |
|
ctrl.Enable(True) |
297 |
|
|
298 |
|
if self.curProjPanel is not None: |
299 |
|
self.curProjPanel.Enable(True) |
300 |
|
|
301 |
if len(sel) == 0: |
if len(sel) == 0: |
302 |
self.button_import.Enable(True) |
self.button_import.Enable(True) |
303 |
self.button_export.Enable(False) |
self.button_export.Enable(False) |
311 |
self.button_add.Enable(len(self.projname.GetValue()) > 0) |
self.button_add.Enable(len(self.projname.GetValue()) > 0) |
312 |
|
|
313 |
if proj is None: |
if proj is None: |
314 |
self.button_export.Enable(False) |
# <None> is selected |
315 |
|
for ctrl in [self.button_export, |
316 |
|
self.button_remove, |
317 |
|
self.button_save, |
318 |
|
self.button_add, |
319 |
|
self.projchoice, |
320 |
|
self.projname]: |
321 |
|
ctrl.Enable(False) |
322 |
|
|
323 |
|
if self.curProjPanel is not None: |
324 |
|
self.curProjPanel.Enable(False) |
325 |
|
|
326 |
|
elif proj is self.originalProjection: |
327 |
self.button_remove.Enable(False) |
self.button_remove.Enable(False) |
328 |
|
|
329 |
if projFile is None: |
if projFile is None: |
332 |
else: |
else: |
333 |
self.panel_edit.Enable(False) |
self.panel_edit.Enable(False) |
334 |
|
|
|
def __DoOnNew(self): |
|
|
sel = self.availprojs.GetSelections() |
|
|
if len(sel) != 0: |
|
|
self.availprojs.SetSelection(sel, False) |
|
|
self.projname.Clear() |
|
|
self.curProjPanel.Clear() |
|
|
|
|
335 |
def __DoOnProjAvail(self): |
def __DoOnProjAvail(self): |
336 |
|
|
337 |
sel = self.availprojs.GetSelections() |
sel = self.availprojs.GetSelections() |
343 |
if proj is None: |
if proj is None: |
344 |
# user selected <None> |
# user selected <None> |
345 |
self.projname.Clear() |
self.projname.Clear() |
346 |
|
|
347 |
else: |
else: |
348 |
|
|
349 |
if projfile is not None: |
if projfile is not None: |
350 |
self.projfilepath.SetLabel(projfile.GetFileName()) |
self.projfilepath.SetLabel(projfile.GetFilename()) |
351 |
else: |
else: |
352 |
# only None if the currently used projection is selected |
# only None if the currently used projection is selected |
353 |
self.projfilepath.SetLabel("") |
self.projfilepath.SetLabel("") |
360 |
if myProjType == projType: |
if myProjType == projType: |
361 |
self.projchoice.SetSelection(i) |
self.projchoice.SetSelection(i) |
362 |
self.__DoOnProjChoice() |
self.__DoOnProjChoice() |
363 |
|
|
364 |
|
# |
365 |
|
# self.curProjPanel should not be null |
366 |
|
# after a call to __DoOnProjChoice |
367 |
|
# |
368 |
|
assert self.curProjPanel is not None |
369 |
|
|
370 |
self.curProjPanel.SetProjection(proj) |
self.curProjPanel.SetProjection(proj) |
371 |
i += 1 |
i += 1 |
372 |
|
|
376 |
self.__DoOnProjChoice() |
self.__DoOnProjChoice() |
377 |
|
|
378 |
def __DoOnProjChoice(self): |
def __DoOnProjChoice(self): |
379 |
|
"""Create and layout a projection panel based on the selected |
380 |
|
projection type. |
381 |
|
|
382 |
|
This is necessary to have in seperate method since calls to |
383 |
|
wxChoice.SetSelection() do not trigger an event. |
384 |
|
|
385 |
|
At the end of this method self.curProjPanel will not be None |
386 |
|
if there was a item selected. |
387 |
|
""" |
388 |
|
|
389 |
choice = self.projchoice |
choice = self.projchoice |
390 |
|
|
391 |
sel = choice.GetSelection() |
sel = choice.GetSelection() |
411 |
self.topBox.SetSizeHints(self) |
self.topBox.SetSizeHints(self) |
412 |
|
|
413 |
def __SetProjection(self): |
def __SetProjection(self): |
414 |
|
"""Set the receiver's projection.""" |
415 |
|
|
416 |
# |
# |
417 |
# save the original projection only once in case |
# save the original projection only once in case |
418 |
# we try to apply several different projections |
# we try to apply several different projections |
419 |
# |
# |
|
if self.originalProjection == -1: |
|
|
self.originalProjection = self.receiver.GetProjection() |
|
|
|
|
420 |
self.receiver.SetProjection(self.__GetProjection()) |
self.receiver.SetProjection(self.__GetProjection()) |
421 |
|
|
422 |
def __GetProjection(self): |
def __GetProjection(self): |
423 |
"""Return the packaged projection. |
"""Return a suitable Projection object based on the current |
424 |
|
state of the dialog box selections. |
425 |
|
|
426 |
Could be None. |
Could be None. |
427 |
""" |
""" |
428 |
|
|
429 |
proj = None |
sel = self.availprojs.GetSelections() |
430 |
|
assert len(sel) < 2, "button should be disabled" |
431 |
|
|
432 |
|
|
433 |
|
if len(sel) == 1: |
434 |
|
proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ] |
435 |
|
if proj is None: |
436 |
|
# <None> is selected |
437 |
|
return None |
438 |
|
|
439 |
|
# |
440 |
|
# self.curProjPanel should always contain the most |
441 |
|
# relevant data for a projection |
442 |
|
# |
443 |
if self.curProjPanel is not None: |
if self.curProjPanel is not None: |
444 |
proj = Projection(self.curProjPanel.GetParameters()) |
return Projection(self.curProjPanel.GetParameters(), |
445 |
proj.SetName(self.projname.GetValue()) |
self.projname.GetValue()) |
446 |
|
|
447 |
return proj |
return None |
448 |
|
|
449 |
|
def __FillAvailList(self, selectCurrent = False): |
450 |
|
"""Populate the list of available projections. |
451 |
|
|
452 |
|
selectCurrent -- if True, select the projection used by |
453 |
|
the receiver, otherwise select nothing. |
454 |
|
""" |
455 |
|
|
|
def __FillAvailList(self): |
|
456 |
self.availprojs.Clear() |
self.availprojs.Clear() |
457 |
|
|
458 |
# |
# |
459 |
|
# We add the current projection to the list first so that |
460 |
|
# we are sure that it's at index 0. That way we can |
461 |
|
# set the selection with confidence. The problem is the |
462 |
|
# the list is automatically sorted when an item is appended |
463 |
|
# and the index of where it was inserted is not returned. |
464 |
|
# |
465 |
|
proj = self.receiver.GetProjection() |
466 |
|
if proj is not None: |
467 |
|
self.availprojs.Append(_("%s (current)") % proj.GetName(), |
468 |
|
[proj, None]) |
469 |
|
if selectCurrent: |
470 |
|
self.availprojs.SetSelection(0) |
471 |
|
self.availprojs.SetFirstItem(0) |
472 |
|
|
473 |
|
# |
474 |
# the list can never be empty. there will always be |
# the list can never be empty. there will always be |
475 |
# at least this one item |
# at least this one item |
476 |
# |
# |
477 |
self.availprojs.Append("<None>", (None, None)) |
self.availprojs.Append("<None>", (None, None)) |
478 |
|
|
479 |
self.__sysProjFile = None |
# proj is only None when <None> should be selected |
480 |
self.__usrProjFile = None |
if proj is None and selectCurrent: |
481 |
|
self.availprojs.SetSelection(0) |
482 |
|
self.availprojs.SetFirstItem(0) |
483 |
|
|
484 |
projfile = GetSystemProjFiles() |
projfile = GetSystemProjFiles() |
485 |
if len(projfile) > 0: |
projfile = projfile[0] |
486 |
projfile = projfile[0] |
for proj in projfile.GetProjections(): |
487 |
for proj in projfile.GetProjections(): |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
488 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
self.__sysProjFile = projfile |
|
self.__sysProjFile = projfile |
|
489 |
|
|
490 |
projfile = GetUserProjFiles() |
projfile = GetUserProjFiles() |
491 |
if len(projfile) > 0: |
projfile = projfile[0] |
492 |
projfile = projfile[0] |
for proj in projfile.GetProjections(): |
493 |
for proj in projfile.GetProjections(): |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
494 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
self.__usrProjFile = projfile |
|
self.__usrProjFile = projfile |
|
|
|
|
|
# projfiles = GetSystemProjFiles() |
|
|
# for projfile in projfiles: |
|
|
# for proj in projfile.GetProjections(): |
|
|
# self.availprojs.Append(proj.GetName(), [proj, projfile]) |
|
|
# self.__sysProjFiles = projfiles |
|
|
|
|
|
# projfiles = GetUserProjFiles() |
|
|
# for projfile in projfiles: |
|
|
# for proj in projfile.GetProjections(): |
|
|
# self.availprojs.Append(proj.GetName(), [proj, projfile]) |
|
|
# self.__usrProjFiles = projfiles |
|
|
|
|
|
proj = self.receiver.GetProjection() |
|
|
if proj is not None: |
|
|
self.availprojs.Append(proj.GetName() + _(" (current)"), |
|
|
[proj, None]) |
|
495 |
|
|
496 |
for proj, name, clazz in self.projPanels: |
for proj, name, clazz in self.projPanels: |
497 |
self.projchoice.Append(name, [clazz, None]) |
self.projchoice.Append(name, [clazz, None]) |
498 |
|
|
499 |
def __set_properties(self): |
def __set_properties(self): |
|
self.__FillAvailList() |
|
500 |
|
|
501 |
# begin wxGlade: ProjFrame.__set_properties |
#self.availprojs.SetSelection(0) |
|
self.SetTitle(_("Projections")) |
|
|
self.availprojs.SetSelection(0) |
|
502 |
self.projchoice.SetSelection(0) |
self.projchoice.SetSelection(0) |
503 |
# end wxGlade |
|
504 |
|
self.__FillAvailList(selectCurrent = True) |
505 |
|
|
506 |
self.projname.SetMaxLength(32) |
self.projname.SetMaxLength(32) |
507 |
|
|