[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__ = "$Revi