[Thuban-commits] r2700 - in trunk/thuban/Thuban: . UI
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Sep 18 16:27:03 CEST 2006
Author: dpinte
Date: 2006-09-18 16:27:02 +0200 (Mon, 18 Sep 2006)
New Revision: 2700
Modified:
trunk/thuban/Thuban/UI/__init__.py
trunk/thuban/Thuban/UI/about.py
trunk/thuban/Thuban/UI/altpathdialog.py
trunk/thuban/Thuban/UI/application.py
trunk/thuban/Thuban/UI/baserenderer.py
trunk/thuban/Thuban/UI/classgen.py
trunk/thuban/Thuban/UI/classifier.py
trunk/thuban/Thuban/UI/colordialog.py
trunk/thuban/Thuban/UI/command.py
trunk/thuban/Thuban/UI/common.py
trunk/thuban/Thuban/UI/controls.py
trunk/thuban/Thuban/UI/dbdialog.py
trunk/thuban/Thuban/UI/dialogs.py
trunk/thuban/Thuban/UI/dock.py
trunk/thuban/Thuban/UI/exceptiondialog.py
trunk/thuban/Thuban/UI/identifyview.py
trunk/thuban/Thuban/UI/join.py
trunk/thuban/Thuban/UI/labeldialog.py
trunk/thuban/Thuban/UI/layerproperties.py
trunk/thuban/Thuban/UI/legend.py
trunk/thuban/Thuban/UI/main.py
trunk/thuban/Thuban/UI/mainwindow.py
trunk/thuban/Thuban/UI/multiplechoicedialog.py
trunk/thuban/Thuban/UI/projdialog.py
trunk/thuban/Thuban/UI/projlist.py
trunk/thuban/Thuban/UI/rasterlayerproperties.py
trunk/thuban/Thuban/UI/renderer.py
trunk/thuban/Thuban/UI/resource.py
trunk/thuban/Thuban/UI/scalebar.py
trunk/thuban/Thuban/UI/sizers.py
trunk/thuban/Thuban/UI/tableview.py
trunk/thuban/Thuban/UI/tree.py
trunk/thuban/Thuban/UI/view.py
trunk/thuban/Thuban/UI/viewport.py
trunk/thuban/Thuban/version.py
Log:
2006-09-18 Didrik Pinte <dpinte at itae.be>
* wxPython 2.6 update : wx 2.4 syntax has been updated to 2.6
Modified: trunk/thuban/Thuban/UI/__init__.py
===================================================================
--- trunk/thuban/Thuban/UI/__init__.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/__init__.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -18,9 +18,9 @@
if not Thuban.translation_function_installed():
# Only import wx modules when we actually can install the
# function so that the test suite can inhibit this
- import wxPython.wx as wx
- wx.wxLocale_AddCatalogLookupPathPrefix(Thuban._message_dir)
- _locale = wx.wxLocale()
+ import wx
+ wx.Locale_AddCatalogLookupPathPrefix(Thuban._message_dir)
+ _locale = wx.Locale()
_locale.AddCatalog("thuban")
# With a unicode build of wxPython, wxGetTranslation returns a
@@ -33,7 +33,7 @@
# provided the internal encoding used is the one expected by
# wxPython, which is taken care of below.
def thuban_wx_translation(s):
- t = wx.wxGetTranslation(s)
+ t = wx.GetTranslation(s)
if isinstance(t, unicode) and Thuban._internal_encoding!="unicode":
t = t.encode(Thuban._internal_encoding, "replace")
return t
@@ -55,10 +55,10 @@
# If we have a wxPython >= 2.5.4.1, we use the
# GetDefaultPyEncoding function to use exactly what wxPython
# also uses when converting between unicode and byte-strings ...
- if hasattr(wx, "wxGetDefaultPyEncoding"):
+ if hasattr(wx, "GetDefaultPyEncoding"):
# AFAICT from the code this will always be a usable string,
# although it could be "ascii".
- internal_encoding = wx.wxGetDefaultPyEncoding()
+ internal_encoding = wx.GetDefaultPyEncoding()
# ... otherwise we use Python's getdefaultlocale. This is what
# GetDefaultPyEncoding also uses ...
Modified: trunk/thuban/Thuban/UI/about.py
===================================================================
--- trunk/thuban/Thuban/UI/about.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/about.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -13,7 +13,7 @@
# $Source$
# $Id$
-from wxPython.wx import *
+import wx
from Thuban import _, internal_from_unicode, get_internal_encoding
from Thuban.version import versions
@@ -21,15 +21,15 @@
from Thuban.UI.extensionregistry import ext_registry
-class About(wxDialog):
+class About(wx.Dialog):
def __init__(self, parent):
- wxDialog.__init__(self, parent, -1, _("About Thuban"),
- style = wxDEFAULT_DIALOG_STYLE
- | wxSYSTEM_MENU
- | wxMINIMIZE_BOX
- | wxMAXIMIZE_BOX
- | wxRESIZE_BORDER,
+ wx.Dialog.__init__(self, parent, -1, _("About Thuban"),
+ style = wx.DEFAULT_DIALOG_STYLE
+ | wx.SYSTEM_MENU
+ | wx.MINIMIZE_BOX
+ | wx.MAXIMIZE_BOX
+ | wx.RESIZE_BORDER,
size = (400, 250))
# Note: The source code is in ASCII, so we escape some
@@ -136,25 +136,25 @@
self.text = text
- text_title = wxStaticText(self, -1,
+ text_title = wx.StaticText(self, -1,
_("Thuban is a program for exploring geographic data.\n\n") +
"Copyright 2001-2006 Intevation GmbH.\n" +
_("Thuban is licensed under the GNU GPL"),
- style=wxST_NO_AUTORESIZE|wxALIGN_CENTRE)
+ style=wx.ST_NO_AUTORESIZE|wx.ALIGN_CENTRE)
- textBox = wxTextCtrl(self, -1, text,
- style=wxTE_READONLY|wxTE_MULTILINE|wxTE_LINEWRAP)
+ textBox = wx.TextCtrl(self, -1, text,
+ style=wx.TE_READONLY|wx.TE_MULTILINE|wx.TE_LINEWRAP)
w, h = (300, 150)
textBox.SetSizeHints(w, h)
textBox.SetSize((w, h))
- button_close = wxButton(self, wxID_CANCEL, _("Close"))
+ button_close = wx.Button(self, wx.ID_CANCEL, _("Close"))
button_close.SetDefault()
- sizer = wxBoxSizer(wxVERTICAL)
- sizer.Add(text_title, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 10)
- sizer.Add(textBox, 1, wxALL|wxEXPAND, 10)
- sizer.Add(button_close, 0, wxALL|wxALIGN_RIGHT, 10)
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ sizer.Add(text_title, 0, wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
+ sizer.Add(textBox, 1, wx.ALL|wx.EXPAND, 10)
+ sizer.Add(button_close, 0, wx.ALL|wx.ALIGN_RIGHT, 10)
self.SetAutoLayout(True)
self.SetSizer(sizer)
@@ -162,7 +162,7 @@
sizer.SetSizeHints(self)
self.Layout()
- EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
def OnCancel(self, event):
- self.EndModal(wxID_CANCEL)
+ self.EndModal(wx.ID_CANCEL)
Modified: trunk/thuban/Thuban/UI/altpathdialog.py
===================================================================
--- trunk/thuban/Thuban/UI/altpathdialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/altpathdialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -14,49 +14,47 @@
from Thuban import _
-from wxPython.wx import wxFileDialog, wxMessageDialog, wxOPEN, \
- wxYES_NO, wxYES_DEFAULT, wxICON_INFORMATION, \
- wxID_OK, wxID_YES
+import wx
import os
-class AltPathFileDialog(wxFileDialog):
+class AltPathFileDialog(wx.FileDialog):
def __init__(self, filename):
msg = _("Select an alternative data file for %s" % \
os.path.basename(filename))
-
- wxFileDialog.__init__(self, None,
- msg,
- os.path.dirname(filename),
+
+ wx.FileDialog.__init__(self, None,
+ msg,
+ os.path.dirname(filename),
os.path.basename(filename),
_("Shapefiles (*.shp)") + "|*.shp;*.SHP|" +
_("All Files (*.*)") + "|*.*",
- wxOPEN)
+ wx.OPEN)
def RunDialog(self):
val = self.ShowModal()
self.Destroy()
- if val == wxID_OK:
+ if val == wx.ID_OK:
return self.GetPaths()[0]
else:
return None
-class AltPathConfirmDialog(wxMessageDialog):
+class AltPathConfirmDialog(wx.MessageDialog):
def __init__(self, filename):
self.filename = filename
msg = _("Found the following as an alternative for %s.\n%s\n\n Please confirm with Yes or select alternative with No." % (os.path.basename(filename), filename))
-
- wxMessageDialog.__init__(self, None, msg, _("Alternative Path"),
- wxYES_NO|wxYES_DEFAULT|wxICON_INFORMATION)
+ wx.MessageDialog.__init__(self, None, msg, _("Alternative Path"),
+ wx.YES_NO|wx.YES_DEFAULT|wx.ICON_INFORMATION)
+
def RunDialog(self):
val = self.ShowModal()
self.Destroy()
- if val == wxID_YES:
+ if val == wx.ID_YES:
return self.filename
else:
dlg = AltPathFileDialog(self.filename)
fname = dlg.RunDialog()
- return fname
+ return fname
Modified: trunk/thuban/Thuban/UI/application.py
===================================================================
--- trunk/thuban/Thuban/UI/application.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/application.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -17,7 +17,7 @@
import traceback
-from wxPython.wx import *
+import wx
from Thuban.Lib.connector import Publisher
from Thuban.Lib.fileutil import get_application_dir
@@ -42,7 +42,7 @@
from messages import SESSION_REPLACED
-class ThubanApplication(wxApp, Publisher):
+class ThubanApplication(wx.App, Publisher):
"""
Thuban's application class.
@@ -165,7 +165,7 @@
"""
msg = (_("This is the wxPython-based Graphical User Interface"
" for exploring geographic data"))
- return mainwindow.MainWindow(NULL, -1, "Thuban", self, None,
+ return mainwindow.MainWindow(None, -1, "Thuban", self, None,
initial_message = msg,
size = (600, 400))
@@ -254,10 +254,10 @@
msg = _("The current session contains Image layers,\n"
"but the GDAL library is not available to "
"draw them.")
- dlg = wxMessageDialog(None,
+ dlg = wx.MessageDialog(None,
msg,
_("Library not available"),
- wxOK | wxICON_INFORMATION)
+ wx.OK | wx.ICON_INFORMATION)
print msg
dlg.ShowModal()
dlg.Destroy()
@@ -300,7 +300,7 @@
dlg = altpathdialog.AltPathFileDialog(filename)
fname = dlg.RunDialog()
if fname is not None:
- self.SetPath('alt_path', fname)
+ self.SetPath('alt_path', fname)
from_list = 0
else:
fname = os.path.join(self.Path('alt_path'),
@@ -355,8 +355,8 @@
if self.in_exception_dialog:
return
self.in_exception_dialog = 1
- while wxIsBusy():
- wxEndBusyCursor() # reset the mouse cursor
+ while wx.IsBusy():
+ wx.EndBusyCursor() # reset the mouse cursor
try:
lines = traceback.format_exception(exc_type, exc_value,
Modified: trunk/thuban/Thuban/UI/baserenderer.py
===================================================================
--- trunk/thuban/Thuban/UI/baserenderer.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/baserenderer.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -454,7 +454,7 @@
# True -- warp the image to the size of the whole screen
# False -- only use the bound box of the layer (currently inaccurate)
- if True:
+ if True:
#if False:
pmin = [0,height]
pmax = [width, 0]
@@ -466,10 +466,10 @@
#print bb
#print pmin, pmax
- fmin = [max(0, min(pmin[0], pmax[0])) - offx,
+ fmin = [max(0, min(pmin[0], pmax[0])) - offx,
offy - min(height, max(pmin[1], pmax[1]))]
- fmax = [min(width, max(pmin[0], pmax[0])) - offx,
+ fmax = [min(width, max(pmin[0], pmax[0])) - offx,
offy - max(0, min(pmin[1], pmax[1]))]
xmin = fmin[0]/self.scale
@@ -483,12 +483,12 @@
options = 0
options = options | layer.MaskType()
- img_data = self.projected_raster_layer(layer, in_proj, out_proj,
+ img_data = self.projected_raster_layer(layer, in_proj, out_proj,
(xmin,ymin,xmax,ymax), [0,0], (width, height), options)
if img_data is not None:
data = (width, height, img_data)
- self.draw_raster_data(fmin[0]+offx, offy-fmax[1],
+ self.draw_raster_data(fmin[0]+offx, offy-fmax[1],
data, format="RAW", opacity=layer.Opacity())
data = None
Modified: trunk/thuban/Thuban/UI/classgen.py
===================================================================
--- trunk/thuban/Thuban/UI/classgen.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/classgen.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -14,7 +14,7 @@
import sys
-from wxPython.wx import *
+import wx
from Thuban import _
@@ -58,7 +58,7 @@
ID_BORDER_COLOR = 4009
ID_BORDER_COLOR_CHANGE = 4010
-class ClassGenDialog(wxDialog):
+class ClassGenDialog(wx.Dialog):
def __init__(self, parent, layer, fieldName):
"""Inialize the class generating dialog.
@@ -66,8 +66,8 @@
parent -- this must be an instance of the Classifier class
"""
- wxDialog.__init__(self, parent, -1, _("Generate Classification"),
- style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ wx.Dialog.__init__(self, parent, -1, _("Generate Classification"),
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
self.parent = parent
self.layer = layer
@@ -87,11 +87,11 @@
# we need to create genButton first because when we create the
# panels they will call AllowGenerate() which uses genButton.
#
- self.genButton = wxButton(self, wxID_OK, _("Generate"))
- self.cancelButton = wxButton(self, wxID_CANCEL, _("Close"))
+ self.genButton = wx.Button(self, wx.ID_OK, _("Generate"))
+ self.cancelButton = wx.Button(self, wx.ID_CANCEL, _("Close"))
self.genButton.SetDefault()
- self.genChoice = wxChoice(self, ID_CLASSGEN_GENCOMBO)
+ self.genChoice = wx.Choice(self, ID_CLASSGEN_GENCOMBO)
self.genpanels.append((GENCOMBOSTR_UNIQUE, GenUniquePanel))
if self.type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE):
@@ -114,31 +114,31 @@
#############
- sizer = wxBoxSizer(wxVERTICAL)
+ sizer = wx.BoxSizer(wx.VERTICAL)
- sizer.Add(wxStaticText(self, -1, _("Field: %s") % fieldName),
- 0, wxALL, 4)
- sizer.Add(wxStaticText(
- self, -1,
+ sizer.Add(wx.StaticText(self, -1, _("Field: %s") % fieldName),
+ 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(
+ self, -1,
_("Data Type: %s") % classifier.Classifier.type2string[self.type]),
- 0, wxALL, 4)
+ 0, wx.ALL, 4)
- psizer = wxBoxSizer(wxHORIZONTAL)
- psizer.Add(wxStaticText(self, -1, _("Generate:")),
- 0, wxALIGN_CENTER_VERTICAL, 0)
- psizer.Add(self.genChoice, 1, wxALL | wxGROW, 4)
+ psizer = wx.BoxSizer(wx.HORIZONTAL)
+ psizer.Add(wx.StaticText(self, -1, _("Generate:")),
+ 0, wx.ALIGN_CENTER_VERTICAL, 0)
+ psizer.Add(self.genChoice, 1, wx.ALL | wx.GROW, 4)
- sizer.Add(psizer, 0, wxALL | wxGROW, 4)
+ sizer.Add(psizer, 0, wx.ALL | wx.GROW, 4)
- self.sizer_genPanel = wxBoxSizer(wxVERTICAL)
- sizer.Add(self.sizer_genPanel, 1, wxGROW | wxALL, 4)
+ self.sizer_genPanel = wx.BoxSizer(wx.VERTICAL)
+ sizer.Add(self.sizer_genPanel, 1, wx.GROW | wx.ALL, 4)
- psizer = wxBoxSizer(wxHORIZONTAL)
- psizer.Add(wxStaticText(self, -1, _("Color Scheme:")),
- 0, wxALIGN_CENTER_VERTICAL, 0)
+ psizer = wx.BoxSizer(wx.HORIZONTAL)
+ psizer.Add(wx.StaticText(self, -1, _("Color Scheme:")),
+ 0, wx.ALIGN_CENTER_VERTICAL, 0)
# Properties (Ramp) ComboBox
- self.propCombo = wxChoice(self, ID_CLASSGEN_PROPCOMBO)
+ self.propCombo = wx.Choice(self, ID_CLASSGEN_PROPCOMBO)
self.propPanel = None
custom_ramp_panel = CustomRampPanel(self, layer.ShapeType())
@@ -153,33 +153,33 @@
self.propCombo.SetSelection(0)
- psizer.Add(self.propCombo, 1, wxALL | wxGROW, 4)
- sizer.Add(psizer, 0, wxALL | wxGROW, 4)
+ psizer.Add(self.propCombo, 1, wx.ALL | wx.GROW, 4)
+ sizer.Add(psizer, 0, wx.ALL | wx.GROW, 4)
if layer.ShapeType() != SHAPETYPE_ARC:
- psizer = wxBoxSizer(wxHORIZONTAL)
- self.fix_border_check = wxCheckBox(self, -1, _("Fix Border Color"))
- psizer.Add(self.fix_border_check, 0, wxALL | wxGROW, 4)
+ psizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.fix_border_check = wx.CheckBox(self, -1, _("Fix Border Color"))
+ psizer.Add(self.fix_border_check, 0, wx.ALL | wx.GROW, 4)
self.border_color = classifier.ClassGroupPropertiesCtrl(
self, ID_BORDER_COLOR,
ClassGroupProperties(), SHAPETYPE_ARC,
- style=wxSIMPLE_BORDER, size=(40, 20))
- psizer.Add(self.border_color, 0, wxALL | wxGROW, 4)
- psizer.Add(wxButton(self, ID_BORDER_COLOR_CHANGE, _("Change")),
- 0, wxALL, 4)
- sizer.Add(psizer, 0, wxALL | wxGROW, 4)
- EVT_BUTTON(self, ID_BORDER_COLOR_CHANGE, self.OnBorderColorChange)
+ style=wx.SIMPLE_BORDER, size=(40, 20))
+ psizer.Add(self.border_color, 0, wx.ALL | wx.GROW, 4)
+ psizer.Add(wx.Button(self, ID_BORDER_COLOR_CHANGE, _("Change")),
+ 0, wx.ALL, 4)
+ sizer.Add(psizer, 0, wx.ALL | wx.GROW, 4)
+ self.Bind(wx.EVT_BUTTON, self.OnBorderColorChange, id=ID_BORDER_COLOR_CHANGE)
else:
self.border_color = None
- sizer.Add(custom_ramp_panel, 1, wxGROW | wxALL, 4)
+ sizer.Add(custom_ramp_panel, 1, wx.GROW | wx.ALL, 4)
sizer.Show(custom_ramp_panel, False)
# Finally place the main buttons
- buttonSizer = wxBoxSizer(wxHORIZONTAL)
- buttonSizer.Add(self.genButton, 0, wxRIGHT|wxEXPAND, 10)
- buttonSizer.Add(self.cancelButton, 0, wxRIGHT|wxEXPAND, 10)
- sizer.Add(buttonSizer, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10)
+ buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
+ buttonSizer.Add(self.genButton, 0, wx.RIGHT|wx.EXPAND, 10)
+ buttonSizer.Add(self.cancelButton, 0, wx.RIGHT|wx.EXPAND, 10)
+ sizer.Add(buttonSizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM|wx.TOP, 10)
self.SetSizer(sizer)
self.SetAutoLayout(True)
@@ -189,10 +189,10 @@
self.__DoOnGenTypeSelect()
- EVT_CHOICE(self, ID_CLASSGEN_GENCOMBO, self._OnGenTypeSelect)
- EVT_CHOICE(self, ID_CLASSGEN_PROPCOMBO, self._OnPropTypeSelect)
- EVT_BUTTON(self, wxID_OK, self.OnOK)
- EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
+ self.Bind(wx.EVT_CHOICE, self._OnGenTypeSelect, id=ID_CLASSGEN_GENCOMBO)
+ self.Bind(wx.EVT_CHOICE, self._OnPropTypeSelect, id=ID_CLASSGEN_PROPCOMBO)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, self, id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, self, id=wx.ID_CANCEL)
self.__DoOnGenTypeSelect()
@@ -232,7 +232,7 @@
ramp = propPanel.GetRamp()
if self.border_color and self.fix_border_check.IsChecked():
props = self.border_color.GetProperties()
- ramp = FixedRamp(ramp,
+ ramp = FixedRamp(ramp,
(props.GetLineColor(), props.GetLineWidth(), None))
if genSel == GENCOMBOSTR_UNIFORM:
@@ -270,14 +270,14 @@
generate_quantiles(_list, percents, ramp, _range)
if adjusted:
- dlg = wxMessageDialog(self,
+ dlg = wx.MessageDialog(self,
_("Based on the data from the table and the input\n"
"values, the exact quantiles could not be generated.\n\n"
"Accept a close estimate?"),
_("Problem with Quantiles"),
- wxYES_NO|wxYES_DEFAULT|wxICON_QUESTION)
- if dlg.ShowModal() == wxID_YES:
+ wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION)
+ if dlg.ShowModal() == wx.ID_YES:
self.parent._SetClassification(self.clazz)
else:
self.parent._SetClassification(self.clazz)
@@ -312,12 +312,12 @@
selIndex = combo.GetSelection()
sel = combo.GetString(selIndex)
- if isinstance(self.propPanel, wxPanel):
+ if isinstance(self.propPanel, wx.Panel):
self.topBox.Show(self.propPanel, False)
self.propPanel = combo.GetClientData(selIndex)
- if isinstance(self.propPanel, wxPanel):
+ if isinstance(self.propPanel, wx.Panel):
self.topBox.Show(self.propPanel, True)
self.topBox.SetSizeHints(self)
@@ -339,7 +339,7 @@
self.curGenPanel.Show()
self.sizer_genPanel.Add(self.curGenPanel, 1,
- wxALL|wxEXPAND|wxADJUST_MINSIZE, 3)
+ wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 3)
self.sizer_genPanel.Layout()
self.Layout()
self.topBox.SetSizeHints(self)
@@ -350,56 +350,56 @@
ID_UNIFORM_STEP = 4004
ID_UNIFORM_RETRIEVE = 4005
-class GenUniformPanel(wxPanel):
+class GenUniformPanel(wx.Panel):
def __init__(self, parent, layer, fieldName, fieldType):
- wxPanel.__init__(self, parent, -1)
+ wx.Panel.__init__(self, parent, -1)
self.parent = parent
self.layer = layer
self.fieldName = fieldName
self.fieldType = fieldType
- topSizer = wxStaticBoxSizer(wxStaticBox(self, -1, ""),
- wxVERTICAL)
+ topSizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, ""),
+ wx.VERTICAL)
#############
- sizer = wxBoxSizer(wxHORIZONTAL)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
- sizer.Add(wxStaticText(self, -1, _("Min:")), 0, wxALL, 4)
- self.minCtrl = wxTextCtrl(self, ID_UNIFORM_MIN, style=wxTE_RIGHT)
- sizer.Add(self.minCtrl, 1, wxALL, 4)
- EVT_TEXT(self, ID_UNIFORM_MIN, self._OnRangeChanged)
+ sizer.Add(wx.StaticText(self, -1, _("Min:")), 0, wx.ALL, 4)
+ self.minCtrl = wx.TextCtrl(self, ID_UNIFORM_MIN, style=wx.TE_RIGHT)
+ sizer.Add(self.minCtrl, 1, wx.ALL, 4)
+ self.Bind(wx.EVT_TEXT, self._OnRangeChanged, id=ID_UNIFORM_MIN)
- sizer.Add(wxStaticText(self, -1, _("Max:")), 0, wxALL, 4)
- self.maxCtrl = wxTextCtrl(self, ID_UNIFORM_MAX, style=wxTE_RIGHT)
- sizer.Add(self.maxCtrl, 1, wxALL, 4)
- EVT_TEXT(self, ID_UNIFORM_MAX, self._OnRangeChanged)
+ sizer.Add(wx.StaticText(self, -1, _("Max:")), 0, wx.ALL, 4)
+ self.maxCtrl = wx.TextCtrl(self, ID_UNIFORM_MAX, style=wx.TE_RIGHT)
+ sizer.Add(self.maxCtrl, 1, wx.ALL, 4)
+ self.Bind(wx.EVT_TEXT, self._OnRangeChanged, id=ID_UNIFORM_MAX)
- sizer.Add(wxButton(self, ID_UNIFORM_RETRIEVE, _("Retrieve From Table")),
- 0, wxALL, 4)
- EVT_BUTTON(self, ID_UNIFORM_RETRIEVE, self._OnRetrieve)
+ sizer.Add(wx.Button(self, ID_UNIFORM_RETRIEVE, _("Retrieve From Table")),
+ 0, wx.ALL, 4)
+ self.Bind(wx.EVT_BUTTON, self._OnRetrieve, id=ID_UNIFORM_RETRIEVE)
- topSizer.Add(sizer, 1, wxGROW, 0)
+ topSizer.Add(sizer, 1, wx.GROW, 0)
#############
- sizer = wxBoxSizer(wxHORIZONTAL)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
- sizer.Add(wxStaticText(self, -1, _("Number of Groups:")), 0, wxALL, 4)
- self.numGroupsCtrl = wxSpinCtrl(self, ID_UNIFORM_NGROUPS,
- style=wxTE_RIGHT)
- EVT_TEXT(self, ID_UNIFORM_NGROUPS, self._OnNumGroupsChanged)
- EVT_SPINCTRL(self, ID_UNIFORM_NGROUPS, self._OnNumGroupsChanged)
- sizer.Add(self.numGroupsCtrl, 1, wxALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Number of Groups:")), 0, wx.ALL, 4)
+ self.numGroupsCtrl = wx.SpinCtrl(self, ID_UNIFORM_NGROUPS,
+ style=wx.TE_RIGHT)
+ self.Bind(wx.EVT_TEXT, self._OnNumGroupsChanged, id=ID_UNIFORM_NGROUPS)
+ self.Bind(wx.EVT_SPINCTRL, self._OnNumGroupsChanged, id=ID_UNIFORM_NGROUPS)
+ sizer.Add(self.numGroupsCtrl, 1, wx.ALL, 4)
- sizer.Add(wxStaticText(self, -1, _("Stepping:")), 0, wxALL, 4)
- self.stepCtrl = wxTextCtrl(self, ID_UNIFORM_STEP, style=wxTE_RIGHT)
- EVT_TEXT(self, ID_UNIFORM_STEP, self._OnSteppingChanged)
- sizer.Add(self.stepCtrl , 1, wxALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Stepping:")), 0, wx.ALL, 4)
+ self.stepCtrl = wx.TextCtrl(self, ID_UNIFORM_STEP, style=wx.TE_RIGHT)
+ self.Bind(wx.EVT_TEXT, self._OnSteppingChanged, id=ID_UNIFORM_STEP)
+ sizer.Add(self.stepCtrl , 1, wx.ALL, 4)
- topSizer.Add(sizer, 1, wxGROW, 0)
+ topSizer.Add(sizer, 1, wx.GROW, 0)
#############
@@ -420,14 +420,14 @@
def GetNumGroups(self):
value = self.numGroupsCtrl.GetValue()
- return self.__GetValidatedTypeEntry(self.numGroupsCtrl,
+ return self.__GetValidatedTypeEntry(self.numGroupsCtrl,
value,
FIELDTYPE_INT,
None)
def GetStepping(self):
step = self.stepCtrl.GetValue()
- return self.__GetValidatedTypeEntry(self.stepCtrl,
+ return self.__GetValidatedTypeEntry(self.stepCtrl,
step,
self.fieldType,
0)
@@ -435,7 +435,7 @@
def GetMin(self):
min = self.minCtrl.GetValue()
max = self.maxCtrl.GetValue()
- return self.__GetValidatedTypeEntry(self.minCtrl,
+ return self.__GetValidatedTypeEntry(self.minCtrl,
min,
self.fieldType,
max)
@@ -443,14 +443,14 @@
def GetMax(self):
min = self.minCtrl.GetValue()
max = self.maxCtrl.GetValue()
- return self.__GetValidatedTypeEntry(self.maxCtrl,
+ return self.__GetValidatedTypeEntry(self.maxCtrl,
max,
self.fieldType,
min)
def _OnRangeChanged(self, event):
- hasFocus = wxWindow_FindFocus() == event.GetEventObject()
+ hasFocus = wx.Window_FindFocus() == event.GetEventObject()
min = self.GetMin()
max = self.GetMax()
@@ -548,7 +548,7 @@
def __GetValidatedTypeEntry(self, win, value, type, badValue = None):
- if type == FIELDTYPE_INT:
+ if type == FIELDTYPE_INT:
func = int
elif type == FIELDTYPE_DOUBLE:
func = float
@@ -577,9 +577,9 @@
valid = False
if valid:
- win.SetForegroundColour(wxBLACK)
+ win.SetForegroundColour(wx.BLACK)
else:
- win.SetForegroundColour(wxRED)
+ win.SetForegroundColour(wx.RED)
win.Refresh()
@@ -614,93 +614,93 @@
ID_UNIQUE_REVAVAIL = 4008
ID_UNIQUE_REVUSE = 4009
-class GenUniquePanel(wxPanel):
+class GenUniquePanel(wx.Panel):
def __init__(self, parent, layer, fieldName, fieldType):
- wxPanel.__init__(self, parent, -1)
+ wx.Panel.__init__(self, parent, -1)
self.parent = parent
self.layer = layer
self.fieldName = fieldName
self.fieldType = fieldType
- topSizer = wxStaticBoxSizer(wxStaticBox(self, -1, ""),
- wxVERTICAL)
+ topSizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, ""),
+ wx.VERTICAL)
#bsizer = wxBoxSizer(wxVERTICAL)
- topSizer.Add(wxButton(self, ID_UNIQUE_RETRIEVE,
- _("Retrieve From Table")),
- 0, wxALL | wxALIGN_RIGHT, 4)
+ topSizer.Add(wx.Button(self, ID_UNIQUE_RETRIEVE,
+ _("Retrieve From Table")),
+ 0, wx.ALL | wx.ALIGN_RIGHT, 4)
- EVT_BUTTON(self, ID_UNIQUE_RETRIEVE, self._OnRetrieve)
+ self.Bind(wx.EVT_BUTTON, self._OnRetrieve, id=ID_UNIQUE_RETRIEVE)
- #topSizer.Add(bsizer, 0, wxALL, 4)
+ #topSizer.Add(bsizer, 0, wx.ALL, 4)
- sizer = wxBoxSizer(wxHORIZONTAL)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
self.dataList = []
- psizer = wxBoxSizer(wxVERTICAL)
- self.list_avail = wxListCtrl(self, -1,
- style=wxLC_REPORT | wxLC_SINGLE_SEL)
+ psizer = wx.BoxSizer(wx.VERTICAL)
+ self.list_avail = wx.ListCtrl(self, -1,
+ style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
self.list_avail.InsertColumn(0, _("Available"))
self.list_avail_data = []
- psizer.Add(self.list_avail, 1, wxGROW, 0)
+ psizer.Add(self.list_avail, 1, wx.GROW, 0)
- bsizer = wxBoxSizer(wxHORIZONTAL)
- bsizer.Add(wxButton(self, ID_UNIQUE_SORTAVAIL, _("Sort")))
- EVT_BUTTON(self, ID_UNIQUE_SORTAVAIL, self._OnSortList)
+ bsizer = wx.BoxSizer(wx.HORIZONTAL)
+ bsizer.Add(wx.Button(self, ID_UNIQUE_SORTAVAIL, _("Sort")))
+ self.Bind(wx.EVT_BUTTON, self._OnSortList, id=ID_UNIQUE_SORTAVAIL)
- bsizer.Add(wxButton(self, ID_UNIQUE_REVAVAIL, _("Reverse")))
- EVT_BUTTON(self, ID_UNIQUE_REVAVAIL, self._OnReverseList)
+ bsizer.Add(wx.Button(self, ID_UNIQUE_REVAVAIL, _("Reverse")))
+ self.Bind(wx.EVT_BUTTON, self._OnReverseList, id=ID_UNIQUE_REVAVAIL)
- psizer.Add(bsizer, 0, wxGROW, 0)
- sizer.Add(psizer, 1, wxGROW, 0)
+ psizer.Add(bsizer, 0, wx.GROW, 0)
+ sizer.Add(psizer, 1, wx.GROW, 0)
-
- bsizer = wxBoxSizer(wxVERTICAL)
- bmp = resource.GetBitmapResource(USEALL_BMP, wxBITMAP_TYPE_XPM)
- bsizer.Add(wxBitmapButton(self, ID_UNIQUE_USEALL, bmp),
- 0, wxGROW | wxALL, 4)
- bmp = resource.GetBitmapResource(USE_BMP, wxBITMAP_TYPE_XPM)
- bsizer.Add(wxBitmapButton(self, ID_UNIQUE_USE, bmp),
- 0, wxGROW | wxALL, 4)
- bmp = resource.GetBitmapResource(USENOT_BMP, wxBITMAP_TYPE_XPM)
- bsizer.Add(wxBitmapButton(self, ID_UNIQUE_DONTUSE, bmp),
- 0, wxGROW | wxALL, 4)
- bmp = resource.GetBitmapResource(USENONE_BMP, wxBITMAP_TYPE_XPM)
- bsizer.Add(wxBitmapButton(self, ID_UNIQUE_USENONE, bmp),
- 0, wxGROW | wxALL, 4)
+ bsizer = wx.BoxSizer(wx.VERTICAL)
- EVT_BUTTON(self, ID_UNIQUE_USEALL, self._OnUseAll)
- EVT_BUTTON(self, ID_UNIQUE_USE, self._OnUse)
- EVT_BUTTON(self, ID_UNIQUE_DONTUSE, self._OnDontUse)
- EVT_BUTTON(self, ID_UNIQUE_USENONE, self._OnUseNone)
+ bmp = resource.GetBitmapResource(USEALL_BMP, wx.BITMAP_TYPE_XPM)
+ bsizer.Add(wx.BitmapButton(self, ID_UNIQUE_USEALL, bmp),
+ 0, wx.GROW | wx.ALL, 4)
+ bmp = resource.GetBitmapResource(USE_BMP, wx.BITMAP_TYPE_XPM)
+ bsizer.Add(wx.BitmapButton(self, ID_UNIQUE_USE, bmp),
+ 0, wx.GROW | wx.ALL, 4)
+ bmp = resource.GetBitmapResource(USENOT_BMP, wx.BITMAP_TYPE_XPM)
+ bsizer.Add(wx.BitmapButton(self, ID_UNIQUE_DONTUSE, bmp),
+ 0, wx.GROW | wx.ALL, 4)
+ bmp = resource.GetBitmapResource(USENONE_BMP, wx.BITMAP_TYPE_XPM)
+ bsizer.Add(wx.BitmapButton(self, ID_UNIQUE_USENONE, bmp),
+ 0, wx.GROW | wx.ALL, 4)
- sizer.Add(bsizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 4)
+ self.Bind(wx.EVT_BUTTON, self._OnUseAll, id=ID_UNIQUE_USEALL)
+ self.Bind(wx.EVT_BUTTON, self._OnUse, id=ID_UNIQUE_USE)
+ self.Bind(wx.EVT_BUTTON, self._OnDontUse, id=ID_UNIQUE_DONTUSE)
+ self.Bind(wx.EVT_BUTTON, self._OnUseNone, id=ID_UNIQUE_USENONE)
- psizer = wxBoxSizer(wxVERTICAL)
- self.list_use = wxListCtrl(self, -1,
- style=wxLC_REPORT | wxLC_SINGLE_SEL)
+ sizer.Add(bsizer, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4)
+
+ psizer = wx.BoxSizer(wx.VERTICAL)
+ self.list_use = wx.ListCtrl(self, -1,
+ style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
self.list_use.InsertColumn(0, _("Use"))
self.list_use_data = []
- psizer.Add(self.list_use, 1, wxGROW, 0)
+ psizer.Add(self.list_use, 1, wx.GROW, 0)
- bsizer = wxBoxSizer(wxHORIZONTAL)
- bsizer.Add(wxButton(self, ID_UNIQUE_SORTUSE, _("Sort")))
- EVT_BUTTON(self, ID_UNIQUE_SORTUSE, self._OnSortList)
+ bsizer = wx.BoxSizer(wx.HORIZONTAL)
+ bsizer.Add(wx.Button(self, ID_UNIQUE_SORTUSE, _("Sort")))
+ self.Bind(wx.EVT_BUTTON, self._OnSortList, id=ID_UNIQUE_SORTUSE)
- bsizer.Add(wxButton(self, ID_UNIQUE_REVUSE, _("Reverse")))
- EVT_BUTTON(self, ID_UNIQUE_REVUSE, self._OnReverseList)
+ bsizer.Add(wx.Button(self, ID_UNIQUE_REVUSE, _("Reverse")))
+ self.Bind(wx.EVT_BUTTON, self._OnReverseList, id=ID_UNIQUE_REVUSE)
- psizer.Add(bsizer, 0, wxGROW, 0)
+ psizer.Add(bsizer, 0, wx.GROW, 0)
- sizer.Add(psizer, 1, wxGROW, 0)
+ sizer.Add(psizer, 1, wx.GROW, 0)
- topSizer.Add(sizer, 1, wxGROW, 0)
+ topSizer.Add(sizer, 1, wx.GROW, 0)
self.SetSizer(topSizer)
self.SetAutoLayout(True)
@@ -730,7 +730,7 @@
else:
list = self.list_avail
- list.SortItems(lambda i1, i2: cmp(self.dataList[i1],
+ list.SortItems(lambda i1, i2: cmp(self.dataList[i1],
self.dataList[i2]))
def _OnReverseList(self, event):
@@ -760,7 +760,7 @@
self.dataList.append(v)
i = self.list_avail.InsertStringItem(index, str(v))
self.list_avail.SetItemData(index, i)
-
+
self.list_avail_data.append(v)
index += 1
finally:
@@ -784,8 +784,8 @@
def __MoveSelectedItems(self, list_src, list_dest):
while True:
index = list_src.GetNextItem(-1,
- wxLIST_NEXT_ALL,
- wxLIST_STATE_SELECTED)
+ wx.LIST_NEXT_ALL,
+ wx.LIST_STATE_SELECTED)
if index == -1:
break
@@ -798,7 +798,7 @@
item = list_src.GetItem(index)
x = list_dest.InsertStringItem(
- list_dest.GetItemCount(),
+ list_dest.GetItemCount(),
str(self.dataList[item.GetData()]))
list_dest.SetItemData(x, item.GetData())
@@ -814,48 +814,48 @@
ID_QUANTILES_RANGE = 4001
ID_QUANTILES_RETRIEVE = 4002
-class GenQuantilesPanel(wxPanel):
+class GenQuantilesPanel(wx.Panel):
def __init__(self, parent, layer, fieldName, fieldType):
- wxPanel.__init__(self, parent, -1)
+ wx.Panel.__init__(self, parent, -1)
self.parent = parent
self.layer = layer
self.fieldName = fieldName
self.fieldType = fieldType
- topBox = wxStaticBoxSizer(wxStaticBox(self, -1, ""),
- wxVERTICAL)
+ topBox = wx.StaticBoxSizer(wx.StaticBox(self, -1, ""),
+ wx.VERTICAL)
- self.text_range = wxTextCtrl(self, ID_QUANTILES_RANGE, "")
- self.button_retrieve = wxButton(self, ID_QUANTILES_RETRIEVE,
+ self.text_range = wx.TextCtrl(self, ID_QUANTILES_RANGE, "")
+ self.button_retrieve = wx.Button(self, ID_QUANTILES_RETRIEVE,
_("Retrieve from Table"))
- self.spin_numClasses = wxSpinCtrl(self, -1, style=wxTE_RIGHT)
+ self.spin_numClasses = wx.SpinCtrl(self, -1, style=wx.TE_RIGHT)
self.spin_numClasses.SetRange(2, sys.maxint)
self.spin_numClasses.SetValue(2)
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(wxStaticText(self, -1, _("Apply to Range")), 0, wxALL, 4)
- sizer.Add(self.text_range, 1, wxALL, 4)
- sizer.Add(self.button_retrieve, 0, wxALL, 4)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(wx.StaticText(self, -1, _("Apply to Range")), 0, wx.ALL, 4)
+ sizer.Add(self.text_range, 1, wx.ALL, 4)
+ sizer.Add(self.button_retrieve, 0, wx.ALL, 4)
- topBox.Add(sizer, 0, wxEXPAND, 0)
+ topBox.Add(sizer, 0, wx.EXPAND, 0)
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(wxStaticText(self, -1, _("Number of Classes:")), 0, wxALL, 4)
- sizer.Add(self.spin_numClasses, 1, wxALL, 4)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(wx.StaticText(self, -1, _("Number of Classes:")), 0, wx.ALL, 4)
+ sizer.Add(self.spin_numClasses, 1, wx.ALL, 4)
- topBox.Add(sizer, 0, wxEXPAND, 0)
+ topBox.Add(sizer, 0, wx.EXPAND, 0)
self.SetSizer(topBox)
self.SetAutoLayout(True)
topBox.Fit(self)
topBox.SetSizeHints(self)
- EVT_TEXT(self, ID_QUANTILES_RANGE, self.OnRangeText)
- EVT_BUTTON(self, ID_QUANTILES_RETRIEVE, self.OnRetrieve)
+ self.Bind(wx.EVT_TEXT, self.OnRangeText, id=ID_QUANTILES_RANGE)
+ self.Bind(wx.EVT_BUTTON, self.OnRetrieve, id=ID_QUANTILES_RETRIEVE)
self.__range = None
@@ -893,9 +893,9 @@
self.__range = None
if self.__range is not None:
- self.text_range.SetForegroundColour(wxBLACK)
+ self.text_range.SetForegroundColour(wx.BLACK)
else:
- self.text_range.SetForegroundColour(wxRED)
+ self.text_range.SetForegroundColour(wx.RED)
def OnRetrieve(self, event):
table = self.layer.ShapeStore().Table()
@@ -919,66 +919,66 @@
ID_CUSTOMRAMP_SPROP = 4005
ID_CUSTOMRAMP_EPROP = 4006
-class CustomRampPanel(wxPanel):
+class CustomRampPanel(wx.Panel):
def __init__(self, parent, shapeType):
- wxPanel.__init__(self, parent, -1)
+ wx.Panel.__init__(self, parent, -1)
- topSizer = wxStaticBoxSizer(wxStaticBox(self, -1, ""), wxHORIZONTAL)
+ topSizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, ""), wx.HORIZONTAL)
- bsizer = wxBoxSizer(wxVERTICAL)
- bsizer.Add(wxStaticText(self, -1, _("Start:")), 0, wxALL | wxCENTER, 4)
+ bsizer = wx.BoxSizer(wx.VERTICAL)
+ bsizer.Add(wx.StaticText(self, -1, _("Start:")), 0, wx.ALL | wx.CENTER, 4)
self.startPropCtrl = classifier.ClassGroupPropertiesCtrl(
- self, ID_CUSTOMRAMP_SPROP,
+ self, ID_CUSTOMRAMP_SPROP,
ClassGroupProperties(), shapeType,
- style=wxSIMPLE_BORDER, size=(40, 20))
- bsizer.Add(self.startPropCtrl, 1, wxGROW | wxALL | wxCENTER, 4)
- bsizer.Add(wxButton(self, ID_CUSTOMRAMP_EDITSTART, _("Change")),
- 0, wxGROW | wxALL | wxCENTER, 4)
+ style=wx.SIMPLE_BORDER, size=(40, 20))
+ bsizer.Add(self.startPropCtrl, 1, wx.GROW | wx.ALL | wx.CENTER, 4)
+ bsizer.Add(wx.Button(self, ID_CUSTOMRAMP_EDITSTART, _("Change")),
+ 0, wx.GROW | wx.ALL | wx.CENTER, 4)
topSizer.Add(bsizer,
- 1, wxALL \
- | wxSHAPED \
- | wxALIGN_CENTER_HORIZONTAL \
- | wxALIGN_CENTER_VERTICAL, \
+ 1, wx.ALL \
+ | wx.SHAPED \
+ | wx.ALIGN_CENTER_HORIZONTAL \
+ | wx.ALIGN_CENTER_VERTICAL, \
4)
- bmp = resource.GetBitmapResource(USE_BMP, wxBITMAP_TYPE_XPM)
- bsizer = wxBoxSizer(wxVERTICAL)
- bsizer.Add(wxBitmapButton(self, ID_CUSTOMRAMP_COPYSTART, bmp),
- 0, wxGROW | wxALL, 4)
- bmp = resource.GetBitmapResource(USENOT_BMP, wxBITMAP_TYPE_XPM)
- bsizer.Add(wxBitmapButton(self, ID_CUSTOMRAMP_COPYEND, bmp),
- 0, wxGROW | wxALL, 4)
+ bmp = resource.GetBitmapResource(USE_BMP, wx.BITMAP_TYPE_XPM)
+ bsizer = wx.BoxSizer(wx.VERTICAL)
+ bsizer.Add(wx.BitmapButton(self, ID_CUSTOMRAMP_COPYSTART, bmp),
+ 0, wx.GROW | wx.ALL, 4)
+ bmp = resource.GetBitmapResource(USENOT_BMP, wx.BITMAP_TYPE_XPM)
+ bsizer.Add(wx.BitmapButton(self, ID_CUSTOMRAMP_COPYEND, bmp),
+ 0, wx.GROW | wx.ALL, 4)
topSizer.Add(bsizer,
- 0, wxALL \
- | wxALIGN_CENTER_HORIZONTAL \
- | wxALIGN_CENTER_VERTICAL,
+ 0, wx.ALL \
+ | wx.ALIGN_CENTER_HORIZONTAL \
+ | wx.ALIGN_CENTER_VERTICAL,
4)
- bsizer = wxBoxSizer(wxVERTICAL)
- bsizer.Add(wxStaticText(self, -1, _("End:")), 0, wxALL | wxCENTER, 4)
+ bsizer = wx.BoxSizer(wx.VERTICAL)
+ bsizer.Add(wx.StaticText(self, -1, _("End:")), 0, wx.ALL | wx.CENTER, 4)
self.endPropCtrl = classifier.ClassGroupPropertiesCtrl(
- self, ID_CUSTOMRAMP_EPROP,
+ self, ID_CUSTOMRAMP_EPROP,
ClassGroupProperties(), shapeType,
- style=wxSIMPLE_BORDER, size=(40, 20))
- bsizer.Add(self.endPropCtrl, 1, wxGROW | wxALL | wxCENTER, 4)
- bsizer.Add(wxButton(self, ID_CUSTOMRAMP_EDITEND, _("Change")),
- 0, wxGROW | wxALL | wxCENTER, 4)
+ style=wx.SIMPLE_BORDER, size=(40, 20))
+ bsizer.Add(self.endPropCtrl, 1, wx.GROW | wx.ALL | wx.CENTER, 4)
+ bsizer.Add(wx.Button(self, ID_CUSTOMRAMP_EDITEND, _("Change")),
+ 0, wx.GROW | wx.ALL | wx.CENTER, 4)
topSizer.Add(bsizer,
- 1, wxALL \
- | wxSHAPED \
- | wxALIGN_RIGHT \
- | wxALIGN_CENTER_HORIZONTAL \
- | wxALIGN_CENTER_VERTICAL,
+ 1, wx.ALL \
+ | wx.SHAPED \
+ | wx.ALIGN_RIGHT \
+ | wx.ALIGN_CENTER_HORIZONTAL \
+ | wx.ALIGN_CENTER_VERTICAL,
4)
- EVT_BUTTON(self, ID_CUSTOMRAMP_COPYSTART, self._OnCopyStart)
- EVT_BUTTON(self, ID_CUSTOMRAMP_COPYEND, self._OnCopyEnd)
- EVT_BUTTON(self, ID_CUSTOMRAMP_EDITSTART, self._OnEditStart)
- EVT_BUTTON(self, ID_CUSTOMRAMP_EDITEND, self._OnEditEnd)
+ self.Bind(wx.EVT_BUTTON, self._OnCopyStart, id=ID_CUSTOMRAMP_COPYSTART)
+ self.Bind(wx.EVT_BUTTON, self._OnCopyEnd, id=ID_CUSTOMRAMP_COPYEND)
+ self.Bind(wx.EVT_BUTTON, self._OnEditStart, id=ID_CUSTOMRAMP_EDITSTART)
+ self.Bind(wx.EVT_BUTTON, self._OnEditEnd, id=ID_CUSTOMRAMP_EDITEND)
self.SetSizer(topSizer)
self.SetAutoLayout(True)
@@ -1000,4 +1000,4 @@
def _OnEditEnd(self, event):
self.endPropCtrl.DoEdit()
-
+
Modified: trunk/thuban/Thuban/UI/classifier.py
===================================================================
--- trunk/thuban/Thuban/UI/classifier.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/classifier.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -21,8 +21,8 @@
from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_DOUBLE, \
FIELDTYPE_STRING
-from wxPython.wx import *
-from wxPython.grid import *
+import wx
+from wx import grid
from Thuban import _
from Thuban.UI.common import Color2wxColour, wxColour2Color
@@ -63,7 +63,7 @@
# passed into SetTable is the same that is returned by GetTable
#
import weakref
-class ClassGrid(wxGrid):
+class ClassGrid(grid.Grid):
def __init__(self, parent, classifier):
@@ -74,23 +74,23 @@
clazz -- the working classification that this grid should
use for display.
"""
- wxGrid.__init__(self, parent, -1, style = 0)
+ grid.Grid.__init__(self, parent, -1, style = 0)
self.classifier = classifier
self.currentSelection = []
- EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick)
- EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange)
- EVT_GRID_SELECT_CELL(self, self._OnSelectedCell)
- EVT_GRID_COL_SIZE(self, self._OnCellResize)
- EVT_GRID_ROW_SIZE(self, self._OnCellResize)
- EVT_GRID_LABEL_RIGHT_CLICK(self, self._OnLabelRightClicked)
+ self.Bind(grid.EVT_GRID_CELL_LEFT_DCLICK, self._OnCellDClick)
+ self.Bind(grid.EVT_GRID_RANGE_SELECT, self._OnSelectedRange)
+ self.Bind(grid.EVT_GRID_SELECT_CELL, self._OnSelectedCell)
+ self.Bind(grid.EVT_GRID_COL_SIZE, self._OnCellResize)
+ self.Bind(grid.EVT_GRID_ROW_SIZE, self._OnCellResize)
+ self.Bind(grid.EVT_GRID_LABEL_RIGHT_CLICK, self._OnLabelRightClicked)
#def GetCellAttr(self, row, col):
#print "GetCellAttr ", row, col
- #wxGrid.GetCellAttr(self, row, col)
+ #Grid.GetCellAttr(self, row, col)
def CreateTable(self, clazz, fieldType, shapeType, group = None):
@@ -99,7 +99,7 @@
table = self.GetTable()
if table is None:
w = self.GetDefaultColSize() * NUM_COLS \
- + self.GetDefaultRowLabelSize()
+ + self.GetDefaultRowLabelSize()
h = self.GetDefaultRowSize() * 4 \
+ self.GetDefaultColLabelSize()
@@ -109,7 +109,7 @@
self.SetTable(table, True)
- self.SetSelectionMode(wxGrid.wxGridSelectRows)
+ self.SetSelectionMode(grid.Grid.wxGridSelectRows)
self.ClearSelection()
table.Reset(clazz, fieldType, shapeType, group)
@@ -135,7 +135,7 @@
#
def SetTable(self, object, *attributes):
self.tableRef = weakref.ref(object)
- return wxGrid.SetTable(self, object, *attributes)
+ return grid.Grid.SetTable(self, object, *attributes)
def GetTable(self):
try:
@@ -145,14 +145,14 @@
def DeleteSelectedRows(self):
"""Deletes all highlighted rows.
-
+
If only one row is highlighted then after it is deleted the
row that was below the deleted row is highlighted."""
sel = self.GetCurrentSelection()
# nothing to do
- if len(sel) == 0: return
+ if len(sel) == 0: return
# if only one thing is selected check if it is the default
# data row, because we can't remove that
@@ -160,12 +160,12 @@
#group = self.GetTable().GetValueAsCustom(sel[0], COL_SYMBOL, None)
group = self.GetTable().GetClassGroup(sel[0])
if isinstance(group, ClassGroupDefault):
- wxMessageDialog(self,
+ wx.MessageDialog(self,
_("The Default group cannot be removed."),
- style = wxOK | wxICON_EXCLAMATION).ShowModal()
+ style = wx.OK | wx.ICON_EXCLAMATION).ShowModal()
return
-
+
self.ClearSelection()
# we need to remove things from the bottom up so we don't
@@ -189,16 +189,16 @@
if r > self.GetNumberRows() - 1:
r = self.GetNumberRows() - 1
self.SelectRow(r)
-
+
def SelectGroup(self, group, makeVisible = True):
if group is None: return
- assert isinstance(group, ClassGroup)
+ assert isinstance(group, ClassGroup)
table = self.GetTable()
- assert table is not None
+ assert table is not None
for i in range(table.GetNumberRows()):
g = table.GetClassGroup(i)
@@ -213,7 +213,7 @@
#
# def DeselectRow(self, row):
# self.ProcessEvent(
-# wxGridRangeSelectEvent(-1,
+# GridRangeSelectEvent(-1,
# wxEVT_GRID_RANGE_SELECT,
# self,
# (row, row), (row, row),
@@ -235,25 +235,25 @@
# from http://wiki.wxpython.org to keep track of which
# cells are currently highlighted
#
- def _OnSelectedRange(self, event):
+ def _OnSelectedRange(self, event):
"""Internal update to the selection tracking list"""
- if event.Selecting():
- for index in range( event.GetTopRow(), event.GetBottomRow()+1):
- if index not in self.currentSelection:
- self.currentSelection.append( index )
- else:
- for index in range( event.GetTopRow(), event.GetBottomRow()+1):
- while index in self.currentSelection:
- self.currentSelection.remove( index )
+ if event.Selecting():
+ for index in range( event.GetTopRow(), event.GetBottomRow()+1):
+ if index not in self.currentSelection:
+ self.currentSelection.append( index )
+ else:
+ for index in range( event.GetTopRow(), event.GetBottomRow()+1):
+ while index in self.currentSelection:
+ self.currentSelection.remove( index )
#self.ConfigureForSelection()
- event.Skip()
+ event.Skip()
- def _OnSelectedCell( self, event ):
+ def _OnSelectedCell( self, event ):
"""Internal update to the selection tracking list"""
- self.currentSelection = [ event.GetRow() ]
+ self.currentSelection = [ event.GetRow() ]
#self.ConfigureForSelection()
- event.Skip()
+ event.Skip()
def _OnCellResize(self, event):
self.FitInside()
@@ -272,9 +272,9 @@
if (label == _("Pattern") or label == _("Singleton")):
xe,ye = event.GetPosition()
x=self.GetRowSize(row)/2
- menu = wxMenu()
- patternID = wxNewId()
- singletonID = wxNewId()
+ menu = wx.Menu()
+ patternID = wx.NewId()
+ singletonID = wx.NewId()
def _SetSingleton(event, self=self, row=row):
table = self.GetTable()
@@ -286,7 +286,7 @@
group.GetLabel()
)
table.SetClassGroup(row, ngroup)
-
+
def _SetPattern(event, self=self, row=row):
table = self.GetTable()
group = table.clazz.GetGroup(row - 1)
@@ -304,14 +304,14 @@
table.SetClassGroup(row, ngroup)
menu.Append(singletonID, _("Singleton"))
- EVT_MENU(self, singletonID, _SetSingleton)
+ self.Bind(wx.EVT_MENU, _SetSingleton, id=singletonID)
if self.GetTable().fieldType == FIELDTYPE_STRING:
menu.Append(patternID, _("Pattern"))
- EVT_MENU(self, patternID, _SetPattern)
- self.PopupMenu(menu, wxPoint(x,ye))
+ self.Bind(wx.EVT_MENU, _SetPattern, id=patternID)
+ self.PopupMenu(menu, wx.Point(x,ye))
menu.Destroy()
-class ClassTable(wxPyGridTableBase):
+class ClassTable(grid.PyGridTableBase):
"""Represents the underlying data structure for the grid."""
__col_labels = [_("Visible"), _("Symbol"), _("Value"), _("Label")]
@@ -322,10 +322,10 @@
shapeType -- the type of shape that the layer uses
- view -- a wxGrid object that uses this class for its table
+ view -- a Grid object that uses this class for its table
"""
- wxPyGridTableBase.__init__(self)
+ grid.PyGridTableBase.__init__(self)
assert len(ClassTable.__col_labels) == NUM_COLS
@@ -348,7 +348,7 @@
shapeType -- the type of shape that the layer uses
"""
- assert isinstance(clazz, Classification)
+ assert isinstance(clazz, Classification)
self.GetView().BeginBatch()
@@ -360,13 +360,13 @@
self.__colAttr = {}
- attr = wxGridCellAttr()
- attr.SetEditor(wxGridCellBoolEditor())
- attr.SetRenderer(wxGridCellBoolRenderer())
- attr.SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER)
+ attr = grid.GridCellAttr()
+ attr.SetEditor(grid.GridCellBoolEditor())
+ attr.SetRenderer(grid.GridCellBoolRenderer())
+ attr.SetAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
self.__colAttr[COL_VISIBLE] = attr
- attr = wxGridCellAttr()
+ attr = grid.GridCellAttr()
attr.SetRenderer(ClassRenderer(self.shapeType))
attr.SetReadOnly()
self.__colAttr[COL_SYMBOL] = attr
@@ -414,14 +414,14 @@
# rows and columns
#
if newRows > curRows:
- msg = wxGridTableMessage(self,
- wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
+ msg = grid.GridTableMessage(self,
+ grid.GRIDTABLE_NOTIFY_ROWS_APPENDED,
newRows - curRows) # how many
self.GetView().ProcessTableMessage(msg)
self.GetView().FitInside()
elif newRows < curRows:
- msg = wxGridTableMessage(self,
- wxGRIDTABLE_NOTIFY_ROWS_DELETED,
+ msg = grid.GridTableMessage(self,
+ grid.GRIDTABLE_NOTIFY_ROWS_DELETED,
curRows, # position
curRows - newRows) # how many
self.GetView().ProcessTableMessage(msg)
@@ -522,7 +522,7 @@
return group.GetLabel()
# col must be COL_VALUE
- assert col == COL_VALUE
+ assert col == COL_VALUE
if isinstance(group, ClassGroupDefault):
return _("DEFAULT")
@@ -590,8 +590,8 @@
typeName -- unused, but needed to overload wxPyGridTableBase
"""
- assert 0 <= col < self.GetNumberCols()
- assert 0 <= row < self.GetNumberRows()
+ assert 0 <= col < self.GetNumberCols()
+ assert 0 <= row < self.GetNumberRows()
if row == 0:
group = self.clazz.GetDefaultGroup()
@@ -663,7 +663,7 @@
def GetAttr(self, row, col, someExtraParameter):
"""Returns the cell attributes"""
- return self.__colAttr.get(col, wxGridCellAttr()).Clone()
+ return self.__colAttr.get(col, grid.GridCellAttr()).Clone()
def GetClassGroup(self, row):
"""Return the ClassGroup object representing row 'row'."""
@@ -704,14 +704,14 @@
The table is considered modified if any rows are removed.
"""
- assert pos >= 0
- old_len = self.GetNumberRows()
+ assert pos >= 0
+ old_len = self.GetNumberRows()
for row in range(pos, pos - numRows, -1):
group = self.GetClassGroup(row)
if row != 0:
self.clazz.RemoveGroup(row - 1)
self.__Modified()
-
+
if self.IsModified():
self.__NotifyRowChanges(old_len, self.GetNumberRows())
@@ -780,7 +780,7 @@
if self.layer.HasClassification():
- self.fieldTypeText = wxStaticText(panel, -1, "")
+ self.fieldTypeText = wx.StaticText(panel, -1, "")
self.originalClass = self.layer.GetClassification()
self.originalClassField = self.layer.GetClassificationColumn()
@@ -791,12 +791,12 @@
#
# make field choice box
#
- self.fields = wxChoice(panel, ID_PROPERTY_SELECT,)
+ self.fields = wx.Choice(panel, ID_PROPERTY_SELECT,)
self.num_cols = table.NumColumns()
# just assume the first field in case one hasn't been
# specified in the file.
- self.__cur_field = 0
+ self.__cur_field = 0
self.fields.Append("<None>")
@@ -811,22 +811,22 @@
if name == field:
self.__cur_field = i + 1
- self.fields.SetClientData(i + 1,
+ self.fields.SetClientData(i + 1,
copy.deepcopy(self.originalClass))
else:
self.fields.SetClientData(i + 1, None)
- button_gen = wxButton(panel, ID_PROPERTY_GENCLASS,
+ button_gen = wx.Button(panel, ID_PROPERTY_GENCLASS,
_("Generate Class"))
- button_add = wxButton(panel, ID_PROPERTY_ADD,
+ button_add = wx.Button(panel, ID_PROPERTY_ADD,
_("Add"))
- button_moveup = wxButton(panel, ID_PROPERTY_MOVEUP,
+ button_moveup = wx.Button(panel, ID_PROPERTY_MOVEUP,
_("Move Up"))
- button_movedown = wxButton(panel, ID_PROPERTY_MOVEDOWN,
+ button_movedown = wx.Button(panel, ID_PROPERTY_MOVEDOWN,
_("Move Down"))
- button_edit = wxButton(panel, ID_PROPERTY_EDITSYM,
+ button_edit = wx.Button(panel, ID_PROPERTY_EDITSYM,
_("Edit Symbol"))
- button_remove = wxButton(panel, ID_PROPERTY_REMOVE,
+ button_remove = wx.Button(panel, ID_PROPERTY_REMOVE,
_("Remove"))
self.classGrid = ClassGrid(panel, self)
@@ -837,46 +837,46 @@
self.__SelectField(self.__cur_field, group = self.group)
- classBox = wxStaticBoxSizer(
- wxStaticBox(panel, -1, _("Classification")), wxVERTICAL)
+ classBox = wx.StaticBoxSizer(
+ wx.StaticBox(panel, -1, _("Classification")), wx.VERTICAL)
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(wxStaticText(panel, ID_PROPERTY_FIELDTEXT, _("Field: ")),
- 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4)
- sizer.Add(self.fields, 1, wxGROW | wxALL, 4)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(wx.StaticText(panel, ID_PROPERTY_FIELDTEXT, _("Field: ")),
+ 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 4)
+ sizer.Add(self.fields, 1, wx.GROW | wx.ALL, 4)
- classBox.Add(sizer, 0, wxGROW, 4)
+ classBox.Add(sizer, 0, wx.GROW, 4)
- classBox.Add(self.fieldTypeText, 0,
- wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4)
+ classBox.Add(self.fieldTypeText, 0,
+ wx.GROW | wx.ALIGN_LEFT | wx.ALL | wx.ADJUST_MINSIZE, 4)
- controlBox = wxBoxSizer(wxHORIZONTAL)
- controlButtonBox = wxBoxSizer(wxVERTICAL)
+ controlBox = wx.BoxSizer(wx.HORIZONTAL)
+ controlButtonBox = wx.BoxSizer(wx.VERTICAL)
- controlButtonBox.Add(button_gen, 0, wxGROW|wxALL, 4)
- controlButtonBox.Add(button_add, 0, wxGROW|wxALL, 4)
- controlButtonBox.Add(button_moveup, 0, wxGROW|wxALL, 4)
- controlButtonBox.Add(button_movedown, 0, wxGROW|wxALL, 4)
- controlButtonBox.Add(button_edit, 0, wxGROW|wxALL, 4)
- controlButtonBox.Add( (60, 20), 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4)
- controlButtonBox.Add(button_remove, 0,
- wxGROW|wxALL|wxALIGN_BOTTOM, 4)
+ controlButtonBox.Add(button_gen, 0, wx.GROW|wx.ALL, 4)
+ controlButtonBox.Add(button_add, 0, wx.GROW|wx.ALL, 4)
+ controlButtonBox.Add(button_moveup, 0, wx.GROW|wx.ALL, 4)
+ controlButtonBox.Add(button_movedown, 0, wx.GROW|wx.ALL, 4)
+ controlButtonBox.Add(button_edit, 0, wx.GROW|wx.ALL, 4)
+ controlButtonBox.Add( (60, 20), 0, wx.GROW|wx.ALL|wx.ALIGN_BOTTOM, 4)
+ controlButtonBox.Add(button_remove, 0,
+ wx.GROW|wx.ALL|wx.ALIGN_BOTTOM, 4)
- controlBox.Add(self.classGrid, 1, wxGROW, 0)
- controlBox.Add(controlButtonBox, 0, wxGROW, 10)
+ controlBox.Add(self.classGrid, 1, wx.GROW, 0)
+ controlBox.Add(controlButtonBox, 0, wx.GROW, 10)
- classBox.Add(controlBox, 1, wxGROW, 10)
- panelBox.Add(classBox, 1, wxGROW, 0)
+ classBox.Add(controlBox, 1, wx.GROW, 10)
+ panelBox.Add(classBox, 1, wx.GROW, 0)
- EVT_CHOICE(self, ID_PROPERTY_SELECT, self._OnFieldSelect)
- EVT_BUTTON(self, ID_PROPERTY_ADD, self._OnAdd)
- EVT_BUTTON(self, ID_PROPERTY_EDITSYM, self._OnEditSymbol)
- EVT_BUTTON(self, ID_PROPERTY_REMOVE, self._OnRemove)
- EVT_BUTTON(self, ID_PROPERTY_GENCLASS, self._OnGenClass)
- EVT_BUTTON(self, ID_PROPERTY_MOVEUP, self._OnMoveUp)
- EVT_BUTTON(self, ID_PROPERTY_MOVEDOWN, self._OnMoveDown)
+ self.Bind(wx.EVT_CHOICE, self._OnFieldSelect, id=ID_PROPERTY_SELECT)
+ self.Bind(wx.EVT_BUTTON, self._OnAdd, id=ID_PROPERTY_ADD)
+ self.Bind(wx.EVT_BUTTON, self._OnEditSymbol, id=ID_PROPERTY_EDITSYM)
+ self.Bind(wx.EVT_BUTTON, self._OnRemove, id=ID_PROPERTY_REMOVE)
+ self.Bind(wx.EVT_BUTTON, self._OnGenClass, id=ID_PROPERTY_GENCLASS)
+ self.Bind(wx.EVT_BUTTON, self._OnMoveUp, id=ID_PROPERTY_MOVEUP)
+ self.Bind(wx.EVT_BUTTON, self._OnMoveDown, id=ID_PROPERTY_MOVEDOWN)
def unsubscribe_messages(self):
"""Unsubscribe from all messages."""
@@ -902,7 +902,7 @@
propDlg = SelectPropertiesDialog(self, prop, self.layer.ShapeType())
self.Enable(False)
- if propDlg.ShowModal() == wxID_OK:
+ if propDlg.ShowModal() == wx.ID_OK:
new_prop = propDlg.GetClassGroupProperties()
table.SetValueAsCustom(row, COL_SYMBOL, None, new_prop)
self.Enable(True)
@@ -958,8 +958,8 @@
fieldName = self.fields.GetString(fieldIndex)
fieldType = self.layer.GetFieldType(fieldName)
-
- self.classGrid.CreateTable(clazz, fieldType,
+
+ self.classGrid.CreateTable(clazz, fieldType,
self.layer.ShapeType(), group)
def __SetFieldTypeText(self, fieldIndex):
@@ -969,7 +969,7 @@
fieldName = self.fields.GetString(fieldIndex)
fieldType = self.layer.GetFieldType(fieldName)
- assert Classifier.type2string.has_key(fieldType)
+ assert Classifier.type2string.has_key(fieldType)
text = Classifier.type2string[fieldType]
@@ -998,7 +998,7 @@
title = ": " + title
self.SetTitle(_("Layer Properties") + title)
-
+
def _OnEditSymbol(self, event):
"""Open up a dialog for the user to select group properties."""
sel = self.classGrid.GetCurrentSelection()
@@ -1006,7 +1006,7 @@
if len(sel) == 1:
self.EditSymbol(sel[0])
- def _OnFieldSelect(self, event):
+ def _OnFieldSelect(self, event):
index = self.fields.GetSelection()
self.__SelectField(index, self.__cur_field)
self.__cur_field = index
@@ -1043,7 +1043,7 @@
#self.Close()
- def _OnAdd(self, event):
+ def _OnAdd(self, event):
self.classGrid.AppendRows()
def _OnRemove(self, event):
@@ -1055,7 +1055,7 @@
self.genDlg = ClassGenDialog(self, self.layer,
self.fields.GetString(self.__cur_field))
- EVT_CLOSE(self.genDlg, self._OnGenDialogClose)
+ self.Bind(wx.EVT_CLOSE, self._OnGenDialogClose, self.genDlg)
self.__EnableButtons(EB_GEN_CLASS)
@@ -1115,18 +1115,18 @@
based on the case provided. Cases are constants beginning with EB_.
"""
- list = {wxID_OK : True,
- wxID_CANCEL : True,
+ list = {wx.ID_OK : True,
+ wx.ID_CANCEL : True,
ID_PROPERTY_ADD : True,
- ID_PROPERTY_MOVEUP : True,
- ID_PROPERTY_MOVEDOWN : True,
+ ID_PROPERTY_MOVEUP : True,
+ ID_PROPERTY_MOVEDOWN : True,
ID_PROPERTY_REMOVE : True,
- ID_PROPERTY_SELECT : True,
- ID_PROPERTY_FIELDTEXT : True,
+ ID_PROPERTY_SELECT : True,
+ ID_PROPERTY_FIELDTEXT : True,
ID_PROPERTY_GENCLASS : True,
ID_PROPERTY_EDITSYM : True}
- if case == EB_LAYER_TITLE:
+ if case == EB_LAYER_TITLE:
if self.layer.Title() == "":
list[wxID_OK] = False
list[wxID_CANCEL] = False
@@ -1141,9 +1141,9 @@
elif case == EB_GEN_CLASS:
if self.genDlg is not None:
- list[ID_PROPERTY_SELECT] = False
+ list[ID_PROPERTY_SELECT] = False
list[ID_PROPERTY_FIELDTEXT] = False
- list[ID_PROPERTY_GENCLASS] = False
+ list[ID_PROPERTY_GENCLASS] = False
for id, enable in list.items():
win = self.FindWindowById(id)
@@ -1158,112 +1158,112 @@
ID_SELPROP_FILLCLRTRANS = 4007
ID_SELPROP_SPINCTRL_SIZE = 4008
-class SelectPropertiesDialog(wxDialog):
+class SelectPropertiesDialog(wx.Dialog):
"""Dialog that allows the user to select group properties."""
def __init__(self, parent, prop, shapeType):
"""Open the dialog with the initial prop properties and shapeType."""
- wxDialog.__init__(self, parent, -1, _("Select Properties"),
- style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ wx.Dialog.__init__(self, parent, -1, _("Select Properties"),
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
self.prop = ClassGroupProperties(prop)
- topBox = wxBoxSizer(wxVERTICAL)
+ topBox = wx.BoxSizer(wx.VERTICAL)
- itemBox = wxBoxSizer(wxHORIZONTAL)
+ itemBox = wx.BoxSizer(wx.HORIZONTAL)
# preview box
- previewBox = wxBoxSizer(wxVERTICAL)
- previewBox.Add(wxStaticText(self, -1, _("Preview:")),
- 0, wxALIGN_LEFT | wxALL, 4)
+ previewBox = wx.BoxSizer(wx.VERTICAL)
+ previewBox.Add(wx.StaticText(self, -1, _("Preview:")),
+ 0, wx.ALIGN_LEFT | wx.ALL, 4)
self.previewWin = ClassGroupPropertiesCtrl(
- self, ID_SELPROP_PREVIEW, self.prop, shapeType,
- (40, 40), wxSIMPLE_BORDER)
+ self, ID_SELPROP_PREVIEW, self.prop, shapeType,
+ (40, 40), wx.SIMPLE_BORDER)
self.previewWin.AllowEdit(False)
- previewBox.Add(self.previewWin, 1, wxGROW | wxALL, 4)
+ previewBox.Add(self.previewWin, 1, wx.GROW | wx.ALL, 4)
- itemBox.Add(previewBox, 1, wxALIGN_LEFT | wxALL | wxGROW, 0)
+ itemBox.Add(previewBox, 1, wx.ALIGN_LEFT | wx.ALL | wx.GROW, 0)
# control box
- ctrlBox = wxBoxSizer(wxVERTICAL)
+ ctrlBox = wx.BoxSizer(wx.VERTICAL)
- lineColorBox = wxBoxSizer(wxHORIZONTAL)
- button = wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color"))
+ lineColorBox = wx.BoxSizer(wx.HORIZONTAL)
+ button = wx.Button(self, ID_SELPROP_STROKECLR, _("Change Line Color"))
button.SetFocus()
- lineColorBox.Add(button, 1, wxALL | wxGROW, 4)
- EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)
+ lineColorBox.Add(button, 1, wx.ALL | wx.GROW, 4)
+ self.Bind(wx.EVT_BUTTON, self._OnChangeLineColor, id=ID_SELPROP_STROKECLR)
lineColorBox.Add(
- wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")),
- 1, wxALL | wxGROW, 4)
- EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS,
- self._OnChangeLineColorTrans)
+ wx.Button(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")),
+ 1, wx.ALL | wx.GROW, 4)
+ self.Bind(wx.EVT_BUTTON, self._OnChangeLineColorTrans, \
+ id=ID_SELPROP_STROKECLRTRANS)
- ctrlBox.Add(lineColorBox, 0,
- wxALIGN_CENTER_HORIZONTAL | wxALL | wxGROW, 4)
+ ctrlBox.Add(lineColorBox, 0,
+ wx.ALIGN_CENTER_HORIZONTAL | wx.ALL | wx.GROW, 4)
if shapeType != SHAPETYPE_ARC:
- fillColorBox = wxBoxSizer(wxHORIZONTAL)
+ fillColorBox = wx.BoxSizer(wx.HORIZONTAL)
fillColorBox.Add(
- wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")),
- 1, wxALL | wxGROW, 4)
- EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor)
+ wx.Button(self, ID_SELPROP_FILLCLR, _("Change Fill Color")),
+ 1, wx.ALL | wx.GROW, 4)
+ self.Bind(wx.EVT_BUTTON, self._OnChangeFillColor, id=ID_SELPROP_FILLCLR)
fillColorBox.Add(
- wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")),
- 1, wxALL | wxGROW, 4)
- EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS,
- self._OnChangeFillColorTrans)
- ctrlBox.Add(fillColorBox, 0,
- wxALIGN_CENTER_HORIZONTAL | wxALL | wxGROW, 4)
+ wx.Button(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")),
+ 1, wx.ALL | wx.GROW, 4)
+ self.Bind(wx.EVT_BUTTON, self._OnChangeFillColorTrans,\
+ id=ID_SELPROP_FILLCLRTRANS)
+ ctrlBox.Add(fillColorBox, 0,
+ wx.ALIGN_CENTER_HORIZONTAL | wx.ALL | wx.GROW, 4)
# Line width selection
- spinBox = wxBoxSizer(wxHORIZONTAL)
- spinBox.Add(wxStaticText(self, -1, _("Line Width: ")),
- 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4)
- self.spinCtrl_linewidth = wxSpinCtrl(self,
+ spinBox = wx.BoxSizer(wx.HORIZONTAL)
+ spinBox.Add(wx.StaticText(self, -1, _("Line Width: ")),
+ 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 4)
+ self.spinCtrl_linewidth = wx.SpinCtrl(self,
ID_SELPROP_SPINCTRL_LINEWIDTH,
- min=1, max=10,
+ min=1, max=10,
value=str(prop.GetLineWidth()),
initial=prop.GetLineWidth())
- EVT_SPINCTRL(self, ID_SELPROP_SPINCTRL_LINEWIDTH,
- self._OnSpinLineWidth)
+ self.Bind(wx.EVT_SPINCTRL, self._OnSpinLineWidth, \
+ id=ID_SELPROP_SPINCTRL_LINEWIDTH)
- spinBox.Add(self.spinCtrl_linewidth, 0, wxALIGN_LEFT | wxALL, 4)
- ctrlBox.Add(spinBox, 0, wxALIGN_RIGHT | wxALL, 0)
+ spinBox.Add(self.spinCtrl_linewidth, 0, wx.ALIGN_LEFT | wx.ALL, 4)
+ ctrlBox.Add(spinBox, 0, wx.ALIGN_RIGHT | wx.ALL, 0)
# Size selection
if shapeType == SHAPETYPE_POINT:
- spinBox = wxBoxSizer(wxHORIZONTAL)
- spinBox.Add(wxStaticText(self, -1, _("Size: ")),
- 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4)
- self.spinCtrl_size = wxSpinCtrl(self, ID_SELPROP_SPINCTRL_SIZE,
+ spinBox = wx.BoxSizer(wx.HORIZONTAL)
+ spinBox.Add(wx.StaticText(self, -1, _("Size: ")),
+ 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 4)
+ self.spinCtrl_size = wx.SpinCtrl(self, ID_SELPROP_SPINCTRL_SIZE,
min=1, max=100,
value=str(prop.GetSize()),
initial=prop.GetSize())
- EVT_SPINCTRL(self, ID_SELPROP_SPINCTRL_SIZE, self._OnSpinSize)
+ self.Bind(wx.EVT_SPINCTRL, self._OnSpinSize, id=ID_SELPROP_SPINCTRL_SIZE)
- spinBox.Add(self.spinCtrl_size, 0, wxALIGN_LEFT | wxALL, 4)
- ctrlBox.Add(spinBox, 0, wxALIGN_RIGHT | wxALL, 0)
+ spinBox.Add(self.spinCtrl_size, 0, wx.ALIGN_LEFT | wx.ALL, 4)
+ ctrlBox.Add(spinBox, 0, wx.ALIGN_RIGHT | wx.ALL, 0)
- itemBox.Add(ctrlBox, 0, wxALIGN_RIGHT | wxALL | wxGROW, 0)
- topBox.Add(itemBox, 1, wxALIGN_LEFT | wxALL | wxGROW, 0)
+ itemBox.Add(ctrlBox, 0, wx.ALIGN_RIGHT | wx.ALL | wx.GROW, 0)
+ topBox.Add(itemBox, 1, wx.ALIGN_LEFT | wx.ALL | wx.GROW, 0)
#
# Control buttons:
#
- buttonBox = wxBoxSizer(wxHORIZONTAL)
- button_ok = wxButton(self, wxID_OK, _("OK"))
- buttonBox.Add(button_ok, 0, wxRIGHT|wxEXPAND, 10)
- buttonBox.Add(wxButton(self, wxID_CANCEL, _("Cancel")),
- 0, wxRIGHT|wxEXPAND, 10)
- topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10)
+ buttonBox = wx.BoxSizer(wx.HORIZONTAL)
+ button_ok = wx.Button(self, wx.ID_OK, _("OK"))
+ buttonBox.Add(button_ok, 0, wx.RIGHT|wx.EXPAND, 10)
+ buttonBox.Add(wx.Button(self, wx.ID_CANCEL, _("Cancel")),
+ 0, wx.RIGHT|wx.EXPAND, 10)
+ topBox.Add(buttonBox, 0, wx.ALIGN_RIGHT|wx.BOTTOM|wx.TOP, 10)
button_ok.SetDefault()
@@ -1276,10 +1276,10 @@
topBox.SetSizeHints(self)
def OnOK(self, event):
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
def OnCancel(self, event):
- self.EndModal(wxID_CANCEL)
+ self.EndModal(wx.ID_CANCEL)
def _OnSpinLineWidth(self, event):
self.prop.SetLineWidth(self.spinCtrl_linewidth.GetValue())
@@ -1294,7 +1294,7 @@
dialog.SetColor(cur)
ret = None
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
ret = dialog.GetColor()
dialog.Destroy()
@@ -1325,17 +1325,17 @@
return self.prop
-class ClassDataPreviewWindow(wxWindow):
+class ClassDataPreviewWindow(wx.Window):
"""A custom window that draws group properties using the correct shape."""
- def __init__(self, rect, prop, shapeType,
- parent = None, id = -1, size = wxDefaultSize):
+ def __init__(self, rect, prop, shapeType,
+ parent = None, id = -1, size = wx.DefaultSize):
"""Draws the appropriate shape as specified with shapeType using
prop properities.
"""
if parent is not None:
- wxWindow.__init__(self, parent, id, (0, 0), size)
- EVT_PAINT(self, self._OnPaint)
+ wx.Window.__init__(self, parent, id, (0, 0), size)
+ self.Bind(wx.EVT_PAINT, self._OnPaint)
self.rect = rect
@@ -1347,14 +1347,14 @@
return self.prop
def _OnPaint(self, event):
- dc = wxPaintDC(self)
+ dc = wx.PaintDC(self)
# XXX: this doesn't seem to be having an effect:
- dc.DestroyClippingRegion()
+ dc.DestroyClippingRegion()
if self.rect is None:
w, h = self.GetSize()
- rect = wxRect(0, 0, w, h)
+ rect = wx.Rect(0, 0, w, h)
else:
rect = self.rect
@@ -1387,26 +1387,26 @@
stroke = prop.GetLineColor()
if stroke is Transparent:
- pen = wxTRANSPARENT_PEN
+ pen = wx.TRANSPARENT_PEN
else:
- pen = wxPen(Color2wxColour(stroke),
+ pen = wx.Pen(Color2wxColour(stroke),
prop.GetLineWidth(),
- wxSOLID)
+ wx.SOLID)
stroke = prop.GetFill()
if stroke is Transparent:
- brush = wxTRANSPARENT_BRUSH
+ brush = wx.TRANSPARENT_BRUSH
else:
- brush = wxBrush(Color2wxColour(stroke), wxSOLID)
+ brush = wx.Brush(Color2wxColour(stroke), wx.SOLID)
dc.SetPen(pen)
dc.SetBrush(brush)
if shapeType == SHAPETYPE_ARC:
- dc.DrawSpline([wxPoint(x, y + h),
- wxPoint(x + w/2, y + h/4),
- wxPoint(x + w/2, y + h/4*3),
- wxPoint(x + w, y)])
+ dc.DrawSpline([wx.Point(x, y + h),
+ wx.Point(x + w/2, y + h/4),
+ wx.Point(x + w/2, y + h/4*3),
+ wx.Point(x + w, y)])
elif shapeType == SHAPETYPE_POINT:
@@ -1424,24 +1424,24 @@
return None
-class ClassRenderer(wxPyGridCellRenderer):
+class ClassRenderer(grid.PyGridCellRenderer):
"""A wrapper class that can be used to draw group properties in a
grid table.
"""
def __init__(self, shapeType):
- wxPyGridCellRenderer.__init__(self)
+ grid.PyGridCellRenderer.__init__(self)
self.shapeType = shapeType
self.previewer = ClassDataPreviewer()
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
data = grid.GetTable().GetClassGroup(row)
- dc.SetClippingRegion(rect.GetX(), rect.GetY(),
+ dc.SetClippingRegion(rect.GetX(), rect.GetY(),
rect.GetWidth(), rect.GetHeight())
- dc.SetPen(wxPen(wxLIGHT_GREY))
- dc.SetBrush(wxBrush(wxLIGHT_GREY, wxSOLID))
- dc.DrawRectangle(rect.GetX(), rect.GetY(),
+ dc.SetPen(wx.Pen(wx.LIGHT_GREY))
+ dc.SetBrush(wx.Brush(wx.LIGHT_GREY, wx.SOLID))
+ dc.DrawRectangle(rect.GetX(), rect.GetY(),
rect.GetWidth(), rect.GetHeight())
if not isinstance(data, ClassGroupMap):
@@ -1457,34 +1457,34 @@
rect.SetHeight(new_h)
rect.SetWidth(new_w)
dc.DestroyClippingRegion()
- dc.SetClippingRegion(rect.GetX(), rect.GetY(),
+ dc.SetClippingRegion(rect.GetX(), rect.GetY(),
rect.GetWidth(), rect.GetHeight())
- dc.SetPen(wxPen(wxLIGHT_GREY))
- dc.SetBrush(wxBrush(wxLIGHT_GREY, wxSOLID))
- dc.DrawRectangle(rect.GetX(), rect.GetY(),
+ dc.SetPen(wx.Pen(wx.LIGHT_GREY))
+ dc.SetBrush(wx.Brush(wx.LIGHT_GREY, wx.SOLID))
+ dc.DrawRectangle(rect.GetX(), rect.GetY(),
rect.GetWidth(), rect.GetHeight())
self.previewer.Draw(dc, rect, data.GetProperties(),
self.shapeType)
if isSelected:
- dc.SetPen(wxPen(wxBLACK, 1, wxSOLID))
- dc.SetBrush(wxTRANSPARENT_BRUSH)
+ dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
- dc.DrawRectangle(rect.GetX(), rect.GetY(),
+ dc.DrawRectangle(rect.GetX(), rect.GetY(),
rect.GetWidth(), rect.GetHeight())
dc.DestroyClippingRegion()
-class ClassGroupPropertiesCtrl(wxControl):
+class ClassGroupPropertiesCtrl(wx.Control):
"""A custom window and control that draw a preview of group properties
and can open a dialog to modify the properties if the user double-clicks
it.
"""
- def __init__(self, parent, id, props, shapeType,
- size = wxDefaultSize, style = 0):
- wxControl.__init__(self, parent, id, size = size, style = style)
+ def __init__(self, parent, id, props, shapeType,
+ size = wx.DefaultSize, style = 0):
+ wx.Control.__init__(self, parent, id, size = size, style = style)
self.parent = parent
@@ -1492,22 +1492,22 @@
self.SetShapeType(shapeType)
self.AllowEdit(True)
- EVT_PAINT(self, self._OnPaint)
- EVT_LEFT_DCLICK(self, self._OnLeftDClick)
+ self.Bind(wx.EVT_PAINT, self._OnPaint)
+ self.Bind(wx.EVT_LEFT_DCLICK, self._OnLeftDClick)
self.previewer = ClassDataPreviewer()
def _OnPaint(self, event):
- dc = wxPaintDC(self)
+ dc = wx.PaintDC(self)
# XXX: this doesn't seem to be having an effect:
- dc.DestroyClippingRegion()
+ dc.DestroyClippingRegion()
w, h = self.GetClientSize()
- self.previewer.Draw(dc,
- wxRect(0, 0, w, h),
- self.GetProperties(),
+ self.previewer.Draw(dc,
+ wx.Rect(0, 0, w, h),
+ self.GetProperties(),
self.GetShapeType())
@@ -1534,11 +1534,11 @@
if not self.allowEdit: return
- propDlg = SelectPropertiesDialog(self.parent,
- self.GetProperties(),
+ propDlg = SelectPropertiesDialog(self.parent,
+ self.GetProperties(),
self.GetShapeType())
- if propDlg.ShowModal() == wxID_OK:
+ if propDlg.ShowModal() == wx.ID_OK:
new_prop = propDlg.GetClassGroupProperties()
self.SetProperties(new_prop)
self.Refresh()
Modified: trunk/thuban/Thuban/UI/colordialog.py
===================================================================
--- trunk/thuban/Thuban/UI/colordialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/colordialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -9,10 +9,7 @@
# $Source$
# $Id$
-from wxPython.wx import wxDialog, wxColourDialog, wxID_OK, wxID_CANCEL, \
- wxBoxSizer, wxVERTICAL, wxHORIZONTAL, wxALL, \
- wxALIGN_CENTER_HORIZONTAL, wxButton, EVT_BUTTON, \
- wxInitAllImageHandlers
+import wx
from Thuban import _
@@ -27,37 +24,37 @@
try:
from wxPython.lib.colourchooser import wxPyColourChooser
_wxPyColourChooser = True
- wxInitAllImageHandlers() # should be somewhere at Thuban startup?
+ wx.InitAllImageHandlers() # should be somewhere at Thuban startup?
except:
_wxPyColourChooser = False
-class PyColorChooserDialog(wxDialog):
+class PyColorChooserDialog(wx.Dialog):
"""
A Dialog that uses the wxPyColourChooser Frame and simply
adds OK and Cancel button to form a modal color selection dialog.
"""
def __init__(self, parent):
- wxDialog.__init__(self, parent, -1, _("Select Color"))
+ wx.Dialog.__init__(self, parent, -1, _("Select Color"))
self.parent = parent
self.dialog_layout()
def dialog_layout(self):
- top_box = wxBoxSizer(wxVERTICAL)
+ top_box = wx.BoxSizer(wx.VERTICAL)
self.chooser = wxPyColourChooser(self, -1)
- top_box.Add(self.chooser, 1, wxALL | wxALIGN_CENTER_HORIZONTAL, 5)
+ top_box.Add(self.chooser, 1, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxButton(self, wxID_OK, _("OK")), 0, wxALL, 4)
- box.Add(wxButton(self, wxID_CANCEL, _("Cancel")), 0, wxALL, 4)
- top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.Button(self, wx.ID_OK, _("OK")), 0, wx.ALL, 4)
+ box.Add(wx.Button(self, wx.ID_CANCEL, _("Cancel")), 0, wx.ALL, 4)
+ top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10)
- EVT_BUTTON(self, wxID_OK, self.OnOK)
- EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
self.SetAutoLayout(True)
self.SetSizer(top_box)
@@ -71,10 +68,10 @@
return self.chooser.SetValue(color)
def OnOK(self, event):
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
def OnCancel(self, event):
- self.EndModal(wxID_CANCEL)
+ self.EndModal(wx.ID_CANCEL)
class ColorDialog:
@@ -94,7 +91,7 @@
if _wxPyColourChooser:
self.dlg = PyColorChooserDialog(parent)
else:
- self.dlg = wxColourDialog(parent)
+ self.dlg = wx.ColourDialog(parent)
def GetColor(self):
if _wxPyColourChooser:
@@ -108,7 +105,7 @@
self.dlg.SetValue(Color2wxColour(color))
else:
self.dlg.GetColourData().SetColour(Color2wxColour(color))
-
+
def ShowModal(self):
return self.dlg.ShowModal()
@@ -121,13 +118,13 @@
from wxPython.wx import wxApp, NULL
- wxInitAllImageHandlers()
+ wx.InitAllImageHandlers()
- class _TestApp(wxApp):
+ class _TestApp(wx.App):
def OnInit(self):
dialog = ColorDialog(NULL)
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
print "Selected color:", dialog.GetColor()
else:
print "No color selected"
Modified: trunk/thuban/Thuban/UI/command.py
===================================================================
--- trunk/thuban/Thuban/UI/command.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/command.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -37,7 +37,7 @@
of a toggled command. These functions are called with just the
context as parameters.
"""
-
+
args = ()
kwargs = None
sensitive = None
Modified: trunk/thuban/Thuban/UI/common.py
===================================================================
--- trunk/thuban/Thuban/UI/common.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/common.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -13,12 +13,11 @@
from Thuban.Model.color import Color
-from wxPython.wx import wxColour, \
- wxBeginBusyCursor, wxEndBusyCursor, wxSafeYield
+import wx
def Color2wxColour(color):
"""Return a wxColor object for the Thuban color object color"""
- return wxColour(int(round(color.red * 255)),
+ return wx.Colour(int(round(color.red * 255)),
int(round(color.green * 255)),
int(round(color.blue * 255)))
@@ -41,8 +40,8 @@
This function and the corresponding ThubanEndBusyCursor function are
the functions to use in Thuban to set a busy cursor.
"""
- wxBeginBusyCursor()
- wxSafeYield()
+ wx.BeginBusyCursor()
+ wx.SafeYield()
def ThubanEndBusyCursor():
"""Thuban wrapper for wxEndBusyCursor
@@ -50,4 +49,4 @@
This function doesn't do anything more than calling wxEndBusyCursor
yet, but please use this whereever you use ThubanBeginBusyCursor.
"""
- wxEndBusyCursor()
+ wx.EndBusyCursor()
Modified: trunk/thuban/Thuban/UI/controls.py
===================================================================
--- trunk/thuban/Thuban/UI/controls.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/controls.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -10,11 +10,8 @@
__version__ = "$Revision$"
-from wxPython.wx import wxListCtrl, wxLC_REPORT, wxLIST_AUTOSIZE_USEHEADER, \
- EVT_LIST_ITEM_SELECTED
-from wxPython.grid import wxPyGridTableBase, wxGrid, wxGRID_VALUE_STRING, \
- wxGridTableMessage, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, \
- wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES
+import wx
+from wx import grid
from Thuban import _
@@ -24,12 +21,12 @@
-class RecordListCtrl(wxListCtrl):
+class RecordListCtrl(wx.ListCtrl):
"""List Control showing a single record from a thuban table"""
def __init__(self, parent, id):
- wxListCtrl.__init__(self, parent, id, style = wxLC_REPORT)
+ wx.ListCtrl.__init__(self, parent, id, style = wx.LC_REPORT)
self.InsertColumn(0, _("Field"))
self.SetColumnWidth(0, 200)
@@ -67,7 +64,7 @@
# selected is the index of the selected record or -1 if none is
# selected
self.selected = -1
- EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected)
+ self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, id=self.GetId())
def OnItemSelected(self, event):
"""Event handler. Update the selected instvar"""
@@ -81,14 +78,14 @@
return None
-class RecordTable(wxPyGridTableBase):
+class RecordTable(grid.PyGridTableBase):
"""Wrapper that makes a Thuban table record look like a table for a
wxGrid
"""
def __init__(self, table = None, record = None):
- wxPyGridTableBase.__init__(self)
+ grid.PyGridTableBase.__init__(self)
self.num_cols = 1
self.num_rows = 0
self.table = None
@@ -125,22 +122,22 @@
def notify_append_rows(self, num):
"""Tell the view that num rows were appended"""
- self.send_view_message(wxGRIDTABLE_NOTIFY_ROWS_APPENDED, num)
+ self.send_view_message(grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, num)
def notify_delete_rows(self, start, num):
"""Tell the view that num rows were deleted starting at start"""
- self.send_view_message(wxGRIDTABLE_NOTIFY_ROWS_DELETED, start, num)
+ self.send_view_message(grid.GRIDTABLE_NOTIFY_ROWS_DELETED, start, num)
def notify_get_values(self):
"""Tell the view that the grid's values have to be updated"""
- self.send_view_message(wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
+ self.send_view_message(grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
def send_view_message(self, msgid, *args):
"""Send the message msgid to the view with arguments args"""
view = self.GetView()
if view:
#print "send_view_message", msgid, args
- msg = apply(wxGridTableMessage, (self, msgid) + args)
+ msg = apply(grid.GridTableMessage, (self, msgid) + args)
view.ProcessTableMessage(msg)
#
@@ -192,7 +189,7 @@
# it's probably a wx bug (filed as #593189 on sourceforge)
if 0 <= row < self.num_rows:
return self.rows[row][1]
- return wxGRID_VALUE_STRING
+ return grid.GRID_VALUE_STRING
# Called to determine how the data can be fetched and stored by the
# editor and renderer. This allows you to enforce some type-safety
@@ -206,12 +203,12 @@
-class RecordGridCtrl(wxGrid):
+class RecordGridCtrl(grid.Grid):
"""Grid view for a RecordTable"""
def __init__(self, parent, table = None, record = None):
- wxGrid.__init__(self, parent, -1)
+ grid.Grid.__init__(self, parent, -1)
self.table = RecordTable(table, record)
Modified: trunk/thuban/Thuban/UI/dbdialog.py
===================================================================
--- trunk/thuban/Thuban/UI/dbdialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/dbdialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -11,7 +11,7 @@
import sys, traceback
-from wxPython.wx import *
+import wx
try:
import psycopg
@@ -35,11 +35,11 @@
ID_LB_DCLICK = 9204
-class ChooseDBTableDialog(wxDialog):
+class ChooseDBTableDialog(wx.Dialog):
def __init__(self, parent, session):
- wxDialog.__init__(self, parent, -1, _("Choose layer from database"),
- style = wxDIALOG_MODAL|wxCAPTION)
+ wx.Dialog.__init__(self, parent, -1, _("Choose layer from database"),
+ style = wx.DIALOG_MODAL|wx.CAPTION)
self.session = session
self.dbconns = self.session.DBConnections()
self.tables = []
@@ -49,18 +49,18 @@
#
# Sizer for the entire dialog
- top = wxFlexGridSizer(2, 1, 0, 0)
+ top = wx.FlexGridSizer(2, 1, 0, 0)
# Sizer for the main part with the list boxes
- main_sizer = wxBoxSizer(wxHORIZONTAL)
- top.Add(main_sizer, 1, wxEXPAND, 0)
+ main_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ top.Add(main_sizer, 1, wx.EXPAND, 0)
# The list box with the connections
- static_box = wxStaticBoxSizer(wxStaticBox(self, -1, _("Databases")),
- wxHORIZONTAL)
- self.lb_connections = wxListBox(self, -1)
- static_box.Add(self.lb_connections, 0, wxEXPAND, 0)
- main_sizer.Add(static_box, 1, wxEXPAND, 0)
+ static_box = wx.StaticBoxSizer(wx.StaticBox(self, -1, _("Databases")),
+ wx.HORIZONTAL)
+ self.lb_connections = wx.ListBox(self, -1)
+ static_box.Add(self.lb_connections, 0, wx.EXPAND, 0)
+ main_sizer.Add(static_box, 1, wx.EXPAND, 0)
for i in range(len(self.dbconns)):
self.lb_connections.Append(self.dbconns[i].BriefDescription())
@@ -69,48 +69,48 @@
# The button box between the connections list box and the table
# list box
- buttons = wxFlexGridSizer(3, 1, 0, 0)
- buttons.Add( (20, 80), 0, wxEXPAND, 0)
- retrieve_button = wxButton(self, ID_DBCHOOSE_RETRIEVE, _("Retrieve"))
- EVT_BUTTON(self, ID_DBCHOOSE_RETRIEVE, self.OnRetrieve)
- buttons.Add(retrieve_button, 0, wxALL
- |wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4)
- buttons.Add( (20, 80), 0, wxEXPAND, 0)
- main_sizer.Add(buttons, 0, wxEXPAND, 0)
+ buttons = wx.FlexGridSizer(3, 1, 0, 0)
+ buttons.Add( (20, 80), 0, wx.EXPAND, 0)
+ retrieve_button = wx.Button(self, ID_DBCHOOSE_RETRIEVE, _("Retrieve"))
+ self.Bind(wx.EVT_BUTTON, self.OnRetrieve, id=ID_DBCHOOSE_RETRIEVE)
+ buttons.Add(retrieve_button, 0, wx.ALL
+ |wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 4)
+ buttons.Add( (20, 80), 0, wx.EXPAND, 0)
+ main_sizer.Add(buttons, 0, wx.EXPAND, 0)
# The list box with the tables
- static_box = wxStaticBoxSizer(wxStaticBox(self, -1, _("Tables")),
- wxHORIZONTAL)
- self.lb_tables = wxListBox(self, ID_LB_DCLICK)
- EVT_LISTBOX(self, ID_LB_DCLICK, self.OnTableSelect)
- EVT_LISTBOX_DCLICK(self, ID_LB_DCLICK, self.OnLBDClick)
- static_box.Add(self.lb_tables, 0, wxEXPAND, 0)
- main_sizer.Add(static_box, 1, wxEXPAND, 0)
+ static_box = wx.StaticBoxSizer(wx.StaticBox(self, -1, _("Tables")),
+ wx.HORIZONTAL)
+ self.lb_tables = wx.ListBox(self, ID_LB_DCLICK)
+ self.Bind(wx.EVT_LISTBOX, self.OnTableSelect, id=ID_LB_DCLICK)
+ self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnLBDClick, id=ID_LB_DCLICK)
+ static_box.Add(self.lb_tables, 0, wx.EXPAND, 0)
+ main_sizer.Add(static_box, 1, wx.EXPAND, 0)
# id column and geometry column selection
- box = wxBoxSizer(wxVERTICAL)
- box.Add(wxStaticText(self, -1, _("ID Column")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_id_column = wxComboBox(self, -1, "")
+ box = wx.BoxSizer(wx.VERTICAL)
+ box.Add(wx.StaticText(self, -1, _("ID Column")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_id_column = wx.ComboBox(self, -1, "")
box.Add(self.text_id_column, 0,
- wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
- box.Add(wxStaticText(self, -1, _("Geometry Column")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_geo_column = wxComboBox(self, -1, "")
+ box.Add(wx.StaticText(self, -1, _("Geometry Column")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_geo_column = wx.ComboBox(self, -1, "")
box.Add(self.text_geo_column, 0,
- wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
- main_sizer.Add(box, 1, wxEXPAND, 0)
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
+ main_sizer.Add(box, 1, wx.EXPAND, 0)
# The standard button box at the bottom of the dialog
- buttons = wxFlexGridSizer(1, 2, 0, 0)
- ok_button = wxButton(self, ID_DBCHOOSE_OK, _("OK"))
- EVT_BUTTON(self, ID_DBCHOOSE_OK, self.OnOK)
- buttons.Add(ok_button, 0, wxALL|wxALIGN_RIGHT, 4)
- cancel_button = wxButton(self, ID_DBCHOOSE_CANCEL, _("Cancel"))
- EVT_BUTTON(self, ID_DBCHOOSE_CANCEL, self.OnCancel)
- buttons.Add(cancel_button, 0, wxALL, 4)
- top.Add(buttons, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 4)
+ buttons = wx.FlexGridSizer(1, 2, 0, 0)
+ ok_button = wx.Button(self, ID_DBCHOOSE_OK, _("OK"))
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=ID_DBCHOOSE_OK)
+ buttons.Add(ok_button, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
+ cancel_button = wx.Button(self, ID_DBCHOOSE_CANCEL, _("Cancel"))
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=ID_DBCHOOSE_CANCEL)
+ buttons.Add(cancel_button, 0, wx.ALL, 4)
+ top.Add(buttons, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 4)
# Autosizing
self.SetAutoLayout(1)
@@ -148,19 +148,19 @@
def OnLBDClick(self, event):
if self.lb_tables.GetSelection() >= 0:
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
self.Show(False)
def OnOK(self, event):
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
self.Show(False)
def OnCancel(self, event):
- self.EndModal(wxID_CANCEL)
+ self.EndModal(wx.ID_CANCEL)
self.Show(False)
-class DBDialog(wxDialog):
+class DBDialog(wx.Dialog):
"""Dialog for the parameters of a database connection"""
@@ -175,62 +175,62 @@
using the dialog to ask for correct parameters when the
connection can't be established.
"""
- wxDialog.__init__(self, parent, -1, title)
+ wx.Dialog.__init__(self, parent, -1, title)
- top = wxBoxSizer(wxVERTICAL)
+ top = wx.BoxSizer(wx.VERTICAL)
if message:
- top.Add(wxStaticText(self, -1, message), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
+ top.Add(wx.StaticText(self, -1, message), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxStaticText(self, -1, _("Hostname:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_host = wxTextCtrl(self, -1, parameters.get("host", ""))
- box.Add(self.text_host, 2, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
- box.Add(wxStaticText(self, -1, _("Port:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_port = wxTextCtrl(self, -1, parameters.get("port", ""))
- box.Add(self.text_port, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
- top.Add(box, 0, wxEXPAND)
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.StaticText(self, -1, _("Hostname:")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_host = wx.TextCtrl(self, -1, parameters.get("host", ""))
+ box.Add(self.text_host, 2, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
+ box.Add(wx.StaticText(self, -1, _("Port:")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_port = wx.TextCtrl(self, -1, parameters.get("port", ""))
+ box.Add(self.text_port, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
+ top.Add(box, 0, wx.EXPAND)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxStaticText(self, -1, _("Database Name:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_dbname = wxTextCtrl(self, -1,
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.StaticText(self, -1, _("Database Name:")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_dbname = wx.TextCtrl(self, -1,
parameters.get("dbname", ""))
- box.Add(self.text_dbname, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
- top.Add(box, 0, wxEXPAND)
+ box.Add(self.text_dbname, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
+ top.Add(box, 0, wx.EXPAND)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxStaticText(self, -1, _("User:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_user = wxTextCtrl(self, -1,
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.StaticText(self, -1, _("User:")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_user = wx.TextCtrl(self, -1,
parameters.get("user", ""))
- box.Add(self.text_user, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
- box.Add(wxStaticText(self, -1, _("Password:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.text_password = wxTextCtrl(self, -1,
+ box.Add(self.text_user, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
+ box.Add(wx.StaticText(self, -1, _("Password:")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.text_password = wx.TextCtrl(self, -1,
parameters.get("password", ""),
- style = wxTE_PASSWORD)
- box.Add(self.text_password, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND,
+ style = wx.TE_PASSWORD)
+ box.Add(self.text_password, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND,
4)
- top.Add(box, 0, wxEXPAND)
+ top.Add(box, 0, wx.EXPAND)
- buttons = wxBoxSizer(wxHORIZONTAL)
- button = wxButton(self, wxID_OK, _("OK"))
- buttons.Add(button, 0, wxALL, 4)
- button = wxButton(self, wxID_CANCEL, _("Cancel"))
- buttons.Add(button, 0, wxALL, 4)
- top.Add(buttons, 0, wxALIGN_RIGHT, 4)
+ buttons = wx.BoxSizer(wx.HORIZONTAL)
+ button = wx.Button(self, wx.ID_OK, _("OK"))
+ buttons.Add(button, 0, wx.ALL, 4)
+ button = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
+ buttons.Add(button, 0, wx.ALL, 4)
+ top.Add(buttons, 0, wx.ALIGN_RIGHT, 4)
self.SetAutoLayout(1)
self.SetSizer(top)
top.Fit(self)
top.SetSizeHints(self)
- EVT_BUTTON(self, wxID_OK, self.OnOK)
- EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
def RunDialog(self):
self.ShowModal()
@@ -240,9 +240,9 @@
def end_dialog(self, result):
self.result = result
if result is not None:
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
else:
- self.EndModal(wxID_CANCEL)
+ self.EndModal(wx.ID_CANCEL)
self.Show(False)
def OnOK(self, event):
@@ -261,7 +261,7 @@
"""Databse connection management dialog"""
def __init__(self, parent, name, session, *args, **kwds):
- kwds["style"] = wxICONIZE|wxCAPTION|wxMINIMIZE
+ kwds["style"] = wx.ICONIZE|wx.CAPTION|wx.MINIMIZE
NonModalDialog.__init__(self, parent, name, "")
self.session = session
self.app = self.parent.application
@@ -269,16 +269,16 @@
self.app.Subscribe(SESSION_REPLACED, self.session_replaced)
self.subscribe_session()
- self.DB_ListBox = wxListBox(self, -1,
- style=wxLB_SINGLE|wxLB_HSCROLL|wxLB_ALWAYS_SB)
- self.DB_Add = wxButton(self, ID_DB_ADD, _("Add"))
- self.DB_Remove = wxButton(self, ID_DB_REMOVE, _("Remove"))
- self.DB_CLOSE = wxButton(self, wxID_CLOSE, _("Close"))
+ self.DB_ListBox = wx.ListBox(self, -1,
+ style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_ALWAYS_SB)
+ self.DB_Add = wx.Button(self, ID_DB_ADD, _("Add"))
+ self.DB_Remove = wx.Button(self, ID_DB_REMOVE, _("Remove"))
+ self.DB_CLOSE = wx.Button(self, wx.ID_CLOSE, _("Close"))
self.__set_properties()
self.__do_layout()
- EVT_BUTTON(self, ID_DB_ADD, self.OnAdd)
- EVT_BUTTON(self, ID_DB_REMOVE, self.OnRemove)
- EVT_BUTTON(self, wxID_CLOSE, self.OnClose)
+ self.Bind(wx.EVT_BUTTON, self.OnAdd, id=ID_DB_ADD)
+ self.Bind(wx.EVT_BUTTON, self.OnRemove, id=ID_DB_REMOVE)
+ self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
self.conns_changed()
@@ -287,23 +287,23 @@
self.DB_ListBox.SetSize((200, 157))
def __do_layout(self):
- top = wxBoxSizer(wxVERTICAL)
+ top = wx.BoxSizer(wx.VERTICAL)
- box = wxBoxSizer(wxHORIZONTAL)
+ box = wx.BoxSizer(wx.HORIZONTAL)
- box.Add(self.DB_ListBox, 1, wxALL|wxEXPAND
- |wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4)
+ box.Add(self.DB_ListBox, 1, wx.ALL|wx.EXPAND
+ |wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 4)
- buttons = wxBoxSizer(wxVERTICAL)
- buttons.Add(self.DB_Add, 0, wxALL, 4)
- buttons.Add(self.DB_Remove, 0, wxALL, 4)
+ buttons = wx.BoxSizer(wx.VERTICAL)
+ buttons.Add(self.DB_Add, 0, wx.ALL, 4)
+ buttons.Add(self.DB_Remove, 0, wx.ALL, 4)
- box.Add(buttons, 0, wxEXPAND)
- top.Add(box, 1, wxEXPAND)
+ box.Add(buttons, 0, wx.EXPAND)
+ top.Add(box, 1, wx.EXPAND)
- buttons = wxBoxSizer(wxHORIZONTAL)
- buttons.Add(self.DB_CLOSE, 1, wxALL|wxALIGN_RIGHT, 4)
- top.Add(buttons, 0, wxALIGN_RIGHT)
+ buttons = wx.BoxSizer(wx.HORIZONTAL)
+ buttons.Add(self.DB_CLOSE, 1, wx.ALL|wx.ALIGN_RIGHT, 4)
+ top.Add(buttons, 0, wx.ALIGN_RIGHT)
self.SetAutoLayout(1)
self.SetSizer(top)
@@ -345,7 +345,7 @@
self.app.Unsubscribe(SESSION_REPLACED, self.session_replaced)
NonModalDialog.OnClose(self, event)
- def RunMessageBox(self, title, text, flags = wxOK | wxICON_INFORMATION):
+ def RunMessageBox(self, title, text, flags = wx.OK | wx.ICON_INFORMATION):
"""Run a modal message box with the given text, title and flags
and return the result"""
dlg = wxMessageDialog(self, text, title, flags)
Modified: trunk/thuban/Thuban/UI/dialogs.py
===================================================================
--- trunk/thuban/Thuban/UI/dialogs.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/dialogs.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -10,17 +10,17 @@
__version__ = "$Revision$"
-from wxPython.wx import *
+import wx
-class ThubanFrame(wxFrame):
+class ThubanFrame(wx.Frame):
def __init__(self, parent, name, title):
- wxFrame.__init__(self, parent, -1, title,
- style = wxDEFAULT_FRAME_STYLE )
+ wx.Frame.__init__(self, parent, -1, title,
+ style = wx.DEFAULT_FRAME_STYLE )
self.parent = parent
self.name = name
- EVT_CLOSE(self, self.OnClose)
- EVT_WINDOW_DESTROY(self, self.OnDestroy)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
+ self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
def OnClose(self, event):
# FIXME: Shouldn't this really be in OnDestroy?
@@ -32,37 +32,37 @@
"""Implement in derived classes for resource cleanup, etc."""
-class NonModalDialog(wxDialog):
+class NonModalDialog(wx.Dialog):
def __init__(self, parent, name, title):
- wxDialog.__init__(self, parent, -1, title,
- style = wxDEFAULT_DIALOG_STYLE
- | wxSYSTEM_MENU
- | wxMINIMIZE_BOX
- | wxMAXIMIZE_BOX
- | wxRESIZE_BORDER
+ wx.Dialog.__init__(self, parent, -1, title,
+ style = wx.DEFAULT_DIALOG_STYLE
+ | wx.SYSTEM_MENU
+ | wx.MINIMIZE_BOX
+ | wx.MAXIMIZE_BOX
+ | wx.RESIZE_BORDER
)
self.parent = parent
self.name = name
- EVT_CLOSE(self, self.OnClose)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
if self.parent.dialogs.has_key(self.name):
self.parent.remove_dialog(self.name)
self.Destroy()
-class NonModalNonParentDialog(wxDialog):
+class NonModalNonParentDialog(wx.Dialog):
def __init__(self, parent, name, title):
- wxDialog.__init__(self, None, -1, title,
- style = wxDEFAULT_DIALOG_STYLE
- | wxSYSTEM_MENU
- | wxMINIMIZE_BOX
- | wxMAXIMIZE_BOX
- | wxRESIZE_BORDER
- | wxDIALOG_NO_PARENT
+ wx.Dialog.__init__(self, None, -1, title,
+ style = wx.DEFAULT_DIALOG_STYLE
+ | wx.SYSTEM_MENU
+ | wx.MINIMIZE_BOX
+ | wx.MAXIMIZE_BOX
+ | wx.RESIZE_BORDER
+ | wx.DIALOG_NO_PARENT
)
self.parent = parent
self.name = name
- EVT_CLOSE(self, self.OnClose)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
if self.parent.dialogs.has_key(self.name):
Modified: trunk/thuban/Thuban/UI/dock.py
===================================================================
--- trunk/thuban/Thuban/UI/dock.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/dock.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -20,7 +20,7 @@
from Thuban import _
-from wxPython.wx import *
+import wx
from Thuban.Lib.connector import Publisher
@@ -37,7 +37,7 @@
UNDOCK_BMP = "undock_12"
CLOSE_BMP = "close_12"
-class DockPanel(wxPanel):
+class DockPanel(wx.Panel):
"""A DockPanel is a panel that should be derived from to create panels
that can be docked in a DockFrame.
"""
@@ -50,7 +50,7 @@
if not isinstance(parent, DockableWindow):
raise TypeError("")
- wxPanel.__init__(self, parent.GetCurrentParent(), id)
+ wx.Panel.__init__(self, parent.GetCurrentParent(), id)
self.parent = parent
@@ -59,7 +59,7 @@
def Create(self):
self.parent.SetPanel(self)
-
+
def SetDockParent(self, parent):
self.__dockParent = parent
@@ -94,7 +94,7 @@
def __getattr__(self, attr):
return getattr(self.__topWindow, attr)
- def __init__(self, parent, id, name, title, dockWindow, orient):
+ def __init__(self, parent, id, name, title, dockWindow, orient):
"""Create the dockable window.
Initially, the window is hidden, but in an undocked state.
@@ -109,7 +109,7 @@
self.__orientation = orient
self.__dockWindow = dockWindow
- self.__floatWindow = wxFrame(parent, id, title)
+ self.__floatWindow = wx.Frame(parent, id, title)
self.__docked = False
if self.__docked:
@@ -126,7 +126,7 @@
self.__dockWindow.Hide()
self.__floatWindow.Hide()
- EVT_CLOSE(self, self._OnClose)
+ self.Bind(wx.EVT_CLOSE, self._OnClose)
##
# Public methods
@@ -148,14 +148,14 @@
def GetPanel(self):
return self.__panel
-
+
def GetCurrentParent(self):
return self.__topWindow
def SetDock(self, dock):
self.__CheckAllGood()
-
+
if dock:
self.Dock()
else:
@@ -187,7 +187,7 @@
self.__dockButton.SetBitmapFocus(self.__bmpUnDock)
self.__dockButton.SetBitmapSelected(self.__bmpUnDock)
self.__dockButton.SetBitmapDisabled(self.__bmpUnDock)
- self.__dockButton.SetToolTip(wxToolTip(_("Undock")))
+ self.__dockButton.SetToolTip(wx.ToolTip(_("Undock")))
self.SetDockSize(self.__dockWindow.GetSize())
@@ -204,7 +204,7 @@
if wasVisible: self.Show(False)
self.__docked = False
-
+
#
# reparent
#
@@ -215,16 +215,16 @@
self.__dockButton.SetBitmapFocus(self.__bmpDock)
self.__dockButton.SetBitmapSelected(self.__bmpDock)
self.__dockButton.SetBitmapDisabled(self.__bmpDock)
- self.__dockButton.SetToolTip(wxToolTip(_("Dock")))
+ self.__dockButton.SetToolTip(wx.ToolTip(_("Dock")))
if wasVisible: self.Show()
#
# restore window information
#
- if self.__floatPosition is not None:
+ if self.__floatPosition is not None:
self.SetPosition(self.__floatPosition)
- if self.__floatSize is not None:
+ if self.__floatSize is not None:
self.SetSize(self.__floatSize)
self.__dockPanel.SetSize(self.__topWindow.GetClientSize())
@@ -260,20 +260,20 @@
else:
rw = w
rh = h
-
+
# these are to account for the border?!!?
rw += 8 # XXX: without this the sash isn't visible!?!?!?!
rh += 8 # XXX: without this the sash isn't visible!?!?!?!
-
- self.__dockWindow.SetDefaultSize(wxSize(rw, rh))
+ self.__dockWindow.SetDefaultSize(wx.Size(rw, rh))
+
def Destroy(self):
self.__panel.Destroy()
self.__floatWindow.Destroy()
self.__dockWindow.Destroy()
self.__parent.OnDockDestroy(self)
-
+
##
# Event handlers
#
@@ -305,7 +305,7 @@
if self.__topWindow is self.__dockWindow:
self.__parent._UpdateDocks()
-
+
def __DoHide(self):
if not self.IsShown(): return
@@ -316,28 +316,28 @@
def __CreateBorder(self):
- self.__dockPanel = wxPanel(self.__topWindow, -1, style=wxSUNKEN_BORDER)
+ self.__dockPanel = wx.Panel(self.__topWindow, -1, style=wx.SUNKEN_BORDER)
self.__panel.Reparent(self.__dockPanel)
self.__panel.SetId(PANEL_ID)
- if self.__orientation == wxLAYOUT_VERTICAL:
- sizer = wxBoxSizer(wxVERTICAL)
- headerBoxOrient = wxHORIZONTAL
+ if self.__orientation == wx.LAYOUT_VERTICAL:
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ headerBoxOrient = wx.HORIZONTAL
else:
- sizer = wxBoxSizer(wxHORIZONTAL)
- headerBoxOrient = wxVERTICAL
-
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ headerBoxOrient = wx.VERTICAL
- headerBox = wxStaticBoxSizer(
- wxStaticBox(self.__dockPanel, -1, ""), headerBoxOrient)
+ headerBox = wx.StaticBoxSizer(
+ wx.StaticBox(self.__dockPanel, -1, ""), headerBoxOrient)
+
#
# ideally, we should be able to rotate this text depending on
# our orientation
#
- text = wxStaticText(self.__dockPanel, -1, self.GetTitle(),
- style = wxALIGN_CENTRE)
+ text = wx.StaticText(self.__dockPanel, -1, self.GetTitle(),
+ style = wx.ALIGN_CENTRE)
font = text.GetFont()
font.SetPointSize(10)
text.SetFont(font)
@@ -347,44 +347,44 @@
# and create the buttons
#
self.__bmpDock = \
- resource.GetBitmapResource(DOCK_BMP, wxBITMAP_TYPE_XPM)
+ resource.GetBitmapResource(DOCK_BMP, wx.BITMAP_TYPE_XPM)
self.__bmpUnDock = \
- resource.GetBitmapResource(UNDOCK_BMP, wxBITMAP_TYPE_XPM)
+ resource.GetBitmapResource(UNDOCK_BMP, wx.BITMAP_TYPE_XPM)
if self.__docked:
bmp = self.__bmpDock
else:
bmp = self.__bmpUnDock
- self.__dockButton = wxBitmapButton(
- self.__dockPanel, ID_BUTTON_DOCK,
- bmp,
- size = wxSize(bmp.GetWidth() + 4, bmp.GetHeight() + 4),
- style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
+ self.__dockButton = wx.BitmapButton(
+ self.__dockPanel, ID_BUTTON_DOCK,
+ bmp,
+ size = wx.Size(bmp.GetWidth() + 4, bmp.GetHeight() + 4),
+ style = wx.BU_EXACTFIT | wx.ADJUST_MINSIZE)
- bmp = resource.GetBitmapResource(CLOSE_BMP, wxBITMAP_TYPE_XPM)
+ bmp = resource.GetBitmapResource(CLOSE_BMP, wx.BITMAP_TYPE_XPM)
- closeX = wxBitmapButton(self.__dockPanel, ID_BUTTON_CLOSE, bmp,
- size = wxSize(bmp.GetWidth() + 4,
+ closeX = wx.BitmapButton(self.__dockPanel, ID_BUTTON_CLOSE, bmp,
+ size = wx.Size(bmp.GetWidth() + 4,
bmp.GetHeight() + 4),
- style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
- closeX.SetToolTip(wxToolTip(_("Close")))
+ style = wx.BU_EXACTFIT | wx.ADJUST_MINSIZE)
+ closeX.SetToolTip(wx.ToolTip(_("Close")))
#
# fill in the sizer in an order appropriate to the orientation
#
- if self.__orientation == wxLAYOUT_VERTICAL:
- headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)
- headerBox.Add((1, 5), 1, wxGROW)
- headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)
- headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxLEFT, 4)
+ if self.__orientation == wx.LAYOUT_VERTICAL:
+ headerBox.Add(text, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTRE_VERTICAL, 0)
+ headerBox.Add((1, 5), 1, wx.GROW)
+ headerBox.Add(self.__dockButton, 0, wx.ALIGN_RIGHT, 0)
+ headerBox.Add(closeX, 0, wx.ALIGN_RIGHT | wx.LEFT, 4)
else:
- headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxBOTTOM, 4)
- headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)
- headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)
+ headerBox.Add(closeX, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 4)
+ headerBox.Add(self.__dockButton, 0, wx.ALIGN_RIGHT, 0)
+ headerBox.Add(text, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTRE_VERTICAL, 0)
- sizer.Add(headerBox, 0, wxGROW, 0)
- sizer.Add(self.__panel, 1, wxGROW, 0)
+ sizer.Add(headerBox, 0, wx.GROW, 0)
+ sizer.Add(self.__panel, 1, wx.GROW, 0)
self.__dockPanel.SetAutoLayout(True)
@@ -392,15 +392,15 @@
sizer.SetSizeHints(self.__dockPanel)
sizer.SetSizeHints(self.__floatWindow)
- EVT_BUTTON(self.__dockPanel, ID_BUTTON_DOCK, self._OnToggleDock)
- EVT_BUTTON(self.__dockPanel, ID_BUTTON_CLOSE, self._OnButtonClose)
+ self.Bind(wx.EVT_BUTTON, self._OnToggleDock, self.__dockPanel, id=ID_BUTTON_DOCK)
+ self.Bind(wx.EVT_BUTTON, self._OnButtonClose, self.__dockPanel, id=ID_BUTTON_CLOSE)
-class DockFrame(wxFrame):
+class DockFrame(wx.Frame):
"""A DockFrame is a frame that will contain dockable panels."""
def __init__(self, parent, id, title, position, size):
- wxFrame.__init__(self, parent, id, title, position, size)
+ wx.Frame.__init__(self, parent, id, title, position, size)
self.openWindows = {}
@@ -409,15 +409,15 @@
self.SetMainWindow(None)
- EVT_SIZE(self, self._OnSashSize)
- EVT_CLOSE(self, self.OnClose)
+ self.Bind(wx.EVT_SIZE, self._OnSashSize)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
- layout2oppSash = {
- wxLAYOUT_NONE : wxSASH_NONE,
- wxLAYOUT_TOP : wxSASH_BOTTOM,
- wxLAYOUT_LEFT : wxSASH_RIGHT,
- wxLAYOUT_RIGHT : wxSASH_LEFT,
- wxLAYOUT_BOTTOM : wxSASH_TOP }
+ layout2oppSash = {
+ wx.LAYOUT_NONE : wx.SASH_NONE,
+ wx.LAYOUT_TOP : wx.SASH_BOTTOM,
+ wx.LAYOUT_LEFT : wx.SASH_RIGHT,
+ wx.LAYOUT_RIGHT : wx.SASH_LEFT,
+ wx.LAYOUT_BOTTOM : wx.SASH_TOP }
def OnClose(self, event):
@@ -444,12 +444,12 @@
wxLAYOUT_RIGHT.
"""
- if align in (wxLAYOUT_NONE, wxLAYOUT_LEFT, wxLAYOUT_RIGHT):
- orient = wxLAYOUT_VERTICAL
+ if align in (wx.LAYOUT_NONE, wx.LAYOUT_LEFT, wx.LAYOUT_RIGHT):
+ orient = wx.LAYOUT_VERTICAL
else:
- orient = wxLAYOUT_HORIZONTAL
+ orient = wx.LAYOUT_HORIZONTAL
- sash = wxSashLayoutWindow(self, id, style=wxNO_BORDER|wxSW_3D)
+ sash = wx.SashLayoutWindow(self, id, style=wx.NO_BORDER|wx.SW_3D)
sash.SetOrientation(orient)
sash.SetAlignment(align)
sash.SetSashVisible(DockFrame.layout2oppSash[align], True)
@@ -458,7 +458,7 @@
win = DockableWindow(self, id, name, title, sash, orient)
self.__RegisterDock(name, win)
- EVT_SASH_DRAGGED(self, id, self._OnSashDragged)
+ self.Bind(wx.EVT_SASH_DRAGGED, self._OnSashDragged, id=id)
return win
@@ -473,13 +473,13 @@
def SetMainWindow(self, main):
self.__mainWindow = main
self._UpdateDocks()
-
+
def _UpdateDocks(self):
if self.__update_lock == 0:
- wxLayoutAlgorithm().LayoutWindow(self, self.__mainWindow)
+ wx.LayoutAlgorithm().LayoutWindow(self, self.__mainWindow)
def _OnSashDragged(self, event):
- if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
+ if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
return
id = event.GetId()
Modified: trunk/thuban/Thuban/UI/exceptiondialog.py
===================================================================
--- trunk/thuban/Thuban/UI/exceptiondialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/exceptiondialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -9,11 +9,11 @@
import sys
-from wxPython.wx import *
+import wx
from Thuban import _
-class ExceptionDialog(wxDialog):
+class ExceptionDialog(wx.Dialog):
"""The exception dialog shows the exception message and then allows
to either proceed with the application or to exit it. In the
@@ -21,31 +21,31 @@
"""
def __init__(self, parent, message, title = _('Thuban: Internal Error')):
- wxDialog.__init__(self, parent, -1, title,
- wxDefaultPosition,
- style = wxRESIZE_BORDER|wxCAPTION|wxDIALOG_MODAL)
+ wx.Dialog.__init__(self, parent, -1, title,
+ wx.DefaultPosition,
+ style = wx.RESIZE_BORDER|wx.CAPTION|wx.DIALOG_MODAL)
self.parent = parent
self.dialog_layout(message)
-
+
def dialog_layout(self, message):
- top_box = wxBoxSizer(wxVERTICAL)
+ top_box = wx.BoxSizer(wx.VERTICAL)
- textBox = wxTextCtrl(self, -1, message,
- style=wxTE_READONLY|wxTE_MULTILINE|wxTE_LINEWRAP)
+ textBox = wx.TextCtrl(self, -1, message,
+ style=wx.TE_READONLY|wx.TE_MULTILINE|wx.TE_LINEWRAP)
w, h = (500, 300)
textBox.SetSizeHints(w, h)
textBox.SetSize((w, h))
- top_box.Add(textBox, 1, wxEXPAND|wxALL, 10)
+ top_box.Add(textBox, 1, wx.EXPAND|wx.ALL, 10)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxButton(self, wxID_OK, _("Proceed")), 0, wxALL, 4)
- box.Add(wxButton(self, wxID_CANCEL, _("Exit Thuban now")), 0, wxALL, 4)
- top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.Button(self, wx.ID_OK, _("Proceed")), 0, wx.ALL, 4)
+ box.Add(wx.Button(self, wx.ID_CANCEL, _("Exit Thuban now")), 0, wx.ALL, 4)
+ top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10)
- EVT_BUTTON(self, wxID_OK, self.OnOK)
- EVT_BUTTON(self, wxID_CANCEL, self.OnExit)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, self.OnExit, id=wx.ID_CANCEL)
self.SetAutoLayout(True)
self.SetSizer(top_box)
@@ -53,7 +53,7 @@
top_box.SetSizeHints(self)
def OnOK(self, event):
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
def OnExit(self, event):
sys.exit(1)
Modified: trunk/thuban/Thuban/UI/identifyview.py
===================================================================
--- trunk/thuban/Thuban/UI/identifyview.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/identifyview.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -8,8 +8,8 @@
__version__ = "$Revision$"
-from wxPython.wx import *
-from wxPython.grid import *
+import wx
+from wx import grid
from Thuban import _
@@ -44,22 +44,22 @@
NonModalDialog.__init__(self, parent, name, _("Identify Shape"))
parent.Subscribe(SHAPES_SELECTED, self.selected_shape)
- top_box = wxBoxSizer(wxVERTICAL)
+ top_box = wx.BoxSizer(wx.VERTICAL)
if main.options.attribute_editing_enabled:
self.list = IdentifyGridCtrl(self)
else:
self.list = IdentifyListCtrl(self, -1)
- self.list.SetSize(wxSize(305,200))
- top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)
+ self.list.SetSize(wx.Size(305,200))
+ top_box.Add(self.list, 1, wx.EXPAND|wx.ALL, 4)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxButton(self, wxID_CLOSE, _("Close Window")), 0, wxALL, 4)
- box.Add(wxButton(self, self.ID_STOP, _("Stop Identify Mode")),
- 0, wxALL, 4)
- top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 4)
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.Button(self, wx.ID_CLOSE, _("Close Window")), 0, wx.ALL, 4)
+ box.Add(wx.Button(self, self.ID_STOP, _("Stop Identify Mode")),
+ 0, wx.ALL, 4)
+ top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 4)
- EVT_BUTTON(self, wxID_CLOSE, self.OnClose)
- EVT_BUTTON(self, self.ID_STOP, self.OnStop)
+ self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
+ self.Bind(wx.EVT_BUTTON, self.OnStop, id=self.ID_STOP)
self.SetAutoLayout(True)
self.SetSizer(top_box)
Modified: trunk/thuban/Thuban/UI/join.py
===================================================================
--- trunk/thuban/Thuban/UI/join.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/join.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -13,7 +13,7 @@
import sys
-from wxPython.wx import *
+import wx
from Thuban import _
@@ -28,7 +28,7 @@
CHOICE_WIDTH = 150
-class JoinDialog(wxDialog):
+class JoinDialog(wx.Dialog):
"""Table join dialog.
@@ -37,35 +37,35 @@
"""
def __init__(self, parent, title, session, layer = None):
- wxDialog.__init__(self, parent, -1, title,
- style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
+ wx.Dialog.__init__(self, parent, -1, title,
+ style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
self.layer = layer
if not layer:
- self.choice_left_table = wxChoice(self, ID_LEFT_TABLE)
+ self.choice_left_table = wx.Choice(self, ID_LEFT_TABLE)
width, height = self.choice_left_table.GetSizeTuple()
- self.choice_left_table.SetSize(wxSize(CHOICE_WIDTH, height))
+ self.choice_left_table.SetSize(wx.Size(CHOICE_WIDTH, height))
self.left_table = None
else:
self.choice_left_table = None
self.left_table = layer.ShapeStore().Table()
- self.choice_right_table = wxChoice(self, ID_RIGHT_TABLE)
+ self.choice_right_table = wx.Choice(self, ID_RIGHT_TABLE)
width, height = self.choice_right_table.GetSizeTuple()
- self.choice_right_table.SetSize(wxSize(CHOICE_WIDTH, height))
+ self.choice_right_table.SetSize(wx.Size(CHOICE_WIDTH, height))
- self.choice_left_field = wxChoice(self, -1)
+ self.choice_left_field = wx.Choice(self, -1)
width, height = self.choice_left_field.GetSizeTuple()
- self.choice_left_field.SetSize(wxSize(CHOICE_WIDTH, height))
- self.choice_right_field = wxChoice(self, -1)
+ self.choice_left_field.SetSize(wx.Size(CHOICE_WIDTH, height))
+ self.choice_right_field = wx.Choice(self, -1)
width, height = self.choice_right_field.GetSizeTuple()
- self.choice_right_field.SetSize(wxSize(CHOICE_WIDTH, height))
+ self.choice_right_field.SetSize(wx.Size(CHOICE_WIDTH, height))
- self.button_join = wxButton(self, wxID_OK, _("Join"))
+ self.button_join = wx.Button(self, wx.ID_OK, _("Join"))
self.button_join.SetDefault()
- self.button_close = wxButton(self, wxID_CANCEL, _("Close"))
+ self.button_close = wx.Button(self, wx.ID_CANCEL, _("Close"))
- EVT_BUTTON(self, wxID_OK, self.OnJoin)
+ self.Bind(wx.EVT_BUTTON, self.OnJoin, id=wx.ID_OK)
if self.choice_left_table is not None:
self.choice_left_table.Append(_('Select...'), None)
@@ -86,53 +86,53 @@
self.choice_left_field.Append(col.name, col)
if self.choice_left_table is not None:
- EVT_CHOICE(self, ID_LEFT_TABLE, self.OnLeftTable)
- EVT_CHOICE(self, ID_RIGHT_TABLE, self.OnRightTable)
+ self.Bind(wx.EVT_CHOICE, self.OnLeftTable, id=ID_LEFT_TABLE)
+ self.Bind(wx.EVT_CHOICE, self.OnRightTable, id=ID_RIGHT_TABLE)
if self.choice_left_table is not None:
self.choice_left_table.SetSelection(0)
self.choice_right_table.SetSelection(0)
self.button_join.Enable(False)
- topBox = wxBoxSizer(wxVERTICAL)
+ topBox = wx.BoxSizer(wx.VERTICAL)
- sizer = wxFlexGridSizer(2, 4)
- sizer.Add(wxStaticText(self, -1, _("Table:")), 0, wxALL, 4)
+ sizer = wx.FlexGridSizer(2, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Table:")), 0, wx.ALL, 4)
if self.choice_left_table is not None:
sizer.Add(self.choice_left_table, 1,
- wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 4)
+ wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
else:
- sizer.Add(wxStaticText(self, -1, self.left_table.Title()), 0,
- wxALL, 4)
+ sizer.Add(wx.StaticText(self, -1, self.left_table.Title()), 0,
+ wx.ALL, 4)
- sizer.Add(wxStaticText(self, -1, _("Table:")), 0, wxALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Table:")), 0, wx.ALL, 4)
sizer.Add(self.choice_right_table, 1,
- wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 4)
- sizer.Add(wxStaticText(self, -1, _("Field:")), 0, wxALL, 4)
+ wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Field:")), 0, wx.ALL, 4)
sizer.Add(self.choice_left_field, 1,
- wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 4)
- sizer.Add(wxStaticText(self, -1, _("Field:")), 0, wxALL, 4)
+ wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Field:")), 0, wx.ALL, 4)
sizer.Add(self.choice_right_field, 1,
- wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 4)
+ wx.EXPAND|wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
sizer.AddGrowableCol(1)
sizer.AddGrowableCol(3)
- topBox.Add(sizer, 0, wxEXPAND|wxALL, 4)
+ topBox.Add(sizer, 0, wx.EXPAND|wx.ALL, 4)
- sizer = wxBoxSizer(wxHORIZONTAL)
- self.check_outer_join = wxCheckBox(self,-1,
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.check_outer_join = wx.CheckBox(self,-1,
_("Outer Join (preserves left table records)"))
- sizer.Add(self.check_outer_join, 1, wxALL,4)
- topBox.Add(sizer, 0, wxALIGN_LEFT|wxALIGN_TOP, 4)
+ sizer.Add(self.check_outer_join, 1, wx.ALL,4)
+ topBox.Add(sizer, 0, wx.ALIGN_LEFT|wx.ALIGN_TOP, 4)
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(self.button_join, 0, wxALIGN_RIGHT|wxALIGN_BOTTOM|wxRIGHT,
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(self.button_join, 0, wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM|wx.RIGHT,
10)
- sizer.Add(self.button_close, 0, wxALIGN_RIGHT|wxALIGN_BOTTOM|wxRIGHT,
+ sizer.Add(self.button_close, 0, wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM|wx.RIGHT,
10)
- topBox.Add(sizer, 1, wxALIGN_RIGHT|wxALIGN_BOTTOM|wxBOTTOM|wxTOP, 10)
+ topBox.Add(sizer, 1, wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM|wx.BOTTOM|wx.TOP, 10)
self.SetAutoLayout(True)
self.SetSizer(topBox)
@@ -160,22 +160,22 @@
right_table = self.choice_right_table.GetClientData(i)
i = self.choice_right_field.GetSelection()
right_field = self.choice_right_field.GetString(i)
-
+
outer_join = self.check_outer_join.IsChecked()
-
+
try:
joined_table = TransientJoinedTable(self.session.TransientDB(),
left_table, left_field,
right_table, right_field,
outer_join)
except:
- dlg = wxMessageDialog(None,
+ dlg = wx.MessageDialog(None,
_('Join failed:\n %s') % sys.exc_info()[1],
- _('Info'), wxOK|wxICON_ERROR)
+ _('Info'), wx.OK|wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return
-
+
joined_table = self.session.AddTable(joined_table)
if self.layer is not None:
@@ -197,8 +197,8 @@
" to be used with the selected layer") \
% {"joined": joined_rows,
"needed": needed_rows}
- dlg = wxMessageDialog(None, msg, _('Join Failed'),
- wxOK|wxICON_ERROR)
+ dlg = wx.MessageDialog(None, msg, _('Join Failed'),
+ wx.OK|wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return
@@ -210,7 +210,7 @@
joined_table)
self.parent.add_dialog(name, dialog)
dialog.Show(True)
-
+
self.Close()
def OnClose(self, event):
Modified: trunk/thuban/Thuban/UI/labeldialog.py
===================================================================
--- trunk/thuban/Thuban/UI/labeldialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/labeldialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -7,7 +7,7 @@
__version__ = "$Revision$"
-from wxPython.wx import *
+import wx
from Thuban import _
@@ -20,30 +20,30 @@
self.fill_list(table, shape)
-class LabelDialog(wxDialog):
+class LabelDialog(wx.Dialog):
def __init__(self, parent, table, shape_index):
- wxDialog.__init__(self, parent, -1, _("Label Values"),
- wxDefaultPosition,
- style = wxRESIZE_BORDER|wxCAPTION|wxDIALOG_MODAL)
+ wx.Dialog.__init__(self, parent, -1, _("Label Values"),
+ wx.DefaultPosition,
+ style = wx.RESIZE_BORDER|wx.CAPTION|wx.DIALOG_MODAL)
self.parent = parent
self.dialog_layout(table, shape_index)
-
+
def dialog_layout(self, table, shape_index):
- top_box = wxBoxSizer(wxVERTICAL)
+ top_box = wx.BoxSizer(wx.VERTICAL)
self.list = LabelListCtrl(self, -1, table, shape_index)
- self.list.SetSize(wxSize(305,200))
- top_box.Add(self.list, 1, wxEXPAND|wxALL, 4)
+ self.list.SetSize(wx.Size(305,200))
+ top_box.Add(self.list, 1, wx.EXPAND|wx.ALL, 4)
- box = wxBoxSizer(wxHORIZONTAL)
- box.Add(wxButton(self, wxID_OK, _("OK")), 0, wxALL, 4)
- box.Add(wxButton(self, wxID_CANCEL, _("Cancel")), 0, wxALL, 4)
- top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(wx.Button(self, wx.ID_OK, _("OK")), 0, wx.ALL, 4)
+ box.Add(wx.Button(self, wx.ID_CANCEL, _("Cancel")), 0, wx.ALL, 4)
+ top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10)
- EVT_BUTTON(self, wxID_OK, self.OnOK)
- EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
self.SetAutoLayout(True)
self.SetSizer(top_box)
@@ -53,12 +53,12 @@
def OnOK(self, event):
result = self.list.GetValue()
if result is not None:
- self.end_dialog(wxID_OK, str(result))
+ self.end_dialog(wx.ID_OK, str(result))
else:
- self.end_dialog(wxID_CANCEL, None)
+ self.end_dialog(wx.ID_CANCEL, None)
def OnCancel(self, event):
- self.end_dialog(wxID_CANCEL, None)
+ self.end_dialog(wx.ID_CANCEL, None)
def end_dialog(self, wx_result, result):
self.result = result
@@ -66,7 +66,7 @@
def run_label_dialog(parent, table, shape_index):
dialog = LabelDialog(parent, table, shape_index)
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
return dialog.result
else:
return None
Modified: trunk/thuban/Thuban/UI/layerproperties.py
===================================================================
--- trunk/thuban/Thuban/UI/layerproperties.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/layerproperties.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -13,7 +13,7 @@
from Thuban import _
-from wxPython.wx import *
+import wx
from Thuban.Model.messages import MAP_LAYERS_REMOVED, LAYER_SHAPESTORE_REPLACED
from dialogs import NonModalNonParentDialog
from messages import MAP_REPLACED
@@ -43,27 +43,27 @@
if self.layout_recurse: return
self.layout_recurse = True
- panel = wxPanel(self, -1)
+ panel = wx.Panel(self, -1)
- topBox = wxBoxSizer(wxVERTICAL)
- panelBox = wxBoxSizer(wxVERTICAL)
+ topBox = wx.BoxSizer(wx.VERTICAL)
+ panelBox = wx.BoxSizer(wx.VERTICAL)
# Title
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(wxStaticText(panel, -1, _("Title: ")),
- 0, wxALIGN_LEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 4)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(wx.StaticText(panel, -1, _("Title: ")),
+ 0, wx.ALIGN_LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 4)
- text_title = wxTextCtrl(panel, ID_PROPERTY_TITLE, self.layer.Title())
+ text_title = wx.TextCtrl(panel, ID_PROPERTY_TITLE, self.layer.Title())
text_title.SetInsertionPointEnd()
- sizer.Add(text_title, 1, wxGROW | wxRIGHT, 0)
+ sizer.Add(text_title, 1, wx.GROW | wx.RIGHT, 0)
- panelBox.Add(sizer, 0, wxGROW | wxALL, 4)
+ panelBox.Add(sizer, 0, wx.GROW | wx.ALL, 4)
# Type
- panelBox.Add(wxStaticText(panel, -1,
+ panelBox.Add(wx.StaticText(panel, -1,
_("Layer Type: %s") % self.layer.Type()),
- 0, wxALIGN_LEFT | wxALL, 4)
+ 0, wx.ALIGN_LEFT | wx.ALL, 4)
# Projection
proj = self.layer.GetProjection()
@@ -71,30 +71,30 @@
text = _("Projection: None")
else:
text = _("Projection: %s") % proj.Label()
-
- panelBox.Add(wxStaticText(panel, -1, text), 0, wxALIGN_LEFT | wxALL, 4)
+ panelBox.Add(wx.StaticText(panel, -1, text), 0, wx.ALIGN_LEFT | wx.ALL, 4)
+
self.dialog_layout(panel, panelBox)
- button_try = wxButton(self, ID_PROPERTY_TRY, _("Try"))
- button_revert = wxButton(self, ID_PROPERTY_REVERT, _("Revert"))
- button_ok = wxButton(self, wxID_OK, _("OK"))
- button_close = wxButton(self, wxID_CANCEL, _("Close"))
+ button_try = wx.Button(self, ID_PROPERTY_TRY, _("Try"))
+ button_revert = wx.Button(self, ID_PROPERTY_REVERT, _("Revert"))
+ button_ok = wx.Button(self, wx.ID_OK, _("OK"))
+ button_close = wx.Button(self, wx.ID_CANCEL, _("Close"))
button_ok.SetDefault()
- buttonBox = wxBoxSizer(wxHORIZONTAL)
- buttonBox.Add(button_try, 0, wxRIGHT|wxEXPAND, 10)
- buttonBox.Add(button_revert, 0, wxRIGHT|wxEXPAND, 10)
- buttonBox.Add(button_ok, 0, wxRIGHT|wxEXPAND, 10)
- buttonBox.Add(button_close, 0, wxRIGHT|wxEXPAND, 0)
+ buttonBox = wx.BoxSizer(wx.HORIZONTAL)
+ buttonBox.Add(button_try, 0, wx.RIGHT|wx.EXPAND, 10)
+ buttonBox.Add(button_revert, 0, wx.RIGHT|wx.EXPAND, 10)
+ buttonBox.Add(button_ok, 0, wx.RIGHT|wx.EXPAND, 10)
+ buttonBox.Add(button_close, 0, wx.RIGHT|wx.EXPAND, 0)
panel.SetAutoLayout(True)
panel.SetSizer(panelBox)
- panelBox.Fit(panel)
- panelBox.SetSizeHints(panel)
+ panelBox.Fit(panel)
+ panelBox.SetSizeHints(panel)
- topBox.Add(panel, 1, wxGROW | wxALL, 4)
- topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxALL, 10)
+ topBox.Add(panel, 1, wx.GROW | wx.ALL, 4)
+ topBox.Add(buttonBox, 0, wx.ALIGN_RIGHT|wx.ALL, 10)
self.SetAutoLayout(True)
self.SetSizer(topBox)
@@ -104,11 +104,11 @@
###########
- EVT_TEXT(self, ID_PROPERTY_TITLE, self.OnTitleChanged)
- EVT_BUTTON(self, wxID_OK, self.OnOK)
- EVT_BUTTON(self, ID_PROPERTY_TRY, self.OnTry)
- EVT_BUTTON(self, wxID_CANCEL, self.OnCloseBtn)
- EVT_BUTTON(self, ID_PROPERTY_REVERT, self.OnRevert)
+ self.Bind(wx.EVT_TEXT, self.OnTitleChanged, id=ID_PROPERTY_TITLE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
+ self.Bind(wx.EVT_BUTTON, self.OnTry, id=ID_PROPERTY_TRY)
+ self.Bind(wx.EVT_BUTTON, self.OnCloseBtn, id=wx.ID_CANCEL)
+ self.Bind(wx.EVT_BUTTON, self.OnRevert, id=ID_PROPERTY_REVERT)
######################
Modified: trunk/thuban/Thuban/UI/legend.py
===================================================================
--- trunk/thuban/Thuban/UI/legend.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/legend.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -14,8 +14,7 @@
import resource
-from wxPython.wx import *
-import wxPython
+import wx
from Thuban.Model.layer import BaseLayer
from Thuban.Model.map import Map
@@ -58,7 +57,7 @@
class LegendPanel(DockPanel):
- def __init__(self, parent, map, mainWindow):
+ def __init__(self, parent, map, mainWindow):
DockPanel.__init__(self, parent, -1)
self.mainWindow = mainWindow
@@ -66,56 +65,56 @@
self.buttons = []
- panelBox = wxBoxSizer(wxVERTICAL)
+ panelBox = wx.BoxSizer(wx.VERTICAL)
- self.toolBar = wxToolBar(self, -1)
- self.toolBar.SetToolBitmapSize(wxSize(24, 24))
+ self.toolBar = wx.ToolBar(self, -1)
+ self.toolBar.SetToolBitmapSize(wx.Size(24, 24))
- bmp = resource.GetBitmapResource(TOP_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_TOP, bmp,
+ bmp = resource.GetBitmapResource(TOP_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_TOP, bmp,
shortHelpString=_("Top Layer"))
- bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_RAISE, bmp,
+ bmp = resource.GetBitmapResource(RAISE_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_RAISE, bmp,
shortHelpString=_("Raise Layer"))
- bmp = resource.GetBitmapResource(LOWER_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_LOWER, bmp,
+ bmp = resource.GetBitmapResource(LOWER_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_LOWER, bmp,
shortHelpString=_("Lower Layer"))
- bmp = resource.GetBitmapResource(BOTTOM_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_BOTTOM, bmp,
+ bmp = resource.GetBitmapResource(BOTTOM_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_BOTTOM, bmp,
shortHelpString=_("Bottom Layer"))
- bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp,
+ bmp = resource.GetBitmapResource(SHOW_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp,
shortHelpString=_("Show Layer"))
- bmp = resource.GetBitmapResource(HIDE_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_HIDELAYER, bmp,
+ bmp = resource.GetBitmapResource(HIDE_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_HIDELAYER, bmp,
shortHelpString=_("Hide Layer"))
- bmp = resource.GetBitmapResource(PROPS_BMP, wxBITMAP_TYPE_XPM)
- self.toolBar.AddTool(ID_LEGEND_PROPS, bmp,
+ bmp = resource.GetBitmapResource(PROPS_BMP, wx.BITMAP_TYPE_XPM)
+ self.toolBar.AddTool(ID_LEGEND_PROPS, bmp,
shortHelpString=_("Edit Layer Properties"))
self.toolBar.Realize()
- panelBox.Add(self.toolBar, 0, wxGROW, 0)
+ panelBox.Add(self.toolBar, 0, wx.GROW, 0)
- EVT_TOOL(self, ID_LEGEND_TOP, self._OnMoveTop)
- EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp)
- EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown)
- EVT_TOOL(self, ID_LEGEND_BOTTOM, self._OnMoveBottom)
- EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties)
- EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)
- EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)
+ self.Bind(wx.EVT_TOOL, self._OnMoveTop, id=ID_LEGEND_TOP)
+ self.Bind(wx.EVT_TOOL, self._OnMoveUp, id=ID_LEGEND_RAISE)
+ self.Bind(wx.EVT_TOOL, self._OnMoveDown, id=ID_LEGEND_LOWER)
+ self.Bind(wx.EVT_TOOL, self._OnMoveBottom, id=ID_LEGEND_BOTTOM)
+ self.Bind(wx.EVT_TOOL, self._OnProperties, id=ID_LEGEND_PROPS)
+ self.Bind(wx.EVT_TOOL, self._OnShowLayer, id=ID_LEGEND_SHOWLAYER)
+ self.Bind(wx.EVT_TOOL, self._OnHideLayer, id=ID_LEGEND_HIDELAYER)
self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow)
- panelBox.Add(self.tree, 1, wxGROW, 0)
+ panelBox.Add(self.tree, 1, wx.GROW, 0)
- self.scalebarbitmap = ScaleBarBitmap(self, map, mainWindow)
- panelBox.Add(self.scalebarbitmap, 0, wxGROW, 0)
+ self.scalebarbitmap = ScaleBarBitmap(self, map, mainWindow)
+ panelBox.Add(self.scalebarbitmap, 0, wx.GROW, 0)
self.SetAutoLayout(True)
self.SetSizer(panelBox)
@@ -128,7 +127,7 @@
self.Create()
- EVT_CLOSE(self, self._OnClose)
+ self.Bind(wx.EVT_CLOSE, self._OnClose)
def GetMap(self):
@@ -160,8 +159,8 @@
def _OnMoveTop(self, event):
self.tree.MoveCurrentItemTop()
-
- def _OnMoveUp(self, event):
+
+ def _OnMoveUp(self, event):
self.tree.MoveCurrentItemUp()
def _OnMoveDown(self, event):
@@ -176,7 +175,7 @@
#def Close(self, force = False):
#DockPanel.Close(self, force)
-
+
def _OnClose(self, event):
self.__Close()
@@ -208,11 +207,11 @@
def __Close(self):
self.tree.Close()
-class LegendTree(wxTreeCtrl):
+class LegendTree(wx.TreeCtrl):
def __init__(self, parent, id, map, mainWindow):
- wxTreeCtrl.__init__(self, parent, id,
- style = wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT,
+ wx.TreeCtrl.__init__(self, parent, id,
+ style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT,
size = (200, 200))
self.mainWindow = mainWindow
@@ -240,13 +239,13 @@
self.preventExpandCollapse = False
self.raiseProperties = False
- EVT_TREE_ITEM_ACTIVATED(self, ID_LEGEND_TREE, self._OnItemActivated)
- EVT_TREE_SEL_CHANGED(self, ID_LEGEND_TREE, self._OnSelChanged)
- EVT_TREE_ITEM_EXPANDING(self, ID_LEGEND_TREE, self.OnItemExpandCollapse)
- EVT_TREE_ITEM_COLLAPSING(self, ID_LEGEND_TREE, self.OnItemExpandCollapse)
- EVT_TREE_ITEM_RIGHT_CLICK(self, ID_LEGEND_TREE, self._OnRightClick)
+ self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self._OnItemActivated, id=ID_LEGEND_TREE)
+ self.Bind(wx.EVT_TREE_SEL_CHANGED, self._OnSelChanged, id=ID_LEGEND_TREE)
+ self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpandCollapse, id=ID_LEGEND_TREE)
+ self.Bind(wx.EVT_TREE_ITEM_COLLAPSING, self.OnItemExpandCollapse, id=ID_LEGEND_TREE)
+ self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self._OnRightClick, id=ID_LEGEND_TREE)
- EVT_CLOSE(self, self._OnClose)
+ self.Bind(wx.EVT_CLOSE, self._OnClose)
self.SetMap(map)
@@ -314,7 +313,7 @@
#except ConnectorError:
#pass
self.DeleteAllItems()
-
+
self.map = map
if self.map is not None:
@@ -370,7 +369,7 @@
layers = self.map.Layers()
return layers.index(data2) - layers.index(data1)
else:
- return wxTreeCtrl.OnCompareItems(self, item1, item2)
+ return wx.TreeCtrl.OnCompareItems(self, item1, item2)
def DoOnShowLayer(self):
layer, group = self.GetSelectedHierarchy()
@@ -411,7 +410,7 @@
def _OnMsgMapsChanged(self):
#print self.map is self.mainWindow.Map()
self.SetMap(self.mainWindow.Map())
-
+
def _OnSelChanged(self, event):
# If we change the selection from normalize_selection do nothing.
if self.changing_selection:
@@ -532,7 +531,7 @@
def __UpdateSelection(self):
layer, group = self.GetSelectedHierarchy()
self.parent.DoOnSelChanged(layer, group)
-
+
def __FillTree(self, map):
self.Freeze()
@@ -570,8 +569,8 @@
bmp = self.__BuildGroupImage(g, shapeType)
if bmp is None:
- self.SetItemImage(id, -1, wxTreeItemIcon_Normal)
- self.SetItemImage(id, -1, wxTreeItemIcon_Selected)
+ self.SetItemImage(id, -1, wx.TreeItemIcon_Normal)
+ self.SetItemImage(id, -1, wx.TreeItemIcon_Selected)
#self.SetItemSelectedImage(id, -1)
else:
if self.availImgListIndices:
@@ -580,17 +579,17 @@
else:
i = self.image_list.Add(bmp)
- self.SetItemImage(id, i, wxTreeItemIcon_Normal)
- self.SetItemImage(id, i, wxTreeItemIcon_Selected)
+ self.SetItemImage(id, i, wx.TreeItemIcon_Normal)
+ self.SetItemImage(id, i, wx.TreeItemIcon_Selected)
#self.SetItemlectedImage(id, i)
self.Thaw()
def __BuildGroupImage(self, group, shapeType):
- bmp = wxEmptyBitmap(BMP_SIZE_W, BMP_SIZE_H)
+ bmp = wx.EmptyBitmap(BMP_SIZE_W, BMP_SIZE_H)
#brush = wxBrush(Color2wxColour(item[1]), wxSOLID)
- dc = wxMemoryDC()
+ dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.Clear()
@@ -607,12 +606,12 @@
self.__RemoveLayer(id)
id, cookie = self.GetNextChild(pid, cookie)
- wxTreeCtrl.DeleteAllItems(self)
+ wx.TreeCtrl.DeleteAllItems(self)
def __AddLayer(self, before, l):
root = self.GetRootItem()
id = self.InsertItemBefore(root, before,
- l.Title(),
+ l.Title(),
self.mapImageIndex,
self.mapImageIndex)
@@ -623,7 +622,7 @@
self.Expand(id)
l.Subscribe(LAYER_CHANGED, self._OnMsgLayerChanged)
- l.Subscribe(LAYER_VISIBILITY_CHANGED,
+ l.Subscribe(LAYER_VISIBILITY_CHANGED,
self._OnMsgLayerVisibilityChanged)
l.Subscribe(TITLE_CHANGED, self._OnMsgLayerTitleChanged)
@@ -631,9 +630,9 @@
self.DeleteChildren(id)
layer = self.GetPyData(id)
- layer.Unsubscribe(LAYER_CHANGED,
+ layer.Unsubscribe(LAYER_CHANGED,
self._OnMsgLayerChanged)
- layer.Unsubscribe(LAYER_VISIBILITY_CHANGED,
+ layer.Unsubscribe(LAYER_VISIBILITY_CHANGED,
self._OnMsgLayerVisibilityChanged)
layer.Unsubscribe(TITLE_CHANGED, self._OnMsgLayerTitleChanged)
@@ -644,26 +643,26 @@
while id.IsOk():
self.availImgListIndices.append(self.GetItemImage(id))
id, cookie = self.GetNextChild(pid, cookie)
- wxTreeCtrl.DeleteChildren(self, pid)
+ wx.TreeCtrl.DeleteChildren(self, pid)
def GetRootItem(self):
- root = wxTreeCtrl.GetRootItem(self)
+ root = wx.TreeCtrl.GetRootItem(self)
if not root.IsOk():
- self.image_list = wxImageList(BMP_SIZE_W, BMP_SIZE_H, False, 0)
+ self.image_list = wx.ImageList(BMP_SIZE_W, BMP_SIZE_H, False, 0)
- bmp = wxEmptyBitmap(BMP_SIZE_W, BMP_SIZE_H)
- dc = wxMemoryDC()
+ bmp = wx.EmptyBitmap(BMP_SIZE_W, BMP_SIZE_H)
+ dc = wx.MemoryDC()
dc.SelectObject(bmp)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetBrush(wx.BLACK_BRUSH)
dc.Clear()
- dc.SelectObject(wxNullBitmap)
+ dc.SelectObject(wx.NullBitmap)
self.emptyImageIndex = \
- self.image_list.AddWithColourMask(bmp, wxColour(0, 0, 0))
+ self.image_list.AddWithColourMask(bmp, wx.Colour(0, 0, 0))
- bmp = resource.GetBitmapResource("legend_icon_layer",
- wxBITMAP_TYPE_XPM)
+ bmp = resource.GetBitmapResource("legend_icon_layer",
+ wx.BITMAP_TYPE_XPM)
self.mapImageIndex = \
self.image_list.Add(bmp)
@@ -678,16 +677,16 @@
font = self.GetItemFont(id)
if visible:
- font.SetStyle(wxNORMAL)
- color = wxBLACK
+ font.SetStyle(wx.NORMAL)
+ color = wx.BLACK
else:
#font.SetStyle(wxITALIC)
- font.SetStyle(wxNORMAL)
- color = wxLIGHT_GREY
+ font.SetStyle(wx.NORMAL)
+ color = wx.LIGHT_GREY
self.SetItemTextColour(id, color)
self.SetItemFont(id, font)
-
+
def __ShowHideLayer(self, layer):
parent = self.find_layer(layer)
assert parent.IsOk()
@@ -710,24 +709,24 @@
# with this and to make the code usable with both 2.5 and 2.4 we
# overwrite the inherited method when running with 2.4 to provide a
# default value for the second argument.
- if map(int, wxPython.__version__.split(".")[:2]) < [2, 5]:
+ if map(int, wx.__version__.split(".")[:2]) < [2, 5]:
def GetFirstChild(self, item):
- return wxTreeCtrl.GetFirstChild(self, item, 0)
+ return wx.TreeCtrl.GetFirstChild(self, item, 0)
-class ScaleBarBitmap(wxBoxSizer):
+class ScaleBarBitmap(wx.BoxSizer):
def __init__(self, parent, map, mainWindow):
# While the width is fixed, get the height _now_.
- dc = wxMemoryDC()
+ dc = wx.MemoryDC()
textwidth, textheight = dc.GetTextExtent("%d"%0)
self.width = 210
self.height = textheight + 3*2 + 8
- wxBoxSizer.__init__(self, wxVERTICAL)
- bmp=wxEmptyBitmap(self.width, self.height)
- self.scalebarBitmap = wxStaticBitmap(parent, -1, bmp)
- self.Add(self.scalebarBitmap, 0, wxALIGN_CENTER|wxLEFT|wxTOP|wxRIGHT, 1)
+ wx.BoxSizer.__init__(self, wx.VERTICAL)
+ bmp=wx.EmptyBitmap(self.width, self.height)
+ self.scalebarBitmap = wx.StaticBitmap(parent, -1, bmp)
+ self.Add(self.scalebarBitmap, 0, wx.ALIGN_CENTER|wx.LEFT|wx.TOP|wx.RIGHT, 1)
self.mainWindow = mainWindow
self.parent = parent
@@ -739,7 +738,7 @@
if self.canvas is not None:
for msg, func in sub_list: self.canvas.Unsubscribe(msg, func)
-
+
self.canvas = canvas
self.scalebar = ScaleBar(canvas.map)
@@ -751,8 +750,8 @@
self.__SetScale(scale)
def __SetScale(self, scale):
- bmp = wxEmptyBitmap(self.width, self.height)
- dc = wxMemoryDC()
+ bmp = wx.EmptyBitmap(self.width, self.height)
+ dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.Clear()
Modified: trunk/thuban/Thuban/UI/main.py
===================================================================
--- trunk/thuban/Thuban/UI/main.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/main.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -7,7 +7,7 @@
# Read the file COPYING coming with Thuban for details.
"""
-The main entry point for the Thuban GUI.
+The main entry point for the Thuban GUI.
"""
__version__ = "$Revision$"
@@ -53,7 +53,7 @@
Print a message containing any libraries which are wrong.
Return True if everything is OK, otherwise False.
"""
-
+
errors = Thuban.version.verify_versions()
if len(errors) > 0:
Modified: trunk/thuban/Thuban/UI/mainwindow.py
===================================================================
--- trunk/thuban/Thuban/UI/mainwindow.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/mainwindow.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -18,7 +18,7 @@
import os
import copy
-from wxPython.wx import *
+import wx
import Thuban
@@ -29,10 +29,7 @@
from Thuban.Model.session import create_empty_session
from Thuban.Model.layer import Layer, RasterLayer
from Thuban.Model.postgisdb import PostGISShapeStore, has_postgis_support
-# XXX: replace this by
-# from wxPython.lib.dialogs import wxMultipleChoiceDialog
-# when Thuban does not support wxPython 2.4.0 any more.
-from Thuban.UI.multiplechoicedialog import wxMultipleChoiceDialog
+from wx.lib.dialogs import MultipleChoiceDialog
import view
import tree
@@ -90,8 +87,8 @@
MAP_LAYERS_REMOVED)
def __init__(self, parent, ID, title, application, interactor,
- initial_message = None, size = wxSize(-1, -1)):
- DockFrame.__init__(self, parent, ID, title, wxDefaultPosition, size)
+ initial_message = None, size = wx.Size(-1, -1)):
+ DockFrame.__init__(self, parent, ID, title, wx.DefaultPosition, size)
#wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, size)
self.application = application
@@ -130,7 +127,7 @@
self.ShowLegend()
- EVT_CLOSE(self, self.OnClose)
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
def Subscribe(self, channel, *args):
"""Subscribe a function to a message channel.
@@ -154,7 +151,7 @@
object = getattr(self, self.delegated_messages[channel])
try:
object.Unsubscribe(channel, *args)
- except wxPyDeadObjectError:
+ except wx.PyDeadObjectError:
# The object was a wxObject and has already been
# destroyed. Hopefully it has unsubscribed all its
# subscribers already so that it's OK if we do nothing
@@ -193,13 +190,13 @@
"""Bind the necessary events for the given command and ID"""
if not self.events_bound.has_key(ID):
# the events haven't been bound yet
- EVT_MENU(self, ID, self.invoke_command)
+ self.Bind(wx.EVT_MENU, self.invoke_command, id=ID)
if command.IsDynamic():
- EVT_UPDATE_UI(self, ID, self.update_command_ui)
+ self.Bind(wx.EVT_UPDATE_UI, self.update_command_ui, id=ID)
def build_menu_bar(self, menudesc):
"""Build and return the menu bar from the menu description"""
- menu_bar = wxMenuBar()
+ menu_bar = wx.MenuBar()
for item in menudesc.items:
# here the items must all be Menu instances themselves
@@ -209,7 +206,7 @@
def build_menu(self, menudesc):
"""Return a wxMenu built from the menu description menudesc"""
- wxmenu = wxMenu()
+ wxmenu = wx.Menu()
last = None
for item in menudesc.items:
if item is None:
@@ -219,7 +216,7 @@
wxmenu.AppendSeparator()
elif isinstance(item, Menu):
# a submenu
- wxmenu.AppendMenu(wxNewId(), item.title, self.build_menu(item))
+ wxmenu.AppendMenu(wx.NewId(), item.title, self.build_menu(item))
else:
# must the name the name of a command
self.add_menu_command(wxmenu, item)
@@ -232,13 +229,13 @@
The parameter should be an instance of the Menu class but it
should not contain submenus.
"""
- toolbar = self.CreateToolBar(wxTB_3DBUTTONS)
+ toolbar = self.CreateToolBar(wx.TB_3DBUTTONS)
# set the size of the tools' bitmaps. Not needed on wxGTK, but
# on Windows, although it doesn't work very well there. It seems
# that only 16x16 icons are really supported on windows.
# We probably shouldn't hardwire the bitmap size here.
- toolbar.SetToolBitmapSize(wxSize(24, 24))
+ toolbar.SetToolBitmapSize(wx.Size(24, 24))
for item in toolbardesc.items:
if item is None:
@@ -279,8 +276,8 @@
command = registry.Command(name)
if command is not None:
ID = self.get_id(name)
- bitmap = resource.GetBitmapResource(command.Icon(),
- wxBITMAP_TYPE_XPM)
+ bitmap = resource.GetBitmapResource(command.Icon(),
+ wx.BITMAP_TYPE_XPM)
toolbar.AddTool(ID, bitmap,
shortHelpString = command.HelpText(),
isToggle = command.IsCheckCommand())
@@ -320,10 +317,10 @@
if command.IsCheckCommand():
event.Check(command.Checked(context))
- def RunMessageBox(self, title, text, flags = wxOK | wxICON_INFORMATION):
+ def RunMessageBox(self, title, text, flags = wx.OK | wx.ICON_INFORMATION):
"""Run a modal message box with the given text, title and flags
and return the result"""
- dlg = wxMessageDialog(self, text, title, flags)
+ dlg = wx.MessageDialog(self, text, title, flags)
dlg.CenterOnParent()
result = dlg.ShowModal()
dlg.Destroy()
@@ -435,7 +432,7 @@
dialog.Show(True)
else:
dialog.Raise()
-
+
def save_modified_session(self, can_veto = 1):
"""If the current session has been modified, ask the user
whether to save it and do so if requested. Return the outcome of
@@ -446,30 +443,30 @@
a cancel button, otherwise not.
"""
if self.application.session.WasModified():
- flags = wxYES_NO | wxICON_QUESTION
+ flags = wx.YES_NO | wx.ICON_QUESTION
if can_veto:
- flags = flags | wxCANCEL
+ flags = flags | wx.CANCEL
result = self.RunMessageBox(_("Exit"),
_("The session has been modified."
" Do you want to save it?"),
flags)
- if result == wxID_YES:
+ if result == wx.ID_YES:
self.SaveSession()
else:
- result = wxID_NO
+ result = wx.ID_NO
return result
def NewSession(self):
- if self.save_modified_session() != wxID_CANCEL:
+ if self.save_modified_session() != wx.ID_CANCEL:
self.application.SetSession(create_empty_session())
def OpenSession(self):
- if self.save_modified_session() != wxID_CANCEL:
- dlg = wxFileDialog(self, _("Open Session"),
- self.application.Path("data"), "",
- "Thuban Session File (*.thuban)|*.thuban",
- wxOPEN)
- if dlg.ShowModal() == wxID_OK:
+ if self.save_modified_session() != wx.ID_CANCEL:
+ dlg = wx.FileDialog(self, _("Open Session"),
+ self.application.Path("data"), "",
+ "Thuban Session File (*.thuban)|*.thuban",
+ wx.OPEN)
+ if dlg.ShowModal() == wx.ID_OK:
self.application.OpenSession(dlg.GetPath(),
self.run_db_param_dialog)
self.application.SetPath("data", dlg.GetPath())
@@ -487,11 +484,11 @@
self.application.SaveSession()
def SaveSessionAs(self):
- dlg = wxFileDialog(self, _("Save Session As"),
+ dlg = wx.FileDialog(self, _("Save Session As"),
self.application.Path("data"), "",
- "Thuban Session File (*.thuban)|*.thuban",
- wxSAVE|wxOVERWRITE_PROMPT)
- if dlg.ShowModal() == wxID_OK:
+ "Thuban Session File (*.thuban)|*.thuban",
+ wx.SAVE|wx.OVERWRITE_PROMPT)
+ if dlg.ShowModal() == wx.ID_OK:
self.application.session.SetFilename(dlg.GetPath())
self.application.SaveSession()
self.application.SetPath("data",dlg.GetPath())
@@ -502,7 +499,7 @@
def OnClose(self, event):
result = self.save_modified_session(can_veto = event.CanVeto())
- if result == wxID_CANCEL:
+ if result == wx.ID_CANCEL:
event.Veto()
else:
# FIXME: it would be better to tie the unsubscription to
@@ -561,12 +558,12 @@
dialog.Raise()
def AddLayer(self):
- dlg = wxFileDialog(self, _("Select one or more data files"),
+ dlg = wx.FileDialog(self, _("Select one or more data files"),
self.application.Path("data"), "",
_("Shapefiles (*.shp)") + "|*.shp;*.SHP|" +
_("All Files (*.*)") + "|*.*",
- wxOPEN | wxMULTIPLE)
- if dlg.ShowModal() == wxID_OK:
+ wx.OPEN | wx.MULTIPLE)
+ if dlg.ShowModal() == wx.ID_OK:
filenames = dlg.GetPaths()
for filename in filenames:
title = os.path.splitext(os.path.basename(filename))[0]
@@ -589,10 +586,10 @@
dlg.Destroy()
def AddRasterLayer(self):
- dlg = wxFileDialog(self, _("Select an image file"),
+ dlg = wx.FileDialog(self, _("Select an image file"),
self.application.Path("data"), "", "*.*",
- wxOPEN)
- if dlg.ShowModal() == wxID_OK:
+ wx.OPEN)
+ if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
title = os.path.splitext(os.path.basename(filename))[0]
map = self.canvas.Map()
@@ -617,7 +614,7 @@
session = self.application.Session()
dlg = ChooseDBTableDialog(self, self.application.Session())
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
dbconn, dbtable, id_column, geo_column = dlg.GetTable()
try:
title = str(dbtable)
@@ -763,7 +760,7 @@
if dialog is None:
map = self.canvas.Map()
- dialog = projdialog.ProjFrame(self, name,
+ dialog = projdialog.ProjFrame(self, name,
_("Map Projection: %s") % map.Title(), map)
self.add_dialog(name, dialog)
dialog.Show()
@@ -778,7 +775,7 @@
if dialog is None:
map = self.canvas.Map()
- dialog = projdialog.ProjFrame(self, name,
+ dialog = projdialog.ProjFrame(self, name,
_("Layer Projection: %s") % layer.Title(), layer)
self.add_dialog(name, dialog)
dialog.Show()
@@ -834,7 +831,7 @@
dialog = self.FindRegisteredDock(name)
if dialog is None:
- dialog = self.CreateDock(name, -1, _("Legend"), wxLAYOUT_LEFT)
+ dialog = self.CreateDock(name, -1, _("Legend"), wx.LAYOUT_LEFT)
legend.LegendPanel(dialog, None, self)
dialog.Dock()
dialog.GetPanel().SetMap(self.Map())
@@ -844,17 +841,17 @@
def LegendShown(self):
"""Return true iff the legend is currently open"""
- dialog = self.FindRegisteredDock("legend")
+ dialog = self.FindRegisteredDock("legend")
return dialog is not None and dialog.IsShown()
def TableOpen(self):
- dlg = wxFileDialog(self, _("Open Table"),
- self.application.Path("data"), "",
- _("DBF Files (*.dbf)") + "|*.dbf|" +
+ dlg = wx.FileDialog(self, _("Open Table"),
+ self.application.Path("data"), "",
+ _("DBF Files (*.dbf)") + "|*.dbf|" +
#_("CSV Files (*.csv)") + "|*.csv|" +
- _("All Files (*.*)") + "|*.*",
- wxOPEN)
- if dlg.ShowModal() == wxID_OK:
+ _("All Files (*.*)") + "|*.*",
+ wx.OPEN)
+ if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
dlg.Destroy()
try:
@@ -873,12 +870,12 @@
lst = [(t.Title(), t) for t in tables]
lst.sort()
titles = [i[0] for i in lst]
- dlg = wxMultipleChoiceDialog(self, _("Pick the tables to close:"),
+ dlg = MultipleChoiceDialog(self, _("Pick the tables to close:"),
_("Close Table"), titles,
size = (400, 300),
- style = wxDEFAULT_DIALOG_STYLE |
- wxRESIZE_BORDER)
- if dlg.ShowModal() == wxID_OK:
+ style = wx.DEFAULT_DIALOG_STYLE |
+ wx.RESIZE_BORDER)
+ if dlg.ShowModal() == wx.ID_OK:
for i in dlg.GetValue():
self.application.session.RemoveTable(lst[i][1])
@@ -894,12 +891,12 @@
lst = [(t.Title(), t) for t in tables]
lst.sort()
titles = [i[0] for i in lst]
- dlg = wxMultipleChoiceDialog(self, _("Pick the table to show:"),
+ dlg = MultipleChoiceDialog(self, _("Pick the table to show:"),
_("Show Table"), titles,
- size = (400,300),
- style = wxDEFAULT_DIALOG_STYLE |
- wxRESIZE_BORDER)
- if (dlg.ShowModal() == wxID_OK):
+ size = (400,300),
+ style = wx.DEFAULT_DIALOG_STYLE |
+ wx.RESIZE_BORDER)
+ if (dlg.ShowModal() == wx.ID_OK):
for i in dlg.GetValue():
# XXX: if the table belongs to a layer, open a
# LayerTableFrame instead of QueryTableFrame
@@ -929,12 +926,12 @@
lst = [(t.Title(), t) for t in tables]
lst.sort()
titles = [i[0] for i in lst]
- dlg = wxMultipleChoiceDialog(self, _("Pick the table to rename:"),
+ dlg = MultipleChoiceDialog(self, _("Pick the table to rename:"),
_("Rename Table"), titles,
- size = (400,300),
- style = wxDEFAULT_DIALOG_STYLE |
- wxRESIZE_BORDER)
- if (dlg.ShowModal() == wxID_OK):
+ size = (400,300),
+ style = wx.DEFAULT_DIALOG_STYLE |
+ wx.RESIZE_BORDER)
+ if (dlg.ShowModal() == wx.ID_OK):
to_rename = [lst[i][1] for i in dlg.GetValue()]
dlg.Destroy()
else:
@@ -942,10 +939,10 @@
# Second, let the user rename the layers
for table in to_rename:
- dlg = wxTextEntryDialog(self, _("Table Title:"), _("Rename Table"),
+ dlg = wx.TextEntryDialog(self, _("Table Title:"), _("Rename Table"),
table.Title())
try:
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
title = dlg.GetValue()
if title != "":
table.SetTitle(title)
@@ -991,9 +988,9 @@
self.canvas.Print()
def RenameMap(self):
- dlg = wxTextEntryDialog(self, _("Map Title:"), _("Rename Map"),
+ dlg = wx.TextEntryDialog(self, _("Map Title:"), _("Rename Map"),
self.Map().Title())
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
title = dlg.GetValue()
if title != "":
self.Map().SetTitle(title)
@@ -1004,10 +1001,10 @@
"""Let the user rename the currently selected layer"""
layer = self.current_layer()
if layer is not None:
- dlg = wxTextEntryDialog(self, _("Layer Title:"), _("Rename Layer"),
+ dlg = wx.TextEntryDialog(self, _("Layer Title:"), _("Rename Layer"),
layer.Title())
try:
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
title = dlg.GetValue()
if title != "":
layer.SetTitle(title)
@@ -1325,7 +1322,7 @@
None,
"toggle_legend",
None]
-if wxPlatform == '__WXMSW__':
+if wx.Platform == '__WXMSW__':
map_menu.append("map_export")
map_menu.append("map_print")
@@ -1364,10 +1361,10 @@
# the main toolbar
main_toolbar = Menu("<toolbar>", "<toolbar>",
- ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool",
- "map_full_extent",
- "layer_full_extent",
- "selected_full_extent",
- None,
+ ["map_zoom_in_tool", "map_zoom_out_tool", "map_pan_tool",
+ "map_full_extent",
+ "layer_full_extent",
+ "selected_full_extent",
+ None,
"map_identify_tool", "map_label_tool"])
Modified: trunk/thuban/Thuban/UI/multiplechoicedialog.py
===================================================================
--- trunk/thuban/Thuban/UI/multiplechoicedialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/multiplechoicedialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -16,18 +16,16 @@
__version__ = "$Revision$"
-from wxPython.wx import *
-from wxPython import wx
-from wxPython.lib.layoutf import Layoutf
+import wx
-class wxMultipleChoiceDialog(wx.wxDialog):
+class wxMultipleChoiceDialog(wx.Dialog):
"""This is a copy of the class wxPython.lib.dialogs.wxMultipleChoiceDialog
and fixes the bug that the style now is passed on (this is fixed
in version wxPython 2.4.1).
"""
- def __init__(self, parent, msg, title, lst, pos = wxDefaultPosition,
- size = (200,200), style = wxDEFAULT_DIALOG_STYLE):
- wxDialog.__init__(self, parent, -1, title, pos, size, style)
+ def __init__(self, parent, msg, title, lst, pos = wx.DefaultPosition,
+ size = (200,200), style = wx.DEFAULT_DIALOG_STYLE):
+ wx.Dialog.__init__(self, parent, -1, title, pos, size, style)
x, y = pos
if x == -1 and y == -1:
self.CenterOnScreen(wx.wxBOTH)
Modified: trunk/thuban/Thuban/UI/projdialog.py
===================================================================
--- trunk/thuban/Thuban/UI/projdialog.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/projdialog.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -14,7 +14,7 @@
# $Id$
import sys, os
-from wxPython.wx import *
+import wx
from Thuban import _
@@ -80,89 +80,89 @@
def build_dialog(self):
"""Build the dialog's widgets and set the event handlers"""
- self.topBox = top_box = wxBoxSizer(wxVERTICAL)
+ self.topBox = top_box = wx.BoxSizer(wx.VERTICAL)
- main_box = wxBoxSizer(wxHORIZONTAL)
- top_box.Add(main_box, 1, wxALL|wxEXPAND)
+ main_box = wx.BoxSizer(wx.HORIZONTAL)
+ top_box.Add(main_box, 1, wx.ALL|wx.EXPAND)
#
# The projection list and associated controls
#
- vbox = wxBoxSizer(wxVERTICAL)
- main_box.Add(vbox, 4, wxALL|wxEXPAND)
+ vbox = wx.BoxSizer(wx.VERTICAL)
+ main_box.Add(vbox, 4, wx.ALL|wx.EXPAND)
#label = wxStaticText(self, -1, _("Available Projections:"))
#vbox.Add(label, 0, wxLEFT|wxRIGHT|wxTOP, 4)
- hbox = wxBoxSizer(wxHORIZONTAL)
- vbox.Add(hbox, 1, wxALL|wxEXPAND)
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ vbox.Add(hbox, 1, wx.ALL|wx.EXPAND)
proj_files = [self.load_user_proj(),
self.load_system_proj(DEFAULT_PROJ_FILE)]
self.projection_list = ProjectionList(self, proj_files,
self.receiver.GetProjection())
- hbox.Add(self.projection_list, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4)
+ hbox.Add(self.projection_list, 1, wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 4)
self.projection_list.Subscribe(PROJ_SELECTION_CHANGED,
self.proj_selection_changed)
# Projection List specific actions (Import/Export/Remove)
- buttons = wxBoxSizer(wxVERTICAL)
- hbox.Add(buttons, 0, wxALL)
- self.button_import = wxButton(self, ID_PROJ_IMPORT, _("Import..."))
- EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport)
- buttons.Add(self.button_import, 1, wxALL|wxEXPAND, 4)
- self.button_export = wxButton(self, ID_PROJ_EXPORT, _("Export..."))
- EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport)
- buttons.Add(self.button_export, 1, wxALL|wxEXPAND, 4)
- buttons.Add( (20, 20), 0, wxEXPAND, 0)
- self.button_remove = wxButton(self, ID_PROJ_REMOVE, _("Remove"))
- EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove)
- buttons.Add(self.button_remove, 1, wxALL|wxEXPAND, 4)
+ buttons = wx.BoxSizer(wx.VERTICAL)
+ hbox.Add(buttons, 0, wx.ALL)
+ self.button_import = wx.Button(self, ID_PROJ_IMPORT, _("Import..."))
+ self.Bind(wx.EVT_BUTTON, self._OnImport, id=ID_PROJ_IMPORT)
+ buttons.Add(self.button_import, 1, wx.ALL|wx.EXPAND, 4)
+ self.button_export = wx.Button(self, ID_PROJ_EXPORT, _("Export..."))
+ self.Bind(wx.EVT_BUTTON, self._OnExport, id=ID_PROJ_EXPORT)
+ buttons.Add(self.button_export, 1, wx.ALL|wx.EXPAND, 4)
+ buttons.Add( (20, 20), 0, wx.EXPAND, 0)
+ self.button_remove = wx.Button(self, ID_PROJ_REMOVE, _("Remove"))
+ self.Bind(wx.EVT_BUTTON, self._OnRemove, id=ID_PROJ_REMOVE)
+ buttons.Add(self.button_remove, 1, wx.ALL|wx.EXPAND, 4)
- buttons.Add( (20, 20), 0, wxEXPAND, 0)
- label = wxStaticText(self, -1, _("Show EPSG:"))
- buttons.Add(label, 0, wxLEFT|wxRIGHT|wxTOP, 4)
- self.check_epsg = wxCheckBox(self, -1, _("Normal"))
- EVT_CHECKBOX(self, self.check_epsg.GetId(), self._OnShowEPSG)
- buttons.Add(self.check_epsg, 1, wxALL|wxEXPAND, 4)
- self.check_epsg_depr = wxCheckBox(self, -1, _("Deprecated"))
- EVT_CHECKBOX(self, self.check_epsg_depr.GetId(), self._OnShowEPSG)
- buttons.Add(self.check_epsg_depr, 1, wxALL|wxEXPAND, 4)
+ buttons.Add( (20, 20), 0, wx.EXPAND, 0)
+ label = wx.StaticText(self, -1, _("Show EPSG:"))
+ buttons.Add(label, 0, wx.LEFT|wx.RIGHT|wx.TOP, 4)
+ self.check_epsg = wx.CheckBox(self, -1, _("Normal"))
+ self.Bind(wx.EVT_CHECKBOX, self._OnShowEPSG, id=self.check_epsg.GetId())
+ buttons.Add(self.check_epsg, 1, wx.ALL|wx.EXPAND, 4)
+ self.check_epsg_depr = wx.CheckBox(self, -1, _("Deprecated"))
+ self.Bind(wx.EVT_CHECKBOX, self._OnShowEPSG, id=self.check_epsg_depr.GetId())
+ buttons.Add(self.check_epsg_depr, 1, wx.ALL|wx.EXPAND, 4)
# The file path
- self.projfilepath = wxStaticText(self, -1, "")
- vbox.Add(self.projfilepath, 0, wxALL|wxEXPAND)
+ self.projfilepath = wx.StaticText(self, -1, "")
+ vbox.Add(self.projfilepath, 0, wx.ALL|wx.EXPAND)
#
# The projection editor part
#
- self.edit_box = wxStaticBox(self, -1, _("Edit"))
- sizer_edit = wxStaticBoxSizer(self.edit_box, wxHORIZONTAL)
- main_box.Add(sizer_edit, 5, wxALL|wxEXPAND)
+ self.edit_box = wx.StaticBox(self, -1, _("Edit"))
+ sizer_edit = wx.StaticBoxSizer(self.edit_box, wx.HORIZONTAL)
+ main_box.Add(sizer_edit, 5, wx.ALL|wx.EXPAND)
# Projection Specific Entries (Name/Projection)
- self.sizer_projctrls = wxBoxSizer(wxVERTICAL)
- sizer_edit.Add(self.sizer_projctrls, 1, wxALL|wxEXPAND)
+ self.sizer_projctrls = wx.BoxSizer(wx.VERTICAL)
+ sizer_edit.Add(self.sizer_projctrls, 1, wx.ALL|wx.EXPAND)
- hbox = wxBoxSizer(wxHORIZONTAL)
- self.sizer_projctrls.Add(hbox, 0, wxALL|wxEXPAND)
- label = wxStaticText(self, -1, _("Name:"))
- hbox.Add(label, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.projname = wxTextCtrl(self, ID_PROJ_PROJNAME, "")
- EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName)
- hbox.Add(self.projname, 1, wxALL|wxEXPAND, 4)
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ self.sizer_projctrls.Add(hbox, 0, wx.ALL|wx.EXPAND)
+ label = wx.StaticText(self, -1, _("Name:"))
+ hbox.Add(label, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.projname = wx.TextCtrl(self, ID_PROJ_PROJNAME, "")
+ self.Bind(wx.EVT_TEXT, self._OnProjName, id=ID_PROJ_PROJNAME)
+ hbox.Add(self.projname, 1, wx.ALL|wx.EXPAND, 4)
- hbox = wxBoxSizer(wxHORIZONTAL)
- self.sizer_projctrls.Add(hbox, 0, wxALL|wxEXPAND)
- label = wxStaticText(self, -1, _("Projection:"))
- hbox.Add(label, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
- self.projchoice = wxChoice(self, ID_PROJ_PROJCHOICE)
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ self.sizer_projctrls.Add(hbox, 0, wx.ALL|wx.EXPAND)
+ label = wx.StaticText(self, -1, _("Projection:"))
+ hbox.Add(label, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ self.projchoice = wx.Choice(self, ID_PROJ_PROJCHOICE)
self.projchoice.SetSelection(0)
- EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)
- hbox.Add(self.projchoice, 1, wxALL|wxEXPAND, 4)
+ self.Bind(wx.EVT_CHOICE, self._OnProjChoice, id=ID_PROJ_PROJCHOICE)
+ hbox.Add(self.projchoice, 1, wx.ALL|wx.EXPAND, 4)
# Fill the projection choice list.
self.nbsizer = NotebookLikeSizer()
self.sizer_projctrls.Add(self.nbsizer, 1,
- wxALL|wxEXPAND|wxADJUST_MINSIZE, 3)
+ wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 3)
self.projection_panels = []
self.projchoice.Append(_("<Unknown>"), "")
for proj_type, name, cls in self.projection_panel_defs:
@@ -178,37 +178,37 @@
self.nbsizer.Add(self.unknown_projection_panel)
# Projection Specific actions (New/Save/Add)
- buttons = wxBoxSizer(wxVERTICAL)
- sizer_edit.Add(buttons, 0, wxALL)
- self.button_new = wxButton(self, ID_PROJ_NEW, _("New"))
- EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew)
- buttons.Add(self.button_new, 0, wxEXPAND|wxALL, 4)
- self.button_add = wxButton(self, ID_PROJ_ADDTOLIST, _("Add to List"))
- EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList)
- buttons.Add(self.button_add, 0, wxEXPAND|wxALL, 4)
- buttons.Add( (20, 20), 0, wxEXPAND, 0)
- self.button_save = wxButton(self, ID_PROJ_SAVE,_("Update"))
- EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave)
- buttons.Add(self.button_save, 0, wxEXPAND|wxALL|wxALIGN_BOTTOM, 4)
+ buttons = wx.BoxSizer(wx.VERTICAL)
+ sizer_edit.Add(buttons, 0, wx.ALL)
+ self.button_new = wx.Button(self, ID_PROJ_NEW, _("New"))
+ self.Bind(wx.EVT_BUTTON, self._OnNew, id=ID_PROJ_NEW)
+ buttons.Add(self.button_new, 0, wx.EXPAND|wx.ALL, 4)
+ self.button_add = wx.Button(self, ID_PROJ_ADDTOLIST, _("Add to List"))
+ self.Bind(wx.EVT_BUTTON, self._OnAddToList, id=ID_PROJ_ADDTOLIST)
+ buttons.Add(self.button_add, 0, wx.EXPAND|wx.ALL, 4)
+ buttons.Add( (20, 20), 0, wx.EXPAND, 0)
+ self.button_save = wx.Button(self, ID_PROJ_SAVE,_("Update"))
+ self.Bind(wx.EVT_BUTTON, self._OnSave, id=ID_PROJ_SAVE)
+ buttons.Add(self.button_save, 0, wx.EXPAND|wx.ALL|wx.ALIGN_BOTTOM, 4)
#
# Main Action buttons (Try/Revert/OK/Close)
#
- buttons = wxBoxSizer(wxHORIZONTAL)
- top_box.Add(buttons, 0, wxALL|wxALIGN_RIGHT, 10)
- self.button_try = wxButton(self, wxID_APPLY, _("Try"))
- EVT_BUTTON(self, wxID_APPLY, self.OnApply)
- buttons.Add(self.button_try, 0, wxRIGHT, 10)
- self.button_revert = wxButton(self, ID_PROJ_REVERT, _("Revert"))
- EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert)
- buttons.Add(self.button_revert, 0, wxRIGHT, 10)
- self.button_ok = wxButton(self, wxID_OK, _("OK"))
- EVT_BUTTON(self, wxID_OK, self.OnOK)
+ buttons = wx.BoxSizer(wx.HORIZONTAL)
+ top_box.Add(buttons, 0, wx.ALL|wx.ALIGN_RIGHT, 10)
+ self.button_try = wx.Button(self, wx.ID_APPLY, _("Try"))
+ self.Bind(wx.EVT_BUTTON, self.OnApply, id=wx.ID_APPLY)
+ buttons.Add(self.button_try, 0, wx.RIGHT, 10)
+ self.button_revert = wx.Button(self, ID_PROJ_REVERT, _("Revert"))
+ self.Bind(wx.EVT_BUTTON, self._OnRevert, id=ID_PROJ_REVERT)
+ buttons.Add(self.button_revert, 0, wx.RIGHT, 10)
+ self.button_ok = wx.Button(self, wx.ID_OK, _("OK"))
+ self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
self.button_ok.SetDefault()
- buttons.Add(self.button_ok, 0, wxRIGHT, 10)
- self.button_close = wxButton(self, wxID_CANCEL, _("Close"))
- EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
- buttons.Add(self.button_close, 0, wxRIGHT, 10)
+ buttons.Add(self.button_ok, 0, wx.RIGHT, 10)
+ self.button_close = wx.Button(self, wx.ID_CANCEL, _("Close"))
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
+ buttons.Add(self.button_close, 0, wx.RIGHT, 10)
#
@@ -303,10 +303,10 @@
add them to the user ProjFile object and write the user file
back to disk.
"""
- dlg = wxFileDialog(self, _("Import"),
- self.parent.application.Path("projection"), style = wxOPEN)
+ dlg = wx.FileDialog(self, _("Import"),
+ self.parent.application.Path("projection"), style = wx.OPEN)
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
ThubanBeginBusyCursor()
@@ -334,11 +334,11 @@
sel = self.projection_list.selected_projections()
assert len(sel) != 0, "button should be disabled"
- dlg = wxFileDialog(self, _("Export"),
+ dlg = wx.FileDialog(self, _("Export"),
self.parent.application.Path("projection"),
- style=wxSAVE|wxOVERWRITE_PROMPT)
+ style=wx.SAVE|wx.OVERWRITE_PROMPT)
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
proj_file = ProjFile(dlg.GetPath())
for proj, pf in sel:
if proj is not None:
@@ -385,10 +385,10 @@
self.__VerifyButtons()
def __ShowError(self, filename, errstr):
- wxMessageDialog(self,
+ wx.MessageDialog(self,
_("The following error occured:\n") +
filename + "\n" + errstr,
- _("Error"), wxOK | wxICON_ERROR).ShowModal()
+ _("Error"), wx.OK | wx.ICON_ERROR).ShowModal()
def __VerifyButtons(self):
"""Update button sensitivity"""
@@ -638,13 +638,13 @@
-class ProjPanel(wxPanel):
+class ProjPanel(wx.Panel):
"""Base class for all projection panels."""
def __init__(self, parent):
- wxPanel.__init__(self, parent, -1)
+ wx.Panel.__init__(self, parent, -1)
- self.__ellps = wxChoice(self, -1)
+ self.__ellps = wx.Choice(self, -1)
self.ellpsData = [("", _("<Unknown>")),
("airy" , _("Airy")),
("bessel", _("Bessel 1841")),
@@ -658,20 +658,20 @@
self.__ellps.Append(name, tag)
self.__ellps.SetSelection(0)
-
+
def _DoLayout(self, childPanel = None):
- panelSizer = wxBoxSizer(wxVERTICAL)
+ panelSizer = wx.BoxSizer(wx.VERTICAL)
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0,
- wxALL|wxALIGN_CENTER_VERTICAL, 4)
- sizer.Add(self.__ellps, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4)
- panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(wx.StaticText(self, -1, _("Ellipsoid:")), 0,
+ wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ sizer.Add(self.__ellps, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ panelSizer.Add(sizer, 0, wx.ALL|wx.EXPAND, 4)
if childPanel is not None:
- panelSizer.Add(childPanel, 0, wxEXPAND, 0)
-
+ panelSizer.Add(childPanel, 0, wx.EXPAND, 0)
+
self.SetAutoLayout(1)
self.SetSizer(panelSizer)
panelSizer.Fit(self)
@@ -718,14 +718,14 @@
"display a configuration panel.\n\n"
"The unidentified set of parameters is:\n\n")
- self.__textbox = wxTextCtrl(self, -1, self.__text, size=(100,200),
- style=wxTE_READONLY|wxTE_MULTILINE|wxTE_LINEWRAP)
+ self.__textbox = wx.TextCtrl(self, -1, self.__text, size=(100,200),
+ style=wx.TE_READONLY|wx.TE_MULTILINE|wx.TE_LINEWRAP)
self._DoLayout()
def _DoLayout(self):
- sizer = wxBoxSizer(wxVERTICAL)
+ sizer = wx.BoxSizer(wx.VERTICAL)
- sizer.Add(self.__textbox, 0, wxALL|wxEXPAND, 4)
+ sizer.Add(self.__textbox, 0, wx.ALL|wx.EXPAND, 4)
ProjPanel._DoLayout(self, sizer)
@@ -748,27 +748,27 @@
def __init__(self, parent, receiver):
ProjPanel.__init__(self, parent)
- self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT)
- self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG)
- self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST)
- self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH)
- self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE)
+ self.__latitude = wx.TextCtrl(self, ID_TMPANEL_LAT)
+ self.__longitude = wx.TextCtrl(self, ID_TMPANEL_LONG)
+ self.__falseEast = wx.TextCtrl(self, ID_TMPANEL_FASLE_EAST)
+ self.__falseNorth = wx.TextCtrl(self, ID_TMPANEL_FALSE_NORTH)
+ self.__scale = wx.TextCtrl(self, ID_TMPANEL_SCALE)
self._DoLayout()
def _DoLayout(self):
- sizer = wxFlexGridSizer(4, 2, 0, 0)
- sizer.Add(wxStaticText(self, -1, _("Latitude:")), 0, wxALL, 4)
- sizer.Add(self.__latitude, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("Longitude:")), 0, wxALL, 4)
- sizer.Add(self.__longitude, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("False Easting:")), 0, wxALL, 4)
- sizer.Add(self.__falseEast, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("False Northing:")), 0, wxALL, 4)
- sizer.Add(self.__falseNorth, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("Scale Factor:")), 0, wxALL, 4)
- sizer.Add(self.__scale, 0, wxALL, 4)
+ sizer = wx.FlexGridSizer(4, 2, 0, 0)
+ sizer.Add(wx.StaticText(self, -1, _("Latitude:")), 0, wx.ALL, 4)
+ sizer.Add(self.__latitude, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Longitude:")), 0, wx.ALL, 4)
+ sizer.Add(self.__longitude, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("False Easting:")), 0, wx.ALL, 4)
+ sizer.Add(self.__falseEast, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("False Northing:")), 0, wx.ALL, 4)
+ sizer.Add(self.__falseNorth, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Scale Factor:")), 0, wx.ALL, 4)
+ sizer.Add(self.__scale, 0, wx.ALL, 4)
ProjPanel._DoLayout(self, sizer)
@@ -817,24 +817,24 @@
self.receiver = receiver
- self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)
- self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose"))
- self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH,
+ self.__zone = wx.SpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)
+ self.__propButton = wx.Button(self, ID_UTMPANEL_PROP, _("Propose"))
+ self.__south = wx.CheckBox(self, ID_UTMPANEL_SOUTH,
_("Southern Hemisphere"))
self._DoLayout()
- EVT_BUTTON(self, ID_UTMPANEL_PROP, self._OnPropose)
+ self.Bind(wx.EVT_BUTTON, self._OnPropose, id=ID_UTMPANEL_PROP)
def _DoLayout(self):
- sizer = wxBoxSizer(wxVERTICAL)
- psizer = wxBoxSizer(wxHORIZONTAL)
- psizer.Add(wxStaticText(self, -1, _("Zone:")), 0, wxALL, 4)
- psizer.Add(self.__zone, 0, wxALL, 4)
- psizer.Add(self.__propButton, 0, wxALL, 4)
- sizer.Add(psizer, 0, wxALL, 4)
- sizer.Add(self.__south, 0, wxALL, 4)
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ psizer = wx.BoxSizer(wx.HORIZONTAL)
+ psizer.Add(wx.StaticText(self, -1, _("Zone:")), 0, wx.ALL, 4)
+ psizer.Add(self.__zone, 0, wx.ALL, 4)
+ psizer.Add(self.__propButton, 0, wx.ALL, 4)
+ sizer.Add(psizer, 0, wx.ALL, 4)
+ sizer.Add(self.__south, 0, wx.ALL, 4)
ProjPanel._DoLayout(self, sizer)
@@ -866,57 +866,57 @@
"""
bb = self.receiver.BoundingBox()
if bb is None:
- dlg = wxMessageDialog(self,
+ dlg = wx.MessageDialog(self,
_("Can not propose: No bounding box found."),
_("Projection: Propose UTM Zone"),
- wxOK | wxICON_INFORMATION)
+ wx.OK | wx.ICON_INFORMATION)
dlg.CenterOnParent()
result = dlg.ShowModal()
dlg.Destroy()
return
dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox())
- if dlg.ShowModal() == wxID_OK:
+ if dlg.ShowModal() == wx.ID_OK:
self.__zone.SetValue(dlg.GetProposedZone())
-class LCCPanel(ProjPanel):
+class LCCPanel(ProjPanel):
"""Projection Panel for Lambert Conic Conformal."""
def __init__(self, parent, receiver):
ProjPanel.__init__(self, parent)
-
- self.__fspLatitude = wxTextCtrl(self, -1)
- self.__sspLatitude = wxTextCtrl(self, -1)
- self.__meridian = wxTextCtrl(self, -1)
- self.__originLat = wxTextCtrl(self, -1)
- self.__falseEast = wxTextCtrl(self, -1)
- self.__falseNorth = wxTextCtrl(self, -1)
+ self.__fspLatitude = wx.TextCtrl(self, -1)
+ self.__sspLatitude = wx.TextCtrl(self, -1)
+ self.__meridian = wx.TextCtrl(self, -1)
+ self.__originLat = wx.TextCtrl(self, -1)
+ self.__falseEast = wx.TextCtrl(self, -1)
+ self.__falseNorth = wx.TextCtrl(self, -1)
+
self._DoLayout()
def _DoLayout(self):
- sizer = wxFlexGridSizer(6, 2, 0, 0)
- sizer.Add(wxStaticText(self, -1,
+ sizer = wx.FlexGridSizer(6, 2, 0, 0)
+ sizer.Add(wx.StaticText(self, -1,
_("Latitude of first standard parallel:")))
- sizer.Add(self.__fspLatitude, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1,
+ sizer.Add(self.__fspLatitude, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1,
_("Latitude of second standard parallel:")))
- sizer.Add(self.__sspLatitude, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("Central Meridian:")))
- sizer.Add(self.__meridian, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("Latitude of origin:")))
- sizer.Add(self.__originLat, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("False Easting:")))
- sizer.Add(self.__falseEast, 0, wxALL, 4)
- sizer.Add(wxStaticText(self, -1, _("False Northing:")))
- sizer.Add(self.__falseNorth, 0, wxALL, 4)
+ sizer.Add(self.__sspLatitude, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Central Meridian:")))
+ sizer.Add(self.__meridian, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Latitude of origin:")))
+ sizer.Add(self.__originLat, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("False Easting:")))
+ sizer.Add(self.__falseEast, 0, wx.ALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("False Northing:")))
+ sizer.Add(self.__falseNorth, 0, wx.ALL, 4)
ProjPanel._DoLayout(self, sizer)
def GetProjName(self):
return _("Lambert Conic Conformal")
-
+
def SetProjection(self, proj):
self.__fspLatitude.SetValue(proj.GetParameter("lat_1"))
self.__sspLatitude.SetValue(proj.GetParameter("lat_2"))
@@ -928,7 +928,7 @@
ProjPanel.SetProjection(self, proj)
def GetParameters(self):
- params = ["proj=lcc",
+ params = ["proj=lcc",
"lat_1=" + self.__fspLatitude.GetValue(),
"lat_2=" + self.__sspLatitude.GetValue(),
"lat_0=" + self.__originLat.GetValue(),
@@ -949,7 +949,7 @@
ProjPanel.Clear(self)
-class GeoPanel(ProjPanel):
+class GeoPanel(ProjPanel):
"""Projection Panel for a Geographic Projection."""
def __init__(self, parent, receiver):
@@ -958,7 +958,7 @@
self.__choices = [(_("Degrees"), "0.017453"),
(_("Radians"), "1")]
- self.__scale = wxChoice(self, -1)
+ self.__scale = wx.Choice(self, -1)
for choice, value in self.__choices:
self.__scale.Append(choice, value)
@@ -966,7 +966,7 @@
def GetProjName(self):
return _("Geographic")
-
+
def SetProjection(self, proj):
value = proj.GetParameter("to_meter")
for i in range(len(self.__choices)):
@@ -976,7 +976,7 @@
ProjPanel.SetProjection(self, proj)
def GetParameters(self):
- params = ["proj=latlong",
+ params = ["proj=latlong",
"to_meter=%s" % self.__scale.GetClientData(
self.__scale.GetSelection())]
@@ -987,11 +987,11 @@
ProjPanel.Clear(self)
def _DoLayout(self):
- sizer = wxBoxSizer(wxHORIZONTAL)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
- sizer.Add(wxStaticText(self, -1, _("Source Data is in: ")),
- 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
- sizer.Add(self.__scale, 1, wxEXPAND|wxALL, 4)
+ sizer.Add(wx.StaticText(self, -1, _("Source Data is in: ")),
+ 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
+ sizer.Add(self.__scale, 1, wx.EXPAND|wx.ALL, 4)
self.__scale.SetSelection(0)
@@ -1000,13 +1000,13 @@
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002
-class UTMProposeZoneDialog(wxDialog):
+class UTMProposeZoneDialog(wx.Dialog):
"""Propose a sensible Zone considering the current map extent."""
def __init__(self, parent, (x, y, x2, y2)):
- wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"),
- wxDefaultPosition, wxSize(200, 100))
+ wx.Dialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"),
+ wx.DefaultPosition, wx.Size(200, 100))
self.parent = parent
x = x + 180
x2 = x2 + 180
@@ -1015,25 +1015,25 @@
self.dialogLayout()
def dialogLayout(self):
- topBox = wxBoxSizer(wxVERTICAL)
+ topBox = wx.BoxSizer(wx.VERTICAL)
- textBox = wxBoxSizer(wxVERTICAL)
- textBox.Add(wxStaticText(self, -1, _("The current map extent center "
+ textBox = wx.BoxSizer(wx.VERTICAL)
+ textBox.Add(wx.StaticText(self, -1, _("The current map extent center "
"lies in UTM Zone")),
- 0, wxALIGN_CENTER|wxALL, 4)
- textBox.Add(wxStaticText(self, -1, str(self.proposedZone)),
- 0, wxALIGN_CENTER|wxALL, 4)
+ 0, wx.ALIGN_CENTER|wx.ALL, 4)
+ textBox.Add(wx.StaticText(self, -1, str(self.proposedZone)),
+ 0, wx.ALIGN_CENTER|wx.ALL, 4)
- topBox.Add(textBox, 1, wxEXPAND|wxALL, 4)
+ topBox.Add(textBox, 1, wx.EXPAND|wx.ALL, 4)
- buttonBox = wxBoxSizer(wxHORIZONTAL)
- buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE,
- _("Take")), 0, wxALL, 4)
- buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL,
- _("Cancel")), 0, wxALL, 4)
- topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
- EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake)
- EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel)
+ buttonBox = wx.BoxSizer(wx.HORIZONTAL)
+ buttonBox.Add(wx.Button(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE,
+ _("Take")), 0, wx.ALL, 4)
+ buttonBox.Add(wx.Button(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL,
+ _("Cancel")), 0, wx.ALL, 4)
+ topBox.Add(buttonBox, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10)
+ self.Bind(wx.EVT_BUTTON, self.OnTake, id=ID_UTM_PROPOSE_ZONE_DIALOG_TAKE)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, id=ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL)
self.SetAutoLayout(True)
self.SetSizer(topBox)
@@ -1041,10 +1041,10 @@
topBox.SetSizeHints(self)
def OnTake(self, event):
- self.EndModal(wxID_OK)
+ self.EndModal(wx.ID_OK)
def OnCancel(self, event):
- self.EndModal(wxID_CANCEL)
+ self.EndModal(wx.ID_CANCEL)
def GetProposedZone(self):
return self.proposedZone
Modified: trunk/thuban/Thuban/UI/projlist.py
===================================================================
--- trunk/thuban/Thuban/UI/projlist.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/projlist.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -11,7 +11,7 @@
# $Source$
# $Id$
-from wxPython.wx import *
+import wx
from Thuban import _
@@ -24,7 +24,7 @@
PROJ_SELECTION_CHANGED = "PROJ_SELECTION_CHANGED"
-class ProjectionList(wxListCtrl, Publisher):
+class ProjectionList(wx.ListCtrl, Publisher):
"""A ListCtrl that shows a list of projections
@@ -46,7 +46,7 @@
proj_files -- a sequence of ProjFile objects
orig_proj -- The projection originally selected in the map/layer
"""
- wxListCtrl.__init__(self, parent, ID, style=wxLC_REPORT|wxLC_VIRTUAL)
+ wx.ListCtrl.__init__(self, parent, ID, style=wx.LC_REPORT|wx.LC_VIRTUAL)
self.InsertColumn(0, _("Available Projections"))
self.proj_files = proj_files
@@ -56,14 +56,14 @@
self.proj_map = {}
self.needs_update = False
self.update_projections()
- EVT_SIZE(self, self.OnSize)
- EVT_LEFT_UP(self, self.mouse_left_up)
- EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.item_selected)
- EVT_LIST_ITEM_DESELECTED(self, self.GetId(), self.item_deselected)
- EVT_IDLE(self, self.OnIdle)
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+ self.Bind(wx.EVT_LEFT_UP, self.mouse_left_up)
+ self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.item_selected, id=self.GetId())
+ self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.item_deselected, id=self.GetId())
+ self.Bind(wx.EVT_IDLE, self.OnIdle)
def __del__(self):
- wxListCtrl.__del__()
+ wx.ListCtrl.__del__()
Publisher.__del__()
def _subscribe_proj_files(self):
@@ -87,7 +87,7 @@
# an instance of ProjectionList anymore as wxPython replaces
# self.__class__ with its dead object class
Publisher.Destroy(self)
- wxListCtrl.Destroy(self)
+ wx.ListCtrl.Destroy(self)
def update_on_idle(self):
self.needs_update = True
@@ -126,7 +126,7 @@
# selected with indices higher than the new count.
if len(self.projections) < old_length:
for i in xrange(len(self.projections), old_length):
- self.SetItemState(i, 0, wxLIST_STATE_SELECTED)
+ self.SetItemState(i, 0, wx.LIST_STATE_SELECTED)
self.SetItemCount(len(self.projections))
@@ -136,11 +136,11 @@
for i in xrange(len(self.projections)):
p = self.projections[i][1]
if get(id(p)):
- state = wxLIST_STATE_SELECTED
+ state = wx.LIST_STATE_SELECTED
count += 1
else:
state = 0
- self.SetItemState(i, state, wxLIST_STATE_SELECTED)
+ self.SetItemState(i, state, wx.LIST_STATE_SELECTED)
# If the selection changed send a PROJ_SELECTION_CHANGED message
if count != len(selection):
@@ -178,7 +178,7 @@
# wxLIST_STATE_SELECTED is set, some other item is focused and
# the first time the focus is moved with the keyboard the
# selection moves in unexpected ways.
- state = wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED
+ state = wx.LIST_STATE_SELECTED|wx.LIST_STATE_FOCUSED
for i in range(len(self.projections)):
p = self.projections[i][1]
self.SetItemState(i, p is proj and state or 0, state)
@@ -186,7 +186,7 @@
def ClearSelection(self):
"""Deselect all projections."""
for i in range(len(self.projections)):
- self.SetItemState(i, 0, wxLIST_STATE_SELECTED)
+ self.SetItemState(i, 0, wx.LIST_STATE_SELECTED)
def SetProjFiles(self, proj_files):
"""Set the projfile objects whose projections are shown in the list"""
@@ -217,7 +217,7 @@
"""
return [self.projections[i][1:]
for i in range(len(self.projections))
- if self.GetItemState(i, wxLIST_STATE_SELECTED)]
+ if self.GetItemState(i, wx.LIST_STATE_SELECTED)]
def _issue_proj_selection_changed(self):
"""Internal: Issue a PROJ_SELECTION_CHANGED message"""
Modified: trunk/thuban/Thuban/UI/rasterlayerproperties.py
===================================================================
--- trunk/thuban/Thuban/UI/rasterlayerproperties.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/rasterlayerproperties.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -11,7 +11,7 @@
# $Source$
# $Id$
-from wxPython.wx import *
+import wx
from Thuban import _
from Thuban.UI.layerproperties import LayerProperties
@@ -37,12 +37,12 @@
if info is None:
panelBox.Add(
- wxStaticText(panel, -1,
+ wx.StaticText(panel, -1,
_("GDAL image information unavailable. See About box for details.")),
- 0, wxALIGN_LEFT | wxALL, 4)
+ 0, wx.ALIGN_LEFT | wx.ALL, 4)
return
-
+
# Bounding Box
bbox = self.layer.LatLongBoundingBox()
if bbox is None:
@@ -50,77 +50,77 @@
else:
text = _("Extent (lat-lon): (%g, %g, %g, %g)") % tuple(bbox)
- panelBox.Add(wxStaticText(panel, -1, text), 0, wxALIGN_LEFT|wxALL, 4)
+ panelBox.Add(wx.StaticText(panel, -1, text), 0, wx.ALIGN_LEFT|wx.ALL, 4)
- rasterBox = wxStaticBoxSizer(wxStaticBox(panel, -1,
- _("Image Properties")), wxVERTICAL)
+ rasterBox = wx.StaticBoxSizer(wx.StaticBox(panel, -1,
+ _("Image Properties")), wx.VERTICAL)
rasterBox.Add(
- wxStaticText(panel, -1,
+ wx.StaticText(panel, -1,
_("Source: %s") % self.layer.GetImageFilename()),
- 0, wxALIGN_LEFT | wxALL, 4)
+ 0, wx.ALIGN_LEFT | wx.ALL, 4)
- infoBox = wxBoxSizer(wxHORIZONTAL)
+ infoBox = wx.BoxSizer(wx.HORIZONTAL)
nBands = info["nBands"]
self.usePalIndex = nBands == 1
-
+
infoBox.Add(
- wxStaticText(panel, -1, _("Driver: %s") % info["Driver"]),
- 0, wxALIGN_LEFT | wxRIGHT, 10)
+ wx.StaticText(panel, -1, _("Driver: %s") % info["Driver"]),
+ 0, wx.ALIGN_LEFT | wx.RIGHT, 10)
infoBox.Add(
- wxStaticText(panel, -1, _("Size: %ix%i") % info["Size"]),
- 0, wxALIGN_LEFT | wxRIGHT, 10)
+ wx.StaticText(panel, -1, _("Size: %ix%i") % info["Size"]),
+ 0, wx.ALIGN_LEFT | wx.RIGHT, 10)
infoBox.Add(
- wxStaticText(panel, -1, _("Number of Bands: %i") % nBands),
- 0, wxALIGN_LEFT | wxRIGHT, 0)
+ wx.StaticText(panel, -1, _("Number of Bands: %i") % nBands),
+ 0, wx.ALIGN_LEFT | wx.RIGHT, 0)
- rasterBox.Add(infoBox, 0, wxALIGN_LEFT|wxALL, 4)
+ rasterBox.Add(infoBox, 0, wx.ALIGN_LEFT|wx.ALL, 4)
# Mask
- maskBox = wxBoxSizer(wxHORIZONTAL)
+ maskBox = wx.BoxSizer(wx.HORIZONTAL)
if versions['wxPython-tuple'] < (2,5,3):
- choices = ["None", "Bitmap",
+ choices = ["None", "Bitmap",
"Alpha (Not support by wxPython %s)" % \
versions['wxPython']]
else:
choices = ["None", "Bitmap", "Alpha"]
- self.maskRadioBox = wxRadioBox(panel, ID_RB_MASK, _("Mask Type"),
+ self.maskRadioBox = wx.RadioBox(panel, ID_RB_MASK, _("Mask Type"),
choices=choices)
#self.maskCB = wxCheckBox(panel, -1, _("Use Mask"))
- maskBox.Add(self.maskRadioBox, 0, wxRIGHT, 10)
+ maskBox.Add(self.maskRadioBox, 0, wx.RIGHT, 10)
- self.opBox = wxBoxSizer(wxHORIZONTAL)
- self.opSpinLabel = wxStaticText(panel, -1, _("Opacity:"))
- self.opBox.Add(self.opSpinLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 4)
- self.opSpin = wxSpinCtrl(panel, -1,
+ self.opBox = wx.BoxSizer(wx.HORIZONTAL)
+ self.opSpinLabel = wx.StaticText(panel, -1, _("Opacity:"))
+ self.opBox.Add(self.opSpinLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 4)
+ self.opSpin = wx.SpinCtrl(panel, -1,
str(self.layer.Opacity()*255),
initial = self.layer.Opacity()*255,
min=0, max=255)
- self.opBox.Add(self.opSpin, 0, wxALL, 4)
- maskBox.Add(self.opBox, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
+ self.opBox.Add(self.opSpin, 0, wx.ALL, 4)
+ maskBox.Add(self.opBox, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
- rasterBox.Add(maskBox, 0, wxALL, 4)
+ rasterBox.Add(maskBox, 0, wx.ALL, 4)
#rasterBox.Add(opBox, 0, wxALL, 4)
- panelBox.Add(rasterBox, 1, wxGROW | wxALL, 4)
+ panelBox.Add(rasterBox, 1, wx.GROW | wx.ALL, 4)
self.maskRadioBox.SetSelection(self.old_state["mask_type"])
self.OnMaskSelect(None)
- EVT_RADIOBOX(self, ID_RB_MASK, self.OnMaskSelect)
+ self.Bind(wx.EVT_RADIOBOX, self.OnMaskSelect, id=ID_RB_MASK)
def OnTry(self, event):
self.set_state()
def OnOK(self, event):
- if self.set_state():
+ if self.set_state():
self.Close()
def OnRevert(self, event):
Modified: trunk/thuban/Thuban/UI/renderer.py
===================================================================
--- trunk/thuban/Thuban/UI/renderer.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/renderer.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -22,12 +22,7 @@
from Thuban import _
-from wxPython.wx import wxPoint, wxRect, wxPen, wxBrush, wxFont, \
- wxTRANSPARENT_PEN, wxTRANSPARENT_BRUSH, \
- wxBLACK_PEN, wxBLACK, wxSOLID, wxCROSS_HATCH, wxSWISS, wxNORMAL, \
- wxBitmapFromImage, wxImageFromStream, wxBITMAP_TYPE_BMP, \
- wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_TIF, \
- wxBITMAP_TYPE_GIF, wxEmptyImage, wxMask, wxBitmapFromBits
+import wx
from wxproj import draw_polygon_shape, draw_polygon_init
@@ -56,35 +51,35 @@
# Map the strings used for the format parameter of the draw_raster_data
# method to the appropriate wxWindows constants
raster_format_map = {
- "BMP": wxBITMAP_TYPE_BMP,
- "JPEG": wxBITMAP_TYPE_JPEG,
- "PNG": wxBITMAP_TYPE_PNG,
- "TIFF": wxBITMAP_TYPE_TIF,
- "GIF": wxBITMAP_TYPE_GIF,
+ "BMP": wx.BITMAP_TYPE_BMP,
+ "JPEG": wx.BITMAP_TYPE_JPEG,
+ "PNG": wx.BITMAP_TYPE_PNG,
+ "TIFF": wx.BITMAP_TYPE_TIF,
+ "GIF": wx.BITMAP_TYPE_GIF,
}
class MapRenderer(BaseRenderer):
"""Class to render a map onto a wxDC"""
- TRANSPARENT_PEN = wxTRANSPARENT_PEN
- TRANSPARENT_BRUSH = wxTRANSPARENT_BRUSH
+ TRANSPARENT_PEN = wx.TRANSPARENT_PEN
+ TRANSPARENT_BRUSH = wx.TRANSPARENT_BRUSH
def make_point(self, x, y):
- return wxPoint(int(round(x)), int(round(y)))
+ return wx.Point(int(round(x)), int(round(y)))
def tools_for_property(self, prop):
fill = prop.GetFill()
if fill is Transparent:
brush = self.TRANSPARENT_BRUSH
else:
- brush = wxBrush(Color2wxColour(fill), wxSOLID)
+ brush = wx.Brush(Color2wxColour(fill), wx.SOLID)
stroke = prop.GetLineColor()
if stroke is Transparent:
pen = self.TRANSPARENT_PEN
else:
- pen = wxPen(Color2wxColour(stroke), prop.GetLineWidth(), wxSOLID)
+ pen = wx.Pen(Color2wxColour(stroke), prop.GetLineWidth(), wx.SOLID)
return pen, brush
def low_level_renderer(self, layer):
@@ -112,8 +107,8 @@
return BaseRenderer.low_level_renderer(self, layer)
def label_font(self):
- return wxFont(int(round(self.resolution * 10)), wxSWISS, wxNORMAL,
- wxNORMAL)
+ return wx.Font(int(round(self.resolution * 10)), wx.SWISS, wx.NORMAL,
+ wx.NORMAL)
def projected_raster_layer(self, layer, srcProj, dstProj, extents,
resolution, dimensions, options):
@@ -132,9 +127,9 @@
options = options & ~2 # ALPHA_MASK not supported
try:
- ret = ProjectRasterFile(layer.GetImageFilename(),
+ ret = ProjectRasterFile(layer.GetImageFilename(),
srcProj, dstProj,
- extents, resolution, dimensions,
+ extents, resolution, dimensions,
options)
except (MemoryError, IOError, AttributeError, ValueError):
# Why does this catch AttributeError and ValueError?
@@ -156,26 +151,26 @@
alpha_data = None
if format == 'RAW':
- image = wxEmptyImage(width, height)
+ image = wx.EmptyImage(width, height)
image.SetData(image_data)
if mask_data is not None:
- mask = wxBitmapFromBits(mask_data, width, height, 1)
- mask = wxMask(mask)
+ mask = wx.BitmapFromBits(mask_data, width, height, 1)
+ mask = wx.Mask(mask)
elif alpha_data is not None:
# alpha_data is already in the right format
alpha = alpha_data
else:
stream = cStringIO.StringIO(image_data)
- image = wxImageFromStream(stream, raster_format_map[format])
+ image = wx.ImageFromStream(stream, raster_format_map[format])
if mask_data is not None:
stream = cStringIO.StringIO(mask_data)
- mask = wxImageFromStream(stream, raster_format_map[format])
- mask = wxMask(wxBitmapFromImage(mask, 1))
+ mask = wx.ImageFromStream(stream, raster_format_map[format])
+ mask = wx.Mask(wx.BitmapFromImage(mask, 1))
elif alpha_data is not None:
stream = cStringIO.StringIO(alpha_data)
- alpha = wxImageFromStream(stream, raster_format_map[format])
+ alpha = wx.ImageFromStream(stream, raster_format_map[format])
alpha = alpha.GetData() #[:] # XXX: do we need to copy this?
elif image.HasAlpha():
alpha = image.GetAlphaData()
@@ -196,7 +191,7 @@
image.SetAlphaData(a)
- bitmap = wxBitmapFromImage(image)
+ bitmap = wx.BitmapFromImage(image)
if mask is not None:
bitmap.SetMask(mask)
@@ -242,8 +237,8 @@
selected_shapes -- a list of the shape-ids representing the
selected shapes for the given layer.
"""
- pen = wxPen(wxBLACK, 3, wxSOLID)
- brush = wxBrush(wxBLACK, wxCROSS_HATCH)
+ pen = wx.Pen(wx.BLACK, 3, wx.SOLID)
+ brush = wx.Brush(wx.BLACK, wx.CROSS_HATCH)
shapetype = layer.ShapeType()
useraw, func, param = self.low_level_renderer(layer)
@@ -384,7 +379,7 @@
self.dc.DestroyClippingRegion()
# Force the font for Legend drawing
- font = wxFont(self.resolution * 10, wxSWISS, wxNORMAL, wxNORMAL)
+ font = wx.Font(self.resolution * 10, wx.SWISS, wx.NORMAL, wx.NORMAL)
self.dc.SetFont(font)
self.render_frame()
@@ -396,8 +391,8 @@
"""Render the frames for map and legend/scalebar."""
dc = self.dc
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxTRANSPARENT_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
# Dimension stuff
width, height = dc.GetSizeTuple()
@@ -422,8 +417,8 @@
previewer = ClassDataPreviewer()
dc = self.dc
- dc.SetPen(wxBLACK_PEN)
- dc.SetBrush(wxTRANSPARENT_BRUSH)
+ dc.SetPen(wx.BLACK_PEN)
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
# Dimension stuff
width, height = dc.GetSizeTuple()
@@ -438,7 +433,7 @@
posy = mminy + 5 # 5 pix inside legend frame
# Render the legend
- dc.SetTextForeground(wxBLACK)
+ dc.SetTextForeground(wx.BLACK)
if self.map.HasLayers():
layers = self.map.Layers()[:]
layers.reverse()
@@ -454,7 +449,7 @@
for g in clazz:
if g.IsVisible():
previewer.Draw(dc,
- wxRect(posx+dx, posy,
+ wx.Rect(posx+dx, posy,
iconwidth, iconheight),
g.GetProperties(), shapeType)
dc.DrawText(g.GetDisplayText(),
Modified: trunk/thuban/Thuban/UI/resource.py
===================================================================
--- trunk/thuban/Thuban/UI/resource.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/resource.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -15,18 +15,18 @@
import os
import Thuban
-from wxPython.wx import wxBITMAP_TYPE_XPM, wxBITMAP_TYPE_ANY, wxBitmap, wxImage
+import wx
bitmapdir = os.path.join(Thuban.__path__[0], os.pardir, "Resources", "Bitmaps")
-bitmap_extensions = {wxBITMAP_TYPE_XPM: ".xpm",
- wxBITMAP_TYPE_ANY: ""}
+bitmap_extensions = {wx.BITMAP_TYPE_XPM: ".xpm",
+ wx.BITMAP_TYPE_ANY: ""}
def GetBitmapResource(file, type):
filename = os.path.join(bitmapdir, file) + bitmap_extensions[type]
- return wxBitmap(filename, type)
+ return wx.Bitmap(filename, type)
def GetImageResource(file, type):
filename = os.path.join(bitmapdir, file) + bitmap_extensions[type]
- return wxImage(filename, type)
+ return wx.Image(filename, type)
Modified: trunk/thuban/Thuban/UI/scalebar.py
===================================================================
--- trunk/thuban/Thuban/UI/scalebar.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/scalebar.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -11,7 +11,7 @@
from Thuban.Model.scalebar import deriveInterval, roundInterval
from Thuban.Model.proj import PROJ_UNITS_METERS
-from wxPython.wx import *
+import wx
class ScaleBar:
@@ -28,10 +28,10 @@
and scale > 0.0:
# We have a projection, draw the scalebar in bw
- BlackPen = wxBLACK_PEN
- BlackBrush = wxBLACK_BRUSH
- BlackText = wxBLACK
-
+ BlackPen = wx.BLACK_PEN
+ BlackBrush = wx.BLACK_BRUSH
+ BlackText = wx.BLACK
+
# Get the dimension
width, height = size
posx, posy = position
@@ -42,21 +42,21 @@
interval, unit = deriveInterval(width, scale)
l2width, l2height = dc.GetTextExtent("%d %s"%(interval,unit))
width = width - 4.0 - l1width/2.0 -l2width/2.0
-
+
# Having precised the width now the final interval can be calculated
interval, unit = deriveInterval(width, scale)
interval, label = roundInterval(interval)
-
+
if interval > 0.0:
# We draw 2 rectangles with half the width
if unit == 'km':
width = int(interval*1000.0*scale/2)
else:
width = int(interval*scale/2)
-
+
dc.SetPen(BlackPen)
- brush = wxBrush(wxWHITE, wxSOLID)
+ brush = wx.Brush(wx.WHITE, wx.SOLID)
dc.SetBrush(brush)
dc.DrawRectangle(posx+4,posy+2,width,8)
Modified: trunk/thuban/Thuban/UI/sizers.py
===================================================================
--- trunk/thuban/Thuban/UI/sizers.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/sizers.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -11,15 +11,15 @@
# $Source$
# $Id$
-from wxPython.wx import wxPySizer, wxSize
+import wx
-class NotebookLikeSizer(wxPySizer):
+class NotebookLikeSizer(wx.PySizer):
"""Similar to a wxNotebookSizer but doesn't need a real notebook
"""
def __init__(self):
- wxPySizer.__init__(self)
+ wx.PySizer.__init__(self)
self.item_dict = {}
def Add(self, item):
@@ -28,7 +28,7 @@
The children added with Add must must be an object that has
Show() and Hide() methods
"""
- wxPySizer.Add(self, item)
+ wx.PySizer.Add(self, item)
def Activate(self, item):
"""Activate the item.
@@ -68,5 +68,5 @@
widths.append(size.width)
heights.append(size.height)
if widths:
- return wxSize(max(widths), max(heights))
- return wxSize(0, 0)
+ return wx.Size(max(widths), max(heights))
+ return wx.Size(0, 0)
Modified: trunk/thuban/Thuban/UI/tableview.py
===================================================================
--- trunk/thuban/Thuban/UI/tableview.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/tableview.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -11,8 +11,8 @@
from Thuban import _
-from wxPython.wx import *
-from wxPython.grid import *
+import wx
+from wx import grid
from Thuban.Lib.connector import Publisher
from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_DOUBLE, \
@@ -23,20 +23,20 @@
from Thuban.Model.messages import TABLE_REMOVED, MAP_LAYERS_REMOVED
from Thuban.UI.common import ThubanBeginBusyCursor, ThubanEndBusyCursor
-wx_value_type_map = {FIELDTYPE_INT: wxGRID_VALUE_NUMBER,
- FIELDTYPE_DOUBLE: wxGRID_VALUE_FLOAT,
- FIELDTYPE_STRING: wxGRID_VALUE_STRING}
+wx_value_type_map = {FIELDTYPE_INT: grid.GRID_VALUE_NUMBER,
+ FIELDTYPE_DOUBLE: grid.GRID_VALUE_FLOAT,
+ FIELDTYPE_STRING: grid.GRID_VALUE_STRING}
ROW_SELECTED = "ROW_SELECTED"
QUERY_KEY = 'S'
-class DataTable(wxPyGridTableBase):
+class DataTable(grid.PyGridTableBase):
"""Wrapper around a Thuban table object suitable for a wxGrid"""
def __init__(self, table = None):
- wxPyGridTableBase.__init__(self)
+ grid.PyGridTableBase.__init__(self)
self.num_cols = 0
self.num_rows = 0
self.columns = []
@@ -112,7 +112,7 @@
return self.table.RowOrdinalToId(ordinal)
-class NullRenderer(wxPyGridCellRenderer):
+class NullRenderer(grid.PyGridCellRenderer):
"""Renderer that draws NULL as a gray rectangle
@@ -121,15 +121,15 @@
"""
def __init__(self, non_null_renderer):
- wxPyGridCellRenderer.__init__(self)
+ grid.PyGridCellRenderer.__init__(self)
self.non_null_renderer = non_null_renderer
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
value = grid.table.GetValue(row, col)
if value is None:
- dc.SetBackgroundMode(wxSOLID)
- dc.SetBrush(wxBrush(wxColour(192, 192, 192), wxSOLID))
- dc.SetPen(wxTRANSPARENT_PEN)
+ dc.SetBackgroundMode(wx.SOLID)
+ dc.SetBrush(wx.Brush(wx.Colour(192, 192, 192), wx.SOLID))
+ dc.SetPen(wx.TRANSPARENT_PEN)
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)
else:
self.non_null_renderer.Draw(grid, attr, dc, rect, row, col,
@@ -142,7 +142,7 @@
return NullRenderer(self.non_null_renderer)
-class TableGrid(wxGrid, Publisher):
+class TableGrid(grid.Grid, Publisher):
"""A grid view for a Thuban table
@@ -155,7 +155,7 @@
"""
def __init__(self, parent, table = None):
- wxGrid.__init__(self, parent, -1)
+ grid.Grid.__init__(self, parent, -1)
self.allow_messages_count = 0
@@ -178,22 +178,22 @@
# long time.
#self.AutoSizeColumns(False)
- self.SetSelectionMode(wxGrid.wxGridSelectRows)
+ self.SetSelectionMode(grid.Grid.wxGridSelectRows)
self.ToggleEventListeners(True)
- EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect)
- EVT_GRID_SELECT_CELL(self, self.OnSelectCell)
+ self.Bind(grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)
+ self.Bind(grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)
# Replace the normal renderers with our own versions which
# render NULL/None values specially
- self.RegisterDataType(wxGRID_VALUE_STRING,
- NullRenderer(wxGridCellStringRenderer()), None)
- self.RegisterDataType(wxGRID_VALUE_NUMBER,
- NullRenderer(wxGridCellNumberRenderer()), None)
- self.RegisterDataType(wxGRID_VALUE_FLOAT,
- NullRenderer(wxGridCellFloatRenderer()), None)
+ self.RegisterDataType(grid.GRID_VALUE_STRING,
+ NullRenderer(grid.GridCellStringRenderer()), None)
+ self.RegisterDataType(grid.GRID_VALUE_NUMBER,
+ NullRenderer(grid.GridCellNumberRenderer()), None)
+ self.RegisterDataType(grid.GRID_VALUE_FLOAT,
+ NullRenderer(grid.GridCellFloatRenderer()), None)
- EVT_WINDOW_DESTROY(self, self.OnDestroy)
+ self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
def OnDestroy(self, event):
Publisher.Destroy(self)
@@ -306,7 +306,7 @@
def __init__(self, parent, name, title, table):
ThubanFrame.__init__(self, parent, name, title)
- self.panel = wxPanel(self, -1)
+ self.panel = wx.Panel(self, -1)
self.table = table
self.grid = self.make_grid(self.table)
@@ -364,19 +364,19 @@
def __init__(self, parent, name, title, table):
TableFrame.__init__(self, parent, name, title, table)
- self.combo_fields = wxComboBox(self.panel, -1, style=wxCB_READONLY)
- self.choice_comp = wxChoice(self.panel, -1,
+ self.combo_fields = wx.ComboBox(self.panel, -1, style=wx.CB_READONLY)
+ self.choice_comp = wx.Choice(self.panel, -1,
choices=["<", "<=", "==", "!=", ">=", ">"])
- self.combo_value = wxComboBox(self.panel, ID_COMBOVALUE)
- self.choice_action = wxChoice(self.panel, -1,
- choices=[_("Replace Selection"),
- _("Refine Selection"),
+ self.combo_value = wx.ComboBox(self.panel, ID_COMBOVALUE)
+ self.choice_action = wx.Choice(self.panel, -1,
+ choices=[_("Replace Selection"),
+ _("Refine Selection"),
_("Add to Selection")])
- button_query = wxButton(self.panel, ID_QUERY, _("Query"))
- button_export = wxButton(self.panel, ID_EXPORT, _("Export"))
- button_exportSel = wxButton(self.panel, ID_EXPORTSEL, _("Export Selection"))
- button_close = wxButton(self.panel, wxID_CLOSE, _("Close"))
+ button_query = wx.Button(self.panel, ID_QUERY, _("Query"))
+ button_export = wx.Button(self.panel, ID_EXPORT, _("Export"))
+ button_exportSel = wx.Button(self.panel, ID_EXPORTSEL, _("Export Selection"))
+ button_close = wx.Button(self.panel, wx.ID_CLOSE, _("Close"))
self.CreateStatusBar()
@@ -398,35 +398,35 @@
self.UpdateStatusText()
- topBox = wxBoxSizer(wxVERTICAL)
+ topBox = wx.BoxSizer(wx.VERTICAL)
- sizer = wxStaticBoxSizer(wxStaticBox(self.panel, -1,
+ sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, -1,
_("Selection")),
- wxHORIZONTAL)
- sizer.Add(self.combo_fields, 1, wxEXPAND|wxALL, 4)
- sizer.Add(self.choice_comp, 0, wxALL, 4)
- sizer.Add(self.combo_value, 1, wxEXPAND|wxALL, 4)
- sizer.Add(self.choice_action, 0, wxALL, 4)
- sizer.Add(button_query, 0, wxALL | wxALIGN_CENTER_VERTICAL, 4)
- sizer.Add( (40, 20), 0, wxALL, 4)
+ wx.HORIZONTAL)
+ sizer.Add(self.combo_fields, 1, wx.EXPAND|wx.ALL, 4)
+ sizer.Add(self.choice_comp, 0, wx.ALL, 4)
+ sizer.Add(self.combo_value, 1, wx.EXPAND|wx.ALL, 4)
+ sizer.Add(self.choice_action, 0, wx.ALL, 4)
+ sizer.Add(button_query, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4)
+ sizer.Add( (40, 20), 0, wx.ALL, 4)
- topBox.Add(sizer, 0, wxEXPAND|wxALL, 4)
- topBox.Add(self.grid, 1, wxEXPAND|wxALL, 0)
+ topBox.Add(sizer, 0, wx.EXPAND|wx.ALL, 4)
+ topBox.Add(self.grid, 1, wx.EXPAND|wx.ALL, 0)
- sizer = wxBoxSizer(wxHORIZONTAL)
- sizer.Add(button_export, 0, wxALL, 4)
- sizer.Add(button_exportSel, 0, wxALL, 4)
- sizer.Add( (60, 20), 1, wxALL|wxEXPAND, 4)
- sizer.Add(button_close, 0, wxALL|wxALIGN_RIGHT, 4)
- topBox.Add(sizer, 0, wxALL | wxEXPAND, 4)
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ sizer.Add(button_export, 0, wx.ALL, 4)
+ sizer.Add(button_exportSel, 0, wx.ALL, 4)
+ sizer.Add( (60, 20), 1, wx.ALL|wx.EXPAND, 4)
+ sizer.Add(button_close, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
+ topBox.Add(sizer, 0, wx.ALL | wx.EXPAND, 4)
self.panel.SetAutoLayout(True)
self.panel.SetSizer(topBox)
topBox.Fit(self.panel)
topBox.SetSizeHints(self.panel)
- panelSizer = wxBoxSizer(wxVERTICAL)
- panelSizer.Add(self.panel, 1, wxEXPAND, 0)
+ panelSizer = wx.BoxSizer(wx.VERTICAL)
+ panelSizer.Add(self.panel, 1, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(panelSizer)
panelSizer.Fit(self)
@@ -434,17 +434,17 @@
self.grid.SetFocus()
- EVT_BUTTON(self, ID_QUERY, self.OnQuery)
- EVT_BUTTON(self, ID_EXPORT, self.OnExport)
- EVT_BUTTON(self, ID_EXPORTSEL, self.OnExportSel)
- EVT_BUTTON(self, wxID_CLOSE, self.OnClose)
- EVT_KEY_DOWN(self.grid, self.OnKeyDown)
+ self.Bind(wx.EVT_BUTTON, self.OnQuery, id=ID_QUERY)
+ self.Bind(wx.EVT_BUTTON, self.OnExport, id=ID_EXPORT)
+ self.Bind(wx.EVT_BUTTON, self.OnExportSel, id=ID_EXPORTSEL)
+ self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
+ self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown, self.grid)
self.grid.Subscribe(ROW_SELECTED, self.UpdateStatusText)
def UpdateStatusText(self, rows=None):
- self.SetStatusText(_("%i rows (%i selected), %i columns")
- % (self.grid.GetNumberRows(),
+ self.SetStatusText(_("%i rows (%i selected), %i columns")
+ % (self.grid.GetNumberRows(),
self.grid.GetNumberSelected(),
self.grid.GetNumberCols()))
@@ -468,12 +468,12 @@
value = self.table.Column(text)
ids = self.table.SimpleQuery(
- self.table.Column(self.combo_fields.GetStringSelection()),
- self.choice_comp.GetStringSelection(),
+ self.table.Column(self.combo_fields.GetStringSelection()),
+ self.choice_comp.GetStringSelection(),
value)
choice = self.choice_action.GetSelection()
-
+
#
# what used to be nice code got became a bit ugly because
# each time we select a row a message is sent to the grid
@@ -520,15 +520,15 @@
finally:
ThubanEndBusyCursor()
-
+
def doExport(self, onlySelected):
-
- dlg = wxFileDialog(self, _("Export Table To"), ".", "",
+
+ dlg = wx.FileDialog(self, _("Export Table To"), ".", "",
_("DBF Files (*.dbf)|*.dbf|") +
_("CSV Files (*.csv)|*.csv|") +
_("All Files (*.*)|*.*"),
- wxSAVE|wxOVERWRITE_PROMPT)
- if dlg.ShowModal() == wxID_OK:
+ wx.SAVE|wx.OVERWRITE_PROMPT)
+ if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
type = os.path.basename(filename).split('.')[-1:][0]
dlg.Destroy()
@@ -543,8 +543,8 @@
elif type.upper() == 'CSV':
table_to_csv(self.table, filename, records)
else:
- dlg = wxMessageDialog(None, "Unsupported format: %s" % type,
- "Table Export", wxOK|wxICON_WARNING)
+ dlg = wx.MessageDialog(None, "Unsupported format: %s" % type,
+ "Table Export", wx.OK|wx.ICON_WARNING)
dlg.ShowModal()
dlg.Destroy()
else:
Modified: trunk/thuban/Thuban/UI/tree.py
===================================================================
--- trunk/thuban/Thuban/UI/tree.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/tree.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -10,7 +10,7 @@
from types import StringType, UnicodeType
-from wxPython.wx import *
+import wx
from Thuban import _
from Thuban.UI.common import Color2wxColour
@@ -26,7 +26,7 @@
BMP_SIZE = 15
-class SessionTreeCtrl(wxTreeCtrl):
+class SessionTreeCtrl(wx.TreeCtrl):
"""Widget to display a tree view of the session.
@@ -51,7 +51,7 @@
def __init__(self, parent, ID, mainwindow, app):
# Use the WANTS_CHARS style so the panel doesn't eat the Return key.
- wxTreeCtrl.__init__(self, parent, ID)
+ wx.TreeCtrl.__init__(self, parent, ID)
self.mainwindow = mainwindow
self.app = app
@@ -72,7 +72,7 @@
# pretend the session has changed to build the initial tree
self.session_changed()
- EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
+ self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=self.GetId())
def unsubscribe_all(self):
if self.session is not None:
@@ -85,17 +85,17 @@
"""Clear and rebuild the tree"""
self.DeleteAllItems()
self.layer_to_item.clear()
- self.image_list = wxImageList(BMP_SIZE, BMP_SIZE, False, 0)
+ self.image_list = wx.ImageList(BMP_SIZE, BMP_SIZE, False, 0)
- bmp = wxEmptyBitmap(BMP_SIZE, BMP_SIZE)
- dc = wxMemoryDC()
+ bmp = wx.EmptyBitmap(BMP_SIZE, BMP_SIZE)
+ dc = wx.MemoryDC()
dc.SelectObject(bmp)
- dc.SetBrush(wxBLACK_BRUSH)
+ dc.SetBrush(wx.BLACK_BRUSH)
dc.Clear()
- dc.SelectObject(wxNullBitmap)
+ dc.SelectObject(wx.NullBitmap)
self.emptyImageIndex = \
- self.image_list.AddWithColourMask(bmp, wxColour(0, 0, 0))
+ self.image_list.AddWithColourMask(bmp, wx.Colour(0, 0, 0))
self.AssignImageList(self.image_list)
@@ -144,16 +144,16 @@
treeitem = self.AppendItem(parent, "(%s)" % item[0])
- bmp = wxEmptyBitmap(BMP_SIZE, BMP_SIZE)
- brush = wxBrush(Color2wxColour(item[1]), wxSOLID)
- dc = wxMemoryDC()
+ bmp = wx.EmptyBitmap(BMP_SIZE, BMP_SIZE)
+ brush = wx.Brush(Color2wxColour(item[1]), wx.SOLID)
+ dc = wx.MemoryDC()
dc.SelectObject(bmp)
dc.SetBrush(brush)
dc.Clear()
- dc.DrawRoundedRectangle(0, 0,
+ dc.DrawRoundedRectangle(0, 0,
bmp.GetWidth(), bmp.GetHeight(),
4)
- dc.SelectObject(wxNullBitmap)
+ dc.SelectObject(wx.NullBitmap)
i = self.image_list.Add(bmp)
self.SetItemImage(treeitem, i)
Modified: trunk/thuban/Thuban/UI/view.py
===================================================================
--- trunk/thuban/Thuban/UI/view.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/view.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -1,4 +1,4 @@
-# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH
+# opyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH
# Authors:
# Bernhard Herzog <bh at intevation.de>
# Frank Koormann <frank at intevation.de>
@@ -20,19 +20,12 @@
import time
import traceback
-from wxPython.wx import wxWindow, \
- wxPaintDC, wxColour, wxClientDC, wxINVERT, wxTRANSPARENT_BRUSH, wxFont,\
- EVT_PAINT, EVT_LEFT_DOWN, EVT_LEFT_UP, EVT_MOTION, EVT_LEAVE_WINDOW, \
- wxPlatform, wxBeginBusyCursor, wxEndBusyCursor, wxFileDialog, wxSAVE, \
- EVT_MIDDLE_DOWN, EVT_MIDDLE_UP, \
- wxOVERWRITE_PROMPT, wxID_OK
+import wx
# Export related stuff
-if wxPlatform == '__WXMSW__':
- from wxPython.wx import wxMetaFileDC
+if wx.Platform == '__WXMSW__':
+ from wx import MetaFileDC
-from wxPython import wx
-
from Thuban import _
from Thuban.Model.messages import MAP_LAYERS_CHANGED, LAYER_CHANGED, \
@@ -55,20 +48,20 @@
x, y = self.current
width, height = self.view.GetSizeTuple()
- bitmapdc = wx.wxMemoryDC()
+ bitmapdc = wx.MemoryDC()
bitmapdc.SelectObject(self.view.PreviewBitmap())
dc = self.view.drag_dc
dc.Blit(0, 0, width, height, bitmapdc, sx - x, sy - y)
-class MapPrintout(wx.wxPrintout):
+class MapPrintout(wx.Printout):
"""
wxPrintout class for printing Thuban maps
"""
def __init__(self, canvas, map, region, selected_layer, selected_shapes):
- wx.wxPrintout.__init__(self)
+ wx.Printout.__init__(self)
self.canvas = canvas
self.map = map
self.region = region
@@ -104,40 +97,40 @@
return True
-class MapCanvas(wxWindow, ViewPort):
+class MapCanvas(wx.Window, ViewPort):
"""A widget that displays a map and offers some interaction"""
def __init__(self, parent, winid):
- wxWindow.__init__(self, parent, winid)
+ wx.Window.__init__(self, parent, winid)
ViewPort.__init__(self)
- self.SetBackgroundColour(wxColour(255, 255, 255))
+ self.SetBackgroundColour(wx.Colour(255, 255, 255))
# the bitmap serving as backing store
self.bitmap = None
# the monochrome bitmap with the selection if any
self.selection_bitmap = None
- self.backgroundColor = wx.wxWHITE_BRUSH
+ self.backgroundColor = wx.WHITE_BRUSH
# The rendering iterator object. Used when rendering
# incrementally
self.render_iter = None
# subscribe the WX events we're interested in
- EVT_PAINT(self, self.OnPaint)
- EVT_LEFT_DOWN(self, self.OnLeftDown)
- EVT_LEFT_UP(self, self.OnLeftUp)
- EVT_MIDDLE_DOWN(self, self.OnMiddleDown)
- EVT_MIDDLE_UP(self, self.OnMiddleUp)
- EVT_MOTION(self, self.OnMotion)
- EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)
- wx.EVT_SIZE(self, self.OnSize)
- wx.EVT_IDLE(self, self.OnIdle)
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
+ self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
+ self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
+ self.Bind(wx.EVT_MIDDLE_DOWN, self.OnMiddleDown)
+ self.Bind(wx.EVT_MIDDLE_UP, self.OnMiddleUp)
+ self.Bind(wx.EVT_MOTION, self.OnMotion)
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+ self.Bind(wx.EVT_IDLE, self.OnIdle)
def __del__(self):
- wxWindow.__del__(self)
+ wx.Window.__del__(self)
ViewPort.__del__(self)
def PreviewBitmap(self):
@@ -146,7 +139,7 @@
def PanTool(self):
"""Start the canvas pan tool"""
self.SelectTool(CanvasPanTool(self))
-
+
def SetMap(self, map):
redraw_channels = (MAP_LAYERS_CHANGED, LAYER_CHANGED,
LAYER_VISIBILITY_CHANGED)
@@ -166,7 +159,7 @@
self.full_redraw()
def OnPaint(self, event):
- dc = wxPaintDC(self)
+ dc = wx.PaintDC(self)
if self.Map() is not None and self.Map().HasLayers():
if self.bitmap is not None:
dc.BeginDrawing()
@@ -213,7 +206,7 @@
# the current tool is drawing on the window.
if not self.dragging \
and time.time() - self.render_last_preview > 0.5:
- client_dc = wxClientDC(self)
+ client_dc = wx.ClientDC(self)
client_dc.BeginDrawing()
client_dc.DrawBitmap(self.bitmap, 0, 0)
client_dc.EndDrawing()
@@ -240,12 +233,12 @@
def _render_iterator(self):
width, height = self.GetSizeTuple()
- dc = wx.wxMemoryDC()
+ dc = wx.MemoryDC()
render_start = time.time()
if self.bitmap is None:
- self.bitmap = wx.wxEmptyBitmap(width, height)
+ self.bitmap = wx.EmptyBitmap(width, height)
dc.SelectObject(self.bitmap)
dc.BeginDrawing()
@@ -259,13 +252,13 @@
yield True
dc.EndDrawing()
- dc.SelectObject(wx.wxNullBitmap)
+ dc.SelectObject(wx.NullBitmap)
if self.HasSelectedShapes() and self.selection_bitmap is None:
- bitmap = wx.wxEmptyBitmap(width, height)
+ bitmap = wx.EmptyBitmap(width, height)
dc.SelectObject(bitmap)
dc.BeginDrawing()
- dc.SetBackground(wx.wxWHITE_BRUSH)
+ dc.SetBackground(wx.WHITE_BRUSH)
dc.Clear()
renderer = ScreenRenderer(dc, self.Map(), self.scale, self.offset,
@@ -276,9 +269,9 @@
yield True
dc.EndDrawing()
- dc.SelectObject(wx.wxNullBitmap)
+ dc.SelectObject(wx.NullBitmap)
- bitmap.SetMask(wx.wxMaskColour(bitmap, wx.wxWHITE))
+ bitmap.SetMask(wx.Mask(bitmap, wx.WHITE))
self.selection_bitmap = bitmap
yield False
@@ -289,13 +282,13 @@
export_path = self.export_path
else:
export_path="."
- dlg = wxFileDialog(self, _("Export Map"), export_path, "",
- "Enhanced Metafile (*.wmf)|*.wmf",
- wxSAVE|wxOVERWRITE_PROMPT)
- if dlg.ShowModal() == wxID_OK:
+ dlg = wx.FileDialog(self, _("Export Map"), export_path, "",
+ "Enhanced Metafile (*.wmf)|*.wmf",
+ wx.SAVE|wx.OVERWRITE_PROMPT)
+ if dlg.ShowModal() == wx.ID_OK:
self.export_path = os.path.dirname(dlg.GetPath())
- dc = wxMetaFileDC(dlg.GetPath())
-
+ dc = wx.MetaFileDC(dlg.GetPath())
+
scale, offset, mapregion = output_transform(self.scale,
self.offset,
self.GetSizeTuple(),
@@ -315,14 +308,14 @@
dc.EndDrawing()
dc.Close()
dlg.Destroy()
-
+
def Print(self):
- printer = wx.wxPrinter()
+ printer = wx.Printer()
width, height = self.GetSizeTuple()
selected_layer = self.selection.SelectedLayer()
selected_shapes = self.selection.SelectedShapes()
-
- printout = MapPrintout(self, self.Map(), (0, 0, width, height),
+
+ printout = MapPrintout(self, self.Map(), (0, 0, width, height),
selected_layer, selected_shapes)
printer.Print(self, printout, True)
printout.Destroy()
@@ -370,9 +363,9 @@
def OnLeftDown(self, event):
self.MouseLeftDown(event)
if self.tool is not None:
- self.drag_dc = wxClientDC(self)
- self.drag_dc.SetLogicalFunction(wxINVERT)
- self.drag_dc.SetBrush(wxTRANSPARENT_BRUSH)
+ self.drag_dc = wx.ClientDC(self)
+ self.drag_dc.SetLogicalFunction(wx.INVERT)
+ self.drag_dc.SetBrush(wx.TRANSPARENT_BRUSH)
self.tool.Show(self.drag_dc)
self.CaptureMouse()
self.dragging = 1
@@ -429,8 +422,8 @@
self.redraw_selection()
def GetTextExtent(self, text):
- dc = wxClientDC(self)
- font = wxFont(10, wx.wxSWISS, wx.wxNORMAL, wx.wxNORMAL)
+ dc = wx.ClientDC(self)
+ font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL)
dc.SetFont(font)
return dc.GetTextExtent(text)
Modified: trunk/thuban/Thuban/UI/viewport.py
===================================================================
--- trunk/thuban/Thuban/UI/viewport.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/UI/viewport.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -500,7 +500,7 @@
Set the scale so that the layer fits exactly into the window and
center it in the window.
"""
-
+
bbox = layer.LatLongBoundingBox()
if bbox is not None:
proj = self.map.GetProjection()
@@ -522,7 +522,7 @@
if bbox is not None:
if len(shapes) == 1 and layer.ShapeType() == SHAPETYPE_POINT:
- self.ZoomFactor(self.calc_min_max_scales()[1] / self.scale,
+ self.ZoomFactor(self.calc_min_max_scales()[1] / self.scale,
self.proj_to_win(bbox[0], bbox[1]))
else:
self.FitRectToWindow(bbox)
@@ -1025,12 +1025,12 @@
width = width * 0.9
map_height = width - 2*distance
map_width = map_height
-
- mapregion = (distance, distance,
+
+ mapregion = (distance, distance,
distance+map_width, distance+map_height)
canvas_width, canvas_height = canvas_size
-
+
scalex = map_width / (canvas_width/canvas_scale)
scaley = map_height / (canvas_height/canvas_scale)
scale = min(scalex, scaley)
Modified: trunk/thuban/Thuban/version.py
===================================================================
--- trunk/thuban/Thuban/version.py 2006-09-18 13:59:40 UTC (rev 2699)
+++ trunk/thuban/Thuban/version.py 2006-09-18 14:27:02 UTC (rev 2700)
@@ -102,7 +102,8 @@
versions['thuban-long'] = longversion
# wxPython
-from wxPython.wx import __version__ as wxPython_version
+
+from wx import __version__ as wxPython_version
versions['wxPython'] = wxPython_version
versions['wxPython-tuple'] = make_tuple(wxPython_version)
More information about the Thuban-commits
mailing list