diff --git a/wx/lib/ClickableHtmlWindow.py b/wx/lib/ClickableHtmlWindow.py
index 51c81263..4deec13d 100644
--- a/wx/lib/ClickableHtmlWindow.py
+++ b/wx/lib/ClickableHtmlWindow.py
@@ -24,7 +24,7 @@ class PyClickableHtmlWindow(html.HtmlWindow):
to the clipboard.
"""
def __init__(self,parent,ID,**kw):
- apply(html.HtmlWindow.__init__,(self,parent,ID),kw)
+ html.HtmlWindow.__init__(self, parent, ID, **kw)
def OnLinkClicked(self,link):
self.link = wx.TextDataObject(link.GetHref())
diff --git a/wx/lib/calendar.py b/wx/lib/calendar.py
index 89cd54df..90062fd8 100644
--- a/wx/lib/calendar.py
+++ b/wx/lib/calendar.py
@@ -122,8 +122,8 @@ def GetMonthList():
def MakeColor(in_color):
try:
- color = wxNamedColour(in_color)
- except:
+ color = wx.Colour(in_color)
+ except Exception:
color = in_color
return color
@@ -152,7 +152,7 @@ class CalDraw:
self.pheight = 1
try:
self.scale = parent.scale
- except:
+ except Exception:
self.scale = 1
self.gridx = []
@@ -176,8 +176,9 @@ class CalDraw:
self.colors = DefaultColors()
- self.font = wx.SWISS
- self.bold = wx.NORMAL
+ self.fontfamily = wx.FONTFAMILY_SWISS
+ self.fontstyle = wx.FONTSTYLE_NORMAL
+ self.fontweight = wx.FONTWEIGHT_NORMAL
self.hide_title = False
self.hide_grid = False
@@ -262,7 +263,7 @@ class CalDraw:
def DrawBorder(self, DC, transparent = False):
if self.outer_border is True:
if transparent == False:
- brush = wx.Brush(MakeColor(self.colors[COLOR_BACKGROUND]), wx.SOLID)
+ brush = wx.Brush(MakeColor(self.colors[COLOR_BACKGROUND]), wx.BRUSHSTYLE_SOLID)
else:
brush = wx.TRANSPARENT_BRUSH
DC.SetBrush(brush)
@@ -274,7 +275,7 @@ class CalDraw:
def DrawFocusIndicator(self, DC):
if self.outer_border is True:
DC.SetBrush(wx.TRANSPARENT_BRUSH)
- DC.SetPen(wx.Pen(MakeColor(self.colors[COLOR_HIGHLIGHT_BACKGROUND]), style=wx.DOT))
+ DC.SetPen(wx.Pen(MakeColor(self.colors[COLOR_HIGHLIGHT_BACKGROUND]), style=wx.PENSTYLE_DOT))
# full display window area
rect = wx.Rect(self.cx_st, self.cy_st, self.sizew, self.sizeh)
DC.DrawRectangle(rect)
@@ -378,7 +379,7 @@ class CalDraw:
if self.sizeh < _MIDSIZE:
sizef = 10
- f = wx.Font(sizef, self.font, wx.NORMAL, self.bold)
+ f = wx.Font(sizef, self.fontfamily, self.fontstyle, self.fontweight)
DC.SetFont(f)
tw,th = DC.GetTextExtent(month)
@@ -391,7 +392,7 @@ class CalDraw:
self.title_offset = th * 2
- f = wx.Font(sizef, self.font, wx.NORMAL, self.bold)
+ f = wx.Font(sizef, self.fontfamily, self.fontstyle, self.fontweight)
DC.SetFont(f)
DC.DrawText(year, self.cx_st + adjust, self.cy_st + th)
@@ -401,7 +402,7 @@ class CalDraw:
height = self.gridy[1] - self.gridy[0] + 1
rect_w = self.gridx[-1] - self.gridx[0]
- f = wx.Font(10, self.font, wx.NORMAL, self.bold) # initial font setting
+ f = wx.Font(10, self.fontfamily, self.fontstyle, self.fontweight) # initial font setting
if self.week_auto == True:
test_size = self.max_week_size # max size
@@ -424,7 +425,7 @@ class CalDraw:
cnt_x = 0
cnt_y = 0
- brush = wx.Brush(MakeColor(self.colors[COLOR_HEADER_BACKGROUND]), wx.SOLID)
+ brush = wx.Brush(MakeColor(self.colors[COLOR_HEADER_BACKGROUND]), wx.BRUSHSTYLE_SOLID)
DC.SetBrush(brush)
if self.cal_type == "NORMAL":
@@ -451,15 +452,15 @@ class CalDraw:
pointXY = (x, y)
pointWH = (width, height)
if self.hide_grid == False:
- pen = wx.Pen(MakeColor(self.GetColor(COLOR_GRID_LINES)), 1, wx.SOLID)
+ pen = wx.Pen(MakeColor(self.GetColor(COLOR_GRID_LINES)), 1, wx.PENSTYLE_SOLID)
else:
- pen = wx.Pen(MakeColor(self.GetColor(COLOR_BACKGROUND)), 1, wx.SOLID)
+ pen = wx.Pen(MakeColor(self.GetColor(COLOR_BACKGROUND)), 1, wx.PENSTYLE_SOLID)
DC.SetPen(pen)
DC.DrawRectangle( pointXY, pointWH)
old_pen = DC.GetPen()
- pen = wx.Pen(MakeColor(self.colors[COLOR_3D_LIGHT]), 1, wx.SOLID)
+ pen = wx.Pen(MakeColor(self.colors[COLOR_3D_LIGHT]), 1, wx.PENSTYLE_SOLID)
DC.SetPen(pen)
# draw the horizontal hilight
startPoint = wx.Point(x + 1 , y + 1)
@@ -471,7 +472,7 @@ class CalDraw:
endPoint = wx.Point(x + 1, y + height - 2)
DC.DrawLine(startPoint, endPoint )
- pen = wx.Pen(MakeColor(self.colors[COLOR_3D_DARK]), 1, wx.SOLID)
+ pen = wx.Pen(MakeColor(self.colors[COLOR_3D_DARK]), 1, wx.PENSTYLE_SOLID)
DC.SetPen(pen)
# draw the horizontal lowlight
@@ -484,7 +485,7 @@ class CalDraw:
endPoint = wx.Point(x + width - 2, y + height - 2)
DC.DrawLine(startPoint, endPoint )
- pen = wx.Pen(MakeColor(self.colors[COLOR_FONT]), 1, wx.SOLID)
+ pen = wx.Pen(MakeColor(self.colors[COLOR_FONT]), 1, wx.PENSTYLE_SOLID)
DC.SetPen(pen)
@@ -512,7 +513,7 @@ class CalDraw:
# draw the day numbers
def DrawNum(self, DC):
- f = wx.Font(10, self.font, wx.NORMAL, self.bold) # initial font setting
+ f = wx.Font(10, self.fontfamily, self.fontstyle, self.fontweight) # initial font setting
self._CalcFontSize(DC, f)
cnt_x = 0
@@ -534,7 +535,7 @@ class CalDraw:
try:
num_val = int(text)
num_color = self.cal_sel[num_val][0]
- except:
+ except Exception:
num_color = self.colors[COLOR_FONT]
DC.SetTextForeground(MakeColor(num_color))
@@ -563,7 +564,7 @@ class CalDraw:
DC.DrawText(text, (x+adj_h, y+adj_v))
def DrawDayText(self, DC, key):
- f = wx.Font(10, self.font, wx.NORMAL, self.bold) # initial font setting
+ f = wx.Font(10, self.fontfamily, self.fontstyle, self.fontweight) # initial font setting
self._CalcFontSize(DC, f)
if key > self.end_pos:
@@ -602,7 +603,7 @@ class CalDraw:
for key in self.cal_sel.keys():
sel_color = self.cal_sel[key][1]
- brush = wx.Brush(MakeColor(sel_color), wx.SOLID)
+ brush = wx.Brush(MakeColor(sel_color), wx.BRUSHSTYLE_SOLID)
DC.SetBrush(brush)
if self.hide_grid is False:
@@ -925,7 +926,7 @@ class Calendar( wx.Control ):
def TestDay(self, key):
try:
self.day = int(self.cal_days[key])
- except:
+ except Exception:
return None
if self.day == "":
@@ -990,7 +991,7 @@ class Calendar( wx.Control ):
try:
cal = self.caldraw
- except:
+ except Exception:
self.caldraw = CalDraw(self)
cal = self.caldraw
@@ -1040,7 +1041,7 @@ class Calendar( wx.Control ):
self.caldraw.DrawFocusIndicator(DC)
else:
self.caldraw.DrawBorder(DC,True)
- except:
+ except Exception:
pass
def DrawRect(self, key, bgcolor = 'WHITE', fgcolor= 'PINK',width = 0):
@@ -1071,7 +1072,7 @@ class Calendar( wx.Control ):
try:
DC.SetPen(wx.Pen(MakeColor(fgcolor), width))
- except:
+ except Exception:
DC.SetPen(wx.Pen(MakeColor(self.GetColor(COLOR_GRID_LINES)), width))
rect = self.rg[key]
@@ -1093,7 +1094,7 @@ class Calendar( wx.Control ):
if day % 7 == 6 or day % 7 == 0:
return True
- except:
+ except Exception:
return False
def SelectDay(self, key):
@@ -1123,7 +1124,7 @@ class Calendar( wx.Control ):
try:
dayIdx = int(self.cal_days[key])
(cfont, bgcolor) = self.caldraw.cal_sel[dayIdx]
- except:
+ except Exception:
pass
return (cfont, bgcolor)
diff --git a/wx/lib/colourdb.py b/wx/lib/colourdb.py
index 4b50f1a7..923f94cd 100644
--- a/wx/lib/colourdb.py
+++ b/wx/lib/colourdb.py
@@ -13,13 +13,13 @@
#----------------------------------------------------------------------
"""
-This module loads additional colour names/values into the :class:`ColourDatabase`.
+This module loads additional colour names/values into the :class:`ColourDatabase`.
Description
===========
-This module loads additional colour names/values into the :class:`ColourDatabase`.
+This module loads additional colour names/values into the :class:`ColourDatabase`.
The :mod:`colourdb` will update the wxPython :class:`ColourDatabase` using a pre-defined
set of colour names/colour tuples, hard-coded in this module source code.
@@ -44,7 +44,7 @@ Sample usage::
colour_list = wx.lib.colourdb.getColourList()
# create a choice widget
- self.choice = wx.Choice(self, -1, choices=colour_list)
+ self.choice = wx.Choice(self.panel, -1, choices=colour_list)
# select item 0 (first item) in choice list to show
self.choice.SetSelection(0)
# set the current frame colour to the choice
@@ -75,7 +75,7 @@ def getColourList():
:rtype: list of strings
"""
-
+
return [ x[0] for x in getColourInfoList() ]
@@ -85,7 +85,7 @@ def getColourInfoList():
:rtype: list of tuples
"""
-
+
return [
("SNOW", 255, 250, 250),
("GHOST WHITE", 248, 248, 255),
@@ -724,16 +724,16 @@ _haveUpdated = False
def updateColourDB():
""" Updates the :class:`ColourDatabase` by adding new colour names and RGB values. """
-
+
global _haveUpdated
if not _haveUpdated:
import wx
assert wx.GetApp() is not None, "You must have a wx.App object before you can use the colour database."
cl = getColourInfoList()
-
+
for info in cl:
name, colour = info[0], wx.Colour(*info[1:])
wx.TheColourDatabase.AddColour(name, colour)
-
+
_haveUpdated = True
diff --git a/wx/lib/delayedresult.py b/wx/lib/delayedresult.py
index fdb0a4b5..2b77bbe4 100644
--- a/wx/lib/delayedresult.py
+++ b/wx/lib/delayedresult.py
@@ -267,7 +267,7 @@ class Producer(threading.Thread):
result = workerFn(*args, **kwargs)
except AbortedException:
pass
- except Exception, exc:
+ except Exception as exc:
originalTb = traceback.format_exc()
extraInfo = self._extraInfo(exc)
sender.sendException(exc, extraInfo, originalTb)
diff --git a/wx/lib/dialogs.py b/wx/lib/dialogs.py
index 0d33fc22..af0ee920 100644
--- a/wx/lib/dialogs.py
+++ b/wx/lib/dialogs.py
@@ -411,7 +411,7 @@ class MultiMessageDialog(wx.Dialog):
messageSizer = wx.BoxSizer(wx.VERTICAL)
if 'wxMac' in wx.PlatformInfo and caption:
caption = wx.StaticText(self, -1, caption)
- caption.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
+ caption.SetFont(wx.Font(18, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
messageSizer.Add(caption)
messageSizer.Add((10,10))
diff --git a/wx/lib/docview.py b/wx/lib/docview.py
index 1e06a4dd..f6acb25f 100644
--- a/wx/lib/docview.py
+++ b/wx/lib/docview.py
@@ -413,7 +413,7 @@ class Document(wx.EvtHandler):
FileNameFromPath(self.GetFilename()),
docTemplate.GetDefaultExtension(),
wildcard = descr,
- flags = wx.SAVE | wx.OVERWRITE_PROMPT,
+ flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
parent = self.GetDocumentWindow())
if filename == "":
return False
@@ -2176,7 +2176,7 @@ class DocManager(wx.EvtHandler):
dlg = wx.FileDialog(self.FindSuitableParent(),
_("Select a File"),
wildcard=descr,
- style=wx.OPEN|wx.FILE_MUST_EXIST|wx.CHANGE_DIR)
+ style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_CHANGE_DIR)
# dlg.CenterOnParent() # wxBug: caused crash with wx.FileDialog
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
diff --git a/wx/lib/dragscroller.py b/wx/lib/dragscroller.py
index 27cce1e6..af87c9be 100644
--- a/wx/lib/dragscroller.py
+++ b/wx/lib/dragscroller.py
@@ -17,7 +17,7 @@ class DragScroller:
Call Start with the position of the drag start.
Call Stop on the drag release. """
- def __init__(self, scrollwin, rate=30, sensitivity=0.75):
+ def __init__(self, scrollwin=None, rate=30, sensitivity=0.75):
self.scrollwin = scrollwin
self.rate = rate
self.sensitivity = sensitivity
@@ -43,7 +43,7 @@ class DragScroller:
def Start(self, pos):
""" Start a drag scroll operation """
if not self.scrollwin:
- raise Exception, 'No ScrollWindow defined'
+ raise Exception('No ScrollWindow defined')
self.pos = pos
self.scrollwin.SetCursor(wx.Cursor(wx.CURSOR_SIZING))
diff --git a/wx/lib/eventwatcher.py b/wx/lib/eventwatcher.py
index 1e6052bc..a86c54d4 100644
--- a/wx/lib/eventwatcher.py
+++ b/wx/lib/eventwatcher.py
@@ -103,7 +103,7 @@ def _makeAttribString(evt):
try:
value = getattr(evt, name)()
attribs += "%s : %s\n" % (name, value)
- except:
+ except Exception:
pass
return attribs.rstrip()
diff --git a/wx/lib/evtmgr.py b/wx/lib/evtmgr.py
index d7dba8f0..bc9c5203 100644
--- a/wx/lib/evtmgr.py
+++ b/wx/lib/evtmgr.py
@@ -106,7 +106,7 @@ class EventManager:
self.messageAdapterDict[topic] = {}
self.messageAdapterDict[topic][listener] = messageAdapter
- if not self.eventAdapterDict.has_key(topic):
+ if not topic in self.eventAdapterDict:
self.eventAdapterDict[topic] = EventAdapter(event, win, id)
else:
# Throwing away a duplicate request
@@ -170,7 +170,7 @@ class EventManager:
for topic in topicList:
topicDict = self.messageAdapterDict[topic]
- if topicDict.has_key(listener):
+ if listener in topicDict:
topicDict[listener].Destroy()
del topicDict[listener]
@@ -285,7 +285,7 @@ class EventManager:
with these specs.
"""
try:
- return self.messageAdapterDict[topicPattern].has_key(eventHandler)
+ return eventHandler in self.messageAdapterDict[topicPattern]
except KeyError:
return 0
diff --git a/wx/lib/fancytext.py b/wx/lib/fancytext.py
index 9f839a3c..339ea604 100644
--- a/wx/lib/fancytext.py
+++ b/wx/lib/fancytext.py
@@ -43,7 +43,7 @@ as greek letters in both upper case (*Alpha* *Beta*... *Omega*) and
lower case (*alpha* *beta*... *omega*).
>>> frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition)
->>> sft = StaticFancyText(frame, -1, testText, wx.Brush("light grey", wx.SOLID))
+>>> sft = StaticFancyText(frame, -1, testText, wx.Brush("light grey", wx.BRUSHSTYLE_SOLID))
>>> frame.SetClientSize(sft.GetSize())
>>> didit = frame.Show()
>>> from guitest import PauseTests; PauseTests()
@@ -100,9 +100,9 @@ class Renderer:
"""
defaultSize = None
- defaultFamily = wx.DEFAULT
- defaultStyle = wx.NORMAL
- defaultWeight = wx.NORMAL
+ defaultFamily = wx.FONTFAMILY_DEFAULT
+ defaultStyle = wx.FONTSTYLE_NORMAL
+ defaultWeight = wx.FONTWEIGHT_NORMAL
defaultEncoding = None
defaultColor = "black"
@@ -227,7 +227,7 @@ class Renderer:
return wx.TheColourDatabase.FindColour(font.get("color", self.defaultColor))
def getCurrentPen(self):
- return wx.Pen(self.getCurrentColor(), 1, wx.SOLID)
+ return wx.Pen(self.getCurrentColor(), 1, wx.PENSTYLE_SOLID)
def renderCharacterData(self, data, x, y):
raise NotImplementedError()
@@ -341,7 +341,7 @@ def RenderToRenderer(str, renderer, enclose=True):
p.EndElementHandler = renderer.endElement
p.CharacterDataHandler = renderer.characterData
p.Parse(str, 1)
- except xml.parsers.expat.error, err:
+ except xml.parsers.expat.error as err:
raise ValueError('error parsing text text "%s": %s' % (str, err))
@@ -402,7 +402,7 @@ class StaticFancyText(wx.StaticBitmap):
elif args:
background = args.pop(0)
else:
- background = wx.Brush(window.GetBackgroundColour(), wx.SOLID)
+ background = wx.Brush(window.GetBackgroundColour(), wx.BRUSHSTYLE_SOLID)
bmp = RenderToBitmap(text, background)
wx.StaticBitmap.__init__(self, window, id, bmp, *args, **kargs)
@@ -447,7 +447,7 @@ upper case (...) and lower case (...
>>> frame = wx.Frame(wx.NULL, -1, "FancyText demo", wx.DefaultPosition)
->>> sft = StaticFancyText(frame, -1, __doc__, wx.Brush("light grey", wx.SOLID))
+>>> sft = StaticFancyText(frame, -1, __doc__, wx.Brush("light grey", wx.BRUSHSTYLE_SOLID))
>>> frame.SetClientSize(sft.GetSize())
>>> didit = frame.Show()
>>> from guitest import PauseTests; PauseTests()
diff --git a/wx/lib/filebrowsebutton.py b/wx/lib/filebrowsebutton.py
index ec714987..97cdca59 100644
--- a/wx/lib/filebrowsebutton.py
+++ b/wx/lib/filebrowsebutton.py
@@ -17,10 +17,10 @@
# o 2.5 Compatability changes
#
-import os
-import types
+import os
+import types
-import wx
+import wx
#----------------------------------------------------------------------
@@ -105,8 +105,8 @@ class FileBrowseButton(wx.Panel):
self.SetAutoLayout(True)
self.SetSizer( outsidebox )
self.Layout()
- if type( size ) == types.TupleType:
- size = apply( wx.Size, size)
+ if type(size) == tuple:
+ size = wx.Size(size)
self.SetSize(-1, -1, size.width, size.height, wx.SIZE_USE_EXISTING)
# if size.width != -1 or size.height != -1:
diff --git a/wx/lib/floatbar.py b/wx/lib/floatbar.py
index f5629e29..68e8643c 100644
--- a/wx/lib/floatbar.py
+++ b/wx/lib/floatbar.py
@@ -89,21 +89,20 @@ else:
toolbar's frame when it is floating. floatable(bool): whether
user actions (i.e., dragging) can float the toolbar or not.
"""
- args = (self,) + _args
- apply(wx.ToolBar.__init__, args, _kwargs)
- if _kwargs.has_key('floatable'):
+ wx.ToolBar.__init__(self, *_args, **_kwargs)
+ if 'floatable' in _kwargs:
self.floatable = _kwargs['floatable']
assert type(self.floatable) == type(0)
else:
self.floatable = 0
self.floating = 0
- if _kwargs.has_key('title'):
+ if 'title' in _kwargs:
self.title = _kwargs['title']
assert type(self.title) == type("")
else:
self.title = ""
self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
- self.parentframe = args[1]
+ self.parentframe = _args[1]
def IsFloatable(self):
@@ -289,7 +288,7 @@ else:
print("Reparented.")
self.parentframe.SetToolBar(self.nullbar)
print("Set toolbar")
- col = wx.NamedColour("GREY")
+ col = wx.Colour("GREY")
self.nullbar.SetBackgroundColour(col)
print("Set color")
size = self.parentframe.GetSize()
diff --git a/wx/lib/foldmenu.py b/wx/lib/foldmenu.py
index 1c1bc1f8..4bc45d8b 100644
--- a/wx/lib/foldmenu.py
+++ b/wx/lib/foldmenu.py
@@ -42,7 +42,7 @@ class FoldOutWindow(wx.PopupWindow):
def OnBtnClick(self,event):
id=event.GetEventObject().GetId()
- if self.handlers.has_key(id):
+ if id in self.handlers:
self.handlers[id](event)
self.Hide()
diff --git a/wx/lib/gestures.py b/wx/lib/gestures.py
index 6d7278b5..0734593e 100644
--- a/wx/lib/gestures.py
+++ b/wx/lib/gestures.py
@@ -141,7 +141,7 @@ class MouseGestures:
'''If the gesture is in the array of registered gestures, run the associated function.'''
if gesture in self.gestures:
i = self.gestures.index(gesture)
- apply(self.actions[i], self.actionarguments[i])
+ self.actions[i](self.actionarguments[i])
def End(self):
'''Stops recording the points to create the mouse gesture from,
diff --git a/wx/lib/gridmovers.py b/wx/lib/gridmovers.py
index f771cf84..bb4c49cb 100644
--- a/wx/lib/gridmovers.py
+++ b/wx/lib/gridmovers.py
@@ -161,7 +161,7 @@ class ColDragWindow(wx.Window):
dc = wx.PaintDC(self)
w,h = self.GetSize()
dc.DrawBitmap(self.image, 0,0)
- dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
+ dc.SetPen(wx.Pen(wx.BLACK,1,wx.PENSTYLE_SOLID))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.DrawRectangle(0,0, w,h)
iPos = self.GetInsertionPos()
@@ -224,7 +224,7 @@ class RowDragWindow(wx.Window):
dc = wx.PaintDC(self)
w,h = self.GetSize()
dc.DrawBitmap(self.image, 0,0)
- dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
+ dc.SetPen(wx.Pen(wx.BLACK,1,wx.PENSTYLE_SOLID))
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.DrawRectangle(0,0, w,h)
iPos = self.GetInsertionPos()
diff --git a/wx/lib/imagebrowser.py b/wx/lib/imagebrowser.py
index c7e849d2..f63bc0bc 100644
--- a/wx/lib/imagebrowser.py
+++ b/wx/lib/imagebrowser.py
@@ -687,6 +687,8 @@ class ImageDialog(wx.Dialog):
if len(self.fl_list):
self.tb.Set(self.fl_list)
+ if sys.version_info[0] == 3:
+ xrange = range
for idir in xrange(self.fl_ndirs):
d = self.fl_list[idir]
# mark directories as 'True' with client data
@@ -696,7 +698,7 @@ class ImageDialog(wx.Dialog):
try:
self.tb.SetSelection(0)
self.SetListValue(0)
- except:
+ except Exception:
self.image_view.SetValue(None)
else:
self.image_view.SetValue(None)
diff --git a/wx/lib/infoframe.py b/wx/lib/infoframe.py
index 14ab217c..3250ce6e 100644
--- a/wx/lib/infoframe.py
+++ b/wx/lib/infoframe.py
@@ -331,7 +331,7 @@ class PyInformationalMessagesFrame(object):
if not hasattr(self,"no__debug__"):
for m in sys.modules.values():
- if m is not None:# and m.__dict__.has_key("__debug__"):
+ if m is not None:# and "__debug__" in m.__dict__:
m.__dict__["__debug__"] = 1
if hasattr(self,"othermenu") and self.othermenu is not None:
@@ -359,7 +359,7 @@ class PyInformationalMessagesFrame(object):
if not hasattr(self,"no__debug__"):
for m in sys.modules.values():
- if m is not None:# and m.__dict__.has_key("__debug__"):
+ if m is not None:# and "__debug__" in m.__dict__:
m.__dict__["__debug__"] = 0
if self.frame is not None: # typically True, but, e.g., allows
diff --git a/wx/lib/inspection.py b/wx/lib/inspection.py
index 65bf491c..aa8bf75a 100644
--- a/wx/lib/inspection.py
+++ b/wx/lib/inspection.py
@@ -680,7 +680,7 @@ class InspectionInfoPanel(wx.stc.StyledTextCtrl):
if hasattr(obj, 'GetValue'):
try:
st.append(self.Fmt('value', obj.GetValue()))
- except:
+ except Exception:
pass
st.append(' child count = %d (direct) %d (recursive) %d (include TLWs)' %
(count, rcount, tlwcount))
diff --git a/wx/lib/intctrl.py b/wx/lib/intctrl.py
index 3b7c6460..a6bcb750 100644
--- a/wx/lib/intctrl.py
+++ b/wx/lib/intctrl.py
@@ -301,11 +301,11 @@ class IntValidator(wx.Validator):
# (Uncomment for debugging:)
## if allow_event:
## print('new value:', new_value)
-## if paste: print 'paste'
-## if set_to_none: print 'set_to_none'
-## if set_to_zero: print 'set_to_zero'
-## if set_to_minus_one: print 'set_to_minus_one'
-## if internally_set: print 'internally_set'
+## if paste: print('paste')
+## if set_to_none: print('set_to_none')
+## if set_to_zero: print('set_to_zero')
+## if set_to_minus_one: print('set_to_minus_one')
+## if internally_set: print('internally_set')
## else:
## print('new text:', new_text)
## print('disallowed')
diff --git a/wx/lib/itemspicker.py b/wx/lib/itemspicker.py
index 7202eea3..c5d53a78 100644
--- a/wx/lib/itemspicker.py
+++ b/wx/lib/itemspicker.py
@@ -145,7 +145,7 @@ class ItemsPicker(wx.Panel):
def _MoveItems(self,source,dest):
selections = source.GetSelections()
- selectedItems = map(source.GetString, selections)
+ selectedItems = list(map(source.GetString, selections))
dest.SetItems(dest.GetItems() + selectedItems)
selections = set(selections)
source.SetItems([item for i, item in enumerate(source.GetItems())\
@@ -153,7 +153,7 @@ class ItemsPicker(wx.Panel):
self._FireIpSelectionChanged()
def _AddSelectedItems(self):
- newItems = map(self._source.GetString, self._source.GetSelections())
+ newItems = list(map(self._source.GetString, self._source.GetSelections()))
items = self._dest.GetItems()
oldItems = set(items)
for newItem in newItems:
diff --git a/wx/lib/langlistctrl.py b/wx/lib/langlistctrl.py
index 21cdafb2..1f96df1f 100644
--- a/wx/lib/langlistctrl.py
+++ b/wx/lib/langlistctrl.py
@@ -345,7 +345,7 @@ def GetWxIdentifierForLanguage(lang):
for n in dir(wx):
if n.startswith('LANGUAGE_') and getattr(wx, n) == lang:
return n
- raise Exception, 'Language %s not found'%lang
+ raise Exception('Language %s not found'%lang)
#-------------------------------------------------------------------------------
diff --git a/wx/lib/msgpanel.py b/wx/lib/msgpanel.py
index a69b1ebd..d836b433 100644
--- a/wx/lib/msgpanel.py
+++ b/wx/lib/msgpanel.py
@@ -46,7 +46,7 @@ class MessagePanel(wx.Panel):
if caption:
caption = wx.StaticText(self, -1, caption)
- caption.SetFont(wx.Font(24, wx.SWISS, wx.NORMAL, wx.BOLD))
+ caption.SetFont(wx.Font(24, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
message = wx.StaticText(self, -1, message)
diff --git a/wx/lib/multisash.py b/wx/lib/multisash.py
index 1eae724b..0e03c7a5 100644
--- a/wx/lib/multisash.py
+++ b/wx/lib/multisash.py
@@ -22,6 +22,7 @@
import wx
+import wx.lib.six as six
MV_HOR = 0
MV_VER = not MV_HOR
@@ -32,7 +33,7 @@ CR_SIZE = SH_SIZE * 3
class MultiSash(wx.Window):
def __init__(self, *_args,**_kwargs):
- apply(wx.Window.__init__,(self,) + _args,_kwargs)
+ wx.Window.__init__(self, *_args, **_kwargs)
self._defChild = EmptyChild
self.child = MultiSplit(self,self,(0,0),self.GetSize())
self.Bind(wx.EVT_SIZE,self.OnMultiSize)
@@ -63,7 +64,7 @@ class MultiSash(wx.Window):
def SetSaveData(self,data):
mod = data['_defChild_mod']
dChild = mod + '.' + data['_defChild_class']
- exec 'import %s' % mod
+ six.exec_('import %s' % mod)
self._defChild = eval(dChild)
old = self.child
self.child = MultiSplit(self,self,wx.Point(0,0),self.GetSize())
@@ -327,7 +328,7 @@ class MultiViewLeaf(wx.Window):
def SetSaveData(self,data):
mod = data['detailClass_mod']
dChild = mod + '.' + data['detailClass_class']
- exec 'import %s' % mod
+ six.exec_('import %s' % mod)
detClass = eval(dChild)
self.SetSize(data['x'],data['y'],data['w'],data['h'])
old = self.detail
@@ -611,12 +612,12 @@ class MultiCreator(wx.Window):
def OnPaint(self,evt):
dc = wx.PaintDC(self)
- dc.SetBackground(wx.Brush(self.GetBackgroundColour(),wx.SOLID))
+ dc.SetBackground(wx.Brush(self.GetBackgroundColour(),wx.BRUSHSTYLE_SOLID))
dc.Clear()
- highlight = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT), 1, wx.SOLID)
- shadow = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW), 1, wx.SOLID)
- black = wx.Pen(wx.BLACK,1,wx.SOLID)
+ highlight = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT), 1, wx.PENSTYLE_SOLID)
+ shadow = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW), 1, wx.PENSTYLE_SOLID)
+ black = wx.Pen(wx.BLACK,1,wx.PENSTYLE_SOLID)
w,h = self.GetSize()
w -= 1
h -= 1
@@ -672,7 +673,7 @@ class MultiCloser(wx.Window):
def OnPaint(self,evt):
dc = wx.PaintDC(self)
- dc.SetBackground(wx.Brush(wx.RED,wx.SOLID))
+ dc.SetBackground(wx.Brush(wx.RED,wx.BRUSHSTYLE_SOLID))
dc.Clear()
def CalcSizePos(self,parent):
diff --git a/wx/lib/mvctree.py b/wx/lib/mvctree.py
index 6df50920..8fd034e2 100644
--- a/wx/lib/mvctree.py
+++ b/wx/lib/mvctree.py
@@ -192,25 +192,25 @@ class Painter:
def SetTextColour(self, color):
self.textcolor = color
self.textbrush = wx.Brush(color)
- self.textpen = wx.Pen(color, 1, wx.SOLID)
+ self.textpen = wx.Pen(color, 1, wx.PENSTYLE_SOLID)
def GetBackgroundColour(self):
return self.bgcolor
def SetBackgroundColour(self, color):
self.bgcolor = color
self.bgbrush = wx.Brush(color)
- self.bgpen = wx.Pen(color, 1, wx.SOLID)
+ self.bgpen = wx.Pen(color, 1, wx.PENSTYLE_SOLID)
def GetForegroundColour(self):
return self.fgcolor
def SetForegroundColour(self, color):
self.fgcolor = color
self.fgbrush = wx.Brush(color)
- self.fgpen = wx.Pen(color, 1, wx.SOLID)
+ self.fgpen = wx.Pen(color, 1, wx.PENSTYLE_SOLID)
def GetLineColour(self):
return self.linecolor
def SetLineColour(self, color):
self.linecolor = color
self.linebrush = wx.Brush(color)
- self.linepen = wx.Pen( color, 1, wx.SOLID)
+ self.linepen = wx.Pen( color, 1, wx.PENSTYLE_SOLID)
def GetForegroundPen(self):
return self.fgpen
def GetBackgroundPen(self):
@@ -330,7 +330,7 @@ class BasicTreeModel(TreeModel):
def SetRoot(self, root):
self.root = root
def GetChildCount(self, node):
- if self.children.has_key(node):
+ if node in self.children:
return len(self.children[node])
else:
return 0
@@ -342,7 +342,7 @@ class BasicTreeModel(TreeModel):
def AddChild(self, parent, child):
self.parents[child]=parent
- if not self.children.has_key(parent):
+ if not parent in self.children:
self.children[parent]=[]
self.children[parent].append(child)
TreeModel.AddChild(self, parent, child)
@@ -356,14 +356,14 @@ class BasicTreeModel(TreeModel):
def InsertChild(self, parent, child, index):
self.parents[child]=parent
- if not self.children.has_key(parent):
+ if not parent in self.children:
self.children[parent]=[]
self.children[parent].insert(child, index)
TreeModel.InsertChild(self, parent, child, index)
return child
def IsLeaf(self, node):
- return not self.children.has_key(node)
+ return not node in self.children
def IsEditable(self, node):
return False
@@ -482,7 +482,7 @@ class LateFSTreeModel(FSTreeModel):
fw = FileWrapper(ppath, name)
self.AddChild(parent, fw)
def GetChildCount(self, node):
- if self.children.has_key(node):
+ if node in self.children:
return FSTreeModel.GetChildCount(self, node)
else:
self._Build(node.path, node)
@@ -591,15 +591,15 @@ class TreePainter(Painter):
for i in range(25):
self.charWidths.append(dc.GetTextExtent("D")[0] * i)
self.charHeight = dc.GetTextExtent("D")[1]
- self.textpen = wx.Pen(self.GetTextColour(), 1, wx.SOLID)
- self.fgpen = wx.Pen(self.GetForegroundColour(), 1, wx.SOLID)
- self.bgpen = wx.Pen(self.GetBackgroundColour(), 1, wx.SOLID)
- self.linepen = wx.Pen(self.GetLineColour(), 1, wx.SOLID)
- self.dashpen = wx.Pen(self.GetLineColour(), 1, wx.DOT)
- self.textbrush = wx.Brush(self.GetTextColour(), wx.SOLID)
- self.fgbrush = wx.Brush(self.GetForegroundColour(), wx.SOLID)
- self.bgbrush = wx.Brush(self.GetBackgroundColour(), wx.SOLID)
- self.linebrush = wx.Pen(self.GetLineColour(), 1, wx.SOLID)
+ self.textpen = wx.Pen(self.GetTextColour(), 1, wx.PENSTYLE_SOLID)
+ self.fgpen = wx.Pen(self.GetForegroundColour(), 1, wx.PENSTYLE_SOLID)
+ self.bgpen = wx.Pen(self.GetBackgroundColour(), 1, wx.PENSTYLE_SOLID)
+ self.linepen = wx.Pen(self.GetLineColour(), 1, wx.PENSTYLE_SOLID)
+ self.dashpen = wx.Pen(self.GetLineColour(), 1, wx.PENSTYLE_DOT)
+ self.textbrush = wx.Brush(self.GetTextColour(), wx.BRUSHSTYLE_SOLID)
+ self.fgbrush = wx.Brush(self.GetForegroundColour(), wx.BRUSHSTYLE_SOLID)
+ self.bgbrush = wx.Brush(self.GetBackgroundColour(), wx.BRUSHSTYLE_SOLID)
+ self.linebrush = wx.Pen(self.GetLineColour(), 1, wx.PENSTYLE_SOLID)
treesize = self.tree.GetSize()
size = self.tree.transform.GetSize()
size = (max(treesize.width, size[0]+50), max(treesize.height, size[1]+50))
@@ -640,7 +640,7 @@ class TreePainter(Painter):
def SetLinePen(self, pen):
Painter.SetLinePen(self, pen)
- self.dashpen = wx.Pen(pen.GetColour(), 1, wx.DOT)
+ self.dashpen = wx.Pen(pen.GetColour(), 1, wx.PENSTYLE_DOT)
def paintWalk(self, node, dc, paintRects=0):
self.linePainter.Paint(node.parent, node, dc)
@@ -740,7 +740,7 @@ EVT_MVCTREE_KEY_DOWN = wx.PyEventBinder(wxEVT_MVCTREE_KEY_DOWN, 1)
class MVCTreeEvent(wx.PyCommandEvent):
def __init__(self, type, id, node = None, nodes = None, keyEvent = None, **kwargs):
- apply(wx.PyCommandEvent.__init__, (self, type, id), kwargs)
+ wx.PyCommandEvent.__init__(self, type, id, **kwargs)
self.node = node
self.nodes = nodes
self.keyEvent = keyEvent
@@ -753,7 +753,7 @@ class MVCTreeEvent(wx.PyCommandEvent):
class MVCTreeNotifyEvent(MVCTreeEvent):
def __init__(self, type, id, node = None, nodes = None, **kwargs):
- apply(MVCTreeEvent.__init__, (self, type, id, node, nodes), kwargs)
+ MVCTreeEvent.__init__(self, type, id, node, nodes, **kwargs)
self.notify = wx.NotifyEvent(type, id)
def getNotifyEvent(self):
return self.notify
@@ -764,7 +764,7 @@ class MVCTree(wx.ScrolledWindow):
"""
def __init__(self, parent, id, model = None, layout = None, transform = None,
painter = None, *args, **kwargs):
- apply(wx.ScrolledWindow.__init__, (self, parent, id), kwargs)
+ wx.ScrolledWindow.__init__(self, parent, id, **kwargs)
self.nodemap = {}
self._multiselect = False
self._selections = []
@@ -787,7 +787,7 @@ class MVCTree(wx.ScrolledWindow):
if not painter:
painter = TreePainter(self)
self.painter = painter
- self.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
+ self.SetFont(wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False))
self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.doubleBuffered = True
diff --git a/wx/lib/nvdlg.py b/wx/lib/nvdlg.py
index 1bda8dfb..1f264bc6 100644
--- a/wx/lib/nvdlg.py
+++ b/wx/lib/nvdlg.py
@@ -43,7 +43,7 @@ class SimpleNameValueDialog(wx.Dialog):
if captionTitle:
titleTxt = wx.StaticText(self, -1, captionTitle)
- titleTxt.SetFont(wx.FFont(18, wx.SWISS, wx.FONTFLAG_BOLD))
+ titleTxt.SetFont(wx.FFont(18, wx.FONTFAMILY_SWISS, wx.FONTFLAG_BOLD))
self.Sizer.Add(titleTxt, 0, wx.ALL, MARGIN)
if captionDescr:
descTxt = wx.StaticText(self, -1, captionDescr)
diff --git a/wx/lib/platebtn.py b/wx/lib/platebtn.py
index dd48c613..0ce2cd86 100644
--- a/wx/lib/platebtn.py
+++ b/wx/lib/platebtn.py
@@ -298,7 +298,7 @@ class PlateButton(wx.Control):
elif self._state['cur'] == PLATE_PRESSED:
gc.SetTextForeground(self._color['htxt'])
if wx.Platform == '__WXMAC__':
- pen = wx.Pen(GetHighlightColour(), 1, wx.SOLID)
+ pen = wx.Pen(GetHighlightColour(), 1, wx.PENSTYLE_SOLID)
else:
pen = wx.Pen(AdjustColour(self._color['press'], -80, 220), 1)
gc.SetPen(pen)
@@ -453,14 +453,14 @@ class PlateButton(wx.Control):
return wx.TRANSPARENT_BRUSH
bkgrd = self.GetBackgroundColour()
- brush = wx.Brush(bkgrd, wx.SOLID)
+ brush = wx.Brush(bkgrd, wx.BRUSHSTYLE_SOLID)
my_attr = self.GetDefaultAttributes()
p_attr = self.Parent.GetDefaultAttributes()
my_def = bkgrd == my_attr.colBg
p_def = self.Parent.GetBackgroundColour() == p_attr.colBg
if my_def and not p_def:
bkgrd = self.Parent.GetBackgroundColour()
- brush = wx.Brush(bkgrd, wx.SOLID)
+ brush = wx.Brush(bkgrd, wx.BRUSHSTYLE_SOLID)
return brush
def GetBitmapDisabled(self):
diff --git a/wx/lib/plot.py b/wx/lib/plot.py
index 9d4091fd..7171e3e6 100644
--- a/wx/lib/plot.py
+++ b/wx/lib/plot.py
@@ -124,7 +124,7 @@ except:
standard Python distribution). See the Numeric Python site
(http://numpy.scipy.org) for information on downloading source or
binaries."""
- raise ImportError, "NumPy not found.\n" + msg
+ raise ImportError("NumPy not found.\n" + msg)
@@ -147,7 +147,7 @@ class PolyPoints:
self.attributes.update(self._attributes)
for name, value in attr.items():
if name not in self._attributes.keys():
- raise KeyError, "Style attribute incorrect. Should be one of %s" % self._attributes.keys()
+ raise KeyError("Style attribute incorrect. Should be one of %s" % self._attributes.keys())
self.attributes[name] = value
def setLogScale(self, logscale):
@@ -165,7 +165,7 @@ class PolyPoints:
else:
return self._points
else:
- raise AttributeError, name
+ raise AttributeError(name)
def log10(self, data, ind):
data = _Numeric.compress(data[:,ind]>0,data,0)
@@ -225,7 +225,7 @@ class PolyLine(PolyPoints):
_attributes = {'colour': 'black',
'width': 1,
- 'style': wx.SOLID,
+ 'style': wx.PENSTYLE_SOLID,
'legend': ''}
def __init__(self, points, **attr):
@@ -238,7 +238,7 @@ class PolyLine(PolyPoints):
========================== ================================
'colour'= 'black' wx.Pen Colour any wx.Colour
'width'= 1 Pen width
- 'style'= wx.SOLID wx.Pen style
+ 'style'= wx.PENSTYLE_SOLID wx.Pen style
'legend'= '' Line Legend to display
========================== ================================
@@ -273,7 +273,7 @@ class PolySpline(PolyLine):
_attributes = {'colour': 'black',
'width': 1,
- 'style': wx.SOLID,
+ 'style': wx.PENSTYLE_SOLID,
'legend': ''}
def __init__(self, points, **attr):
@@ -286,7 +286,7 @@ class PolySpline(PolyLine):
========================== ================================
'colour'= 'black' wx.Pen Colour any wx.Colour
'width'= 1 Pen width
- 'style'= wx.SOLID wx.Pen style
+ 'style'= wx.PENSTYLE_SOLID wx.Pen style
'legend'= '' Line Legend to display
========================== ================================
@@ -317,7 +317,7 @@ class PolyMarker(PolyPoints):
'width': 1,
'size': 2,
'fillcolour': None,
- 'fillstyle': wx.SOLID,
+ 'fillstyle': wx.BRUSHSTYLE_SOLID,
'marker': 'circle',
'legend': ''}
@@ -328,16 +328,16 @@ class PolyMarker(PolyPoints):
:param `points`: sequence (array, tuple or list) of (x,y) points
:keyword `attr`: keyword attributes, default to:
- ============================ ================================
- 'colour'= 'black' wx.Pen Colour any wx.Colour
- 'width'= 1 Pen width
- 'size'= 2 Marker size
- 'fillcolour'= same as colour wx.Brush Colour any wx.Colour
- 'fillstyle'= wx.SOLID wx.Brush fill style (use wx.TRANSPARENT for no fill)
- 'style'= wx.SOLID wx.Pen style
- 'marker'= 'circle' Marker shape
- 'legend'= '' Line Legend to display
- ============================ ================================
+ ================================ ================================
+ 'colour'= 'black' wx.Pen Colour any wx.Colour
+ 'width'= 1 Pen width
+ 'size'= 2 Marker size
+ 'fillcolour'= same as colour wx.Brush Colour any wx.Colour
+ 'fillstyle'= wx.BRUSHSTYLE_SOLID wx.Brush fill style (use wx.BRUSHSTYLE_TRANSPARENT for no fill)
+ 'style'= wx.FONTFAMILY_SOLID wx.Pen style
+ 'marker'= 'circle' Marker shape
+ 'legend'= '' Line Legend to display
+ ================================ ================================
Marker Shapes:
- 'circle'
@@ -440,7 +440,7 @@ class PlotGraphics:
yLabel - label shown on y-axis
"""
if type(objects) not in [list,tuple]:
- raise TypeError, "objects argument should be list or tuple"
+ raise TypeError("objects argument should be list or tuple")
self.objects = objects
self.title= title
self.xLabel= xLabel
@@ -449,7 +449,7 @@ class PlotGraphics:
def setLogScale(self, logscale):
if type(logscale) != tuple:
- raise TypeError, 'logscale must be a tuple of bools, e.g. (False, False)'
+ raise TypeError('logscale must be a tuple of bools, e.g. (False, False)')
if len(self.objects) == 0:
return
for o in self.objects:
@@ -794,7 +794,7 @@ class PlotCanvas(wx.Panel):
def setLogScale(self, logscale):
if type(logscale) != tuple:
- raise TypeError, 'logscale must be a tuple of bools, e.g. (False, False)'
+ raise TypeError('logscale must be a tuple of bools, e.g. (False, False)')
if self.last_draw is not None:
graphics, xAxis, yAxis= self.last_draw
graphics.setLogScale(logscale)
@@ -833,7 +833,7 @@ class PlotCanvas(wx.Panel):
def SetShowScrollbars(self, value):
"""Set True to show scrollbars"""
if value not in [True,False]:
- raise TypeError, "Value should be True or False"
+ raise TypeError("Value should be True or False")
if value == self.GetShowScrollbars():
return
self.sb_vert.Show(value)
@@ -869,7 +869,7 @@ class PlotCanvas(wx.Panel):
def SetEnableDrag(self, value):
"""Set True to enable drag."""
if value not in [True,False]:
- raise TypeError, "Value should be True or False"
+ raise TypeError("Value should be True or False")
if value:
if self.GetEnableZoom():
self.SetEnableZoom(False)
@@ -884,7 +884,7 @@ class PlotCanvas(wx.Panel):
def SetEnableZoom(self, value):
"""Set True to enable zooming."""
if value not in [True,False]:
- raise TypeError, "Value should be True or False"
+ raise TypeError("Value should be True or False")
if value:
if self.GetEnableDrag():
self.SetEnableDrag(False)
@@ -900,7 +900,7 @@ class PlotCanvas(wx.Panel):
def SetEnableGrid(self, value):
"""Set True, 'Horizontal' or 'Vertical' to enable grid."""
if value not in [True,False,'Horizontal','Vertical']:
- raise TypeError, "Value should be True, False, Horizontal or Vertical"
+ raise TypeError("Value should be True, False, Horizontal or Vertical")
self._gridEnabled= value
self.Redraw()
@@ -911,7 +911,7 @@ class PlotCanvas(wx.Panel):
def SetEnableCenterLines(self, value):
"""Set True, 'Horizontal' or 'Vertical' to enable center line(s)."""
if value not in [True,False,'Horizontal','Vertical']:
- raise TypeError, "Value should be True, False, Horizontal or Vertical"
+ raise TypeError("Value should be True, False, Horizontal or Vertical")
self._centerLinesEnabled= value
self.Redraw()
@@ -923,7 +923,7 @@ class PlotCanvas(wx.Panel):
"""Set True, 'Bottomleft-Topright' or 'Bottomright-Topleft' to enable
center line(s)."""
if value not in [True,False,'Bottomleft-Topright','Bottomright-Topleft']:
- raise TypeError, "Value should be True, False, Bottomleft-Topright or Bottomright-Topleft"
+ raise TypeError("Value should be True, False, Bottomleft-Topright or Bottomright-Topleft")
self._diagonalsEnabled= value
self.Redraw()
@@ -934,7 +934,7 @@ class PlotCanvas(wx.Panel):
def SetEnableLegend(self, value):
"""Set True to enable legend."""
if value not in [True,False]:
- raise TypeError, "Value should be True or False"
+ raise TypeError("Value should be True or False")
self._legendEnabled= value
self.Redraw()
@@ -945,7 +945,7 @@ class PlotCanvas(wx.Panel):
def SetEnableTitle(self, value):
"""Set True to enable title."""
if value not in [True,False]:
- raise TypeError, "Value should be True or False"
+ raise TypeError("Value should be True or False")
self._titleEnabled= value
self.Redraw()
@@ -956,7 +956,7 @@ class PlotCanvas(wx.Panel):
def SetEnablePointLabel(self, value):
"""Set True to enable pointLabel."""
if value not in [True,False]:
- raise TypeError, "Value should be True or False"
+ raise TypeError("Value should be True or False")
self._pointLabelEnabled= value
self.Redraw() #will erase existing pointLabel if present
self.last_PointLabel = None
@@ -1106,9 +1106,9 @@ class PlotCanvas(wx.Panel):
# check Axis is either tuple or none
if type(xAxis) not in [type(None),tuple]:
- raise TypeError, "xAxis should be None or (minX,maxX)"+str(type(xAxis))
+ raise TypeError("xAxis should be None or (minX,maxX)"+str(type(xAxis)))
if type(yAxis) not in [type(None),tuple]:
- raise TypeError, "yAxis should be None or (minY,maxY)"+str(type(xAxis))
+ raise TypeError("yAxis should be None or (minY,maxY)"+str(type(xAxis)))
# check case for axis = (a,b) where a==b caused by improper zooms
if xAxis != None:
@@ -1136,7 +1136,7 @@ class PlotCanvas(wx.Panel):
if dc == None:
# sets new dc and clears it
dc = wx.BufferedDC(wx.ClientDC(self.canvas), self._Buffer)
- bbr = wx.Brush(self.GetBackgroundColour(), wx.SOLID)
+ bbr = wx.Brush(self.GetBackgroundColour(), wx.BRUSHSTYLE_SOLID)
dc.SetBackground(bbr)
dc.SetBackgroundMode(wx.SOLID)
dc.Clear()
@@ -1144,7 +1144,7 @@ class PlotCanvas(wx.Panel):
if not isinstance(dc, wx.GCDC):
try:
dc = wx.GCDC(dc)
- except Exception, exception:
+ except Exception:
pass
else:
if self._hiResEnabled:
@@ -1284,7 +1284,7 @@ class PlotCanvas(wx.Panel):
if self._antiAliasingEnabled:
try:
dc = wx.GCDC(dc)
- except Exception, exception:
+ except Exception:
pass
dc.SetTextForeground(self.GetForegroundColour())
dc.SetTextBackground(self.GetBackgroundColour())
@@ -1445,7 +1445,7 @@ class PlotCanvas(wx.Panel):
if self._antiAliasingEnabled:
try:
dc = wx.GCDC(dc)
- except Exception, exception:
+ except Exception:
pass
def OnSize(self,event):
@@ -1556,7 +1556,7 @@ class PlotCanvas(wx.Panel):
pnt2= (trhc[0]+legendLHS+legendSymExt[0], trhc[1]+s+lineHeight/2.)
o.draw(dc, self.printerScale, coord= _Numeric.array([pnt1,pnt2]))
else:
- raise TypeError, "object is neither PolyMarker or PolyLine instance"
+ raise TypeError("object is neither PolyMarker or PolyLine instance")
# draw legend txt
pnt= (trhc[0]+legendLHS+legendSymExt[0]+5*self._pointSize[0], trhc[1]+s+lineHeight/2.-legendTextExt[1]/2)
dc.DrawText(o.getLegend(),pnt[0],pnt[1])
@@ -1605,7 +1605,7 @@ class PlotCanvas(wx.Panel):
# draw rectangle
dc = wx.ClientDC( self.canvas )
dc.SetPen(wx.Pen(wx.BLACK))
- dc.SetBrush(wx.Brush( wx.WHITE, wx.TRANSPARENT ) )
+ dc.SetBrush(wx.Brush( wx.WHITE, wx.BRUSHSTYLE_TRANSPARENT ) )
dc.SetLogicalFunction(wx.INVERT)
dc.DrawRectangle( ptx,pty, rectWidth,rectHeight)
dc.SetLogicalFunction(wx.COPY)
@@ -1668,7 +1668,7 @@ class PlotCanvas(wx.Panel):
else:
return upper, lower
else:
- raise ValueError, str(spec) + ': illegal axis specification'
+ raise ValueError(str(spec) + ': illegal axis specification')
def _drawAxes(self, dc, p1, p2, scale, shift, xticks, yticks):
@@ -1807,10 +1807,10 @@ class PlotCanvas(wx.Panel):
format = '%+7.1e'
elif power >= 0:
digits = max(1, int(power))
- format = '%' + `digits`+'.0f'
+ format = '%' + repr(digits) + '.0f'
else:
digits = -int(power)
- format = '%'+`digits+2`+'.'+`digits`+'f'
+ format = '%' + repr(digits+2) + '.' + repr(digits) + 'f'
ticks = []
t = -grid*_Numeric.floor(-lower/grid)
while t <= upper:
@@ -1916,7 +1916,7 @@ class PlotPrintout(wx.Printout):
if self.graph._antiAliasingEnabled and not isinstance(dc, wx.GCDC):
try:
dc = wx.GCDC(dc)
- except Exception, exception:
+ except Exception:
pass
else:
if self.graph._hiResEnabled:
@@ -2031,13 +2031,13 @@ def _draw2Objects():
data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
data1.shape = (100, 2)
data1[:,1] = _Numeric.sin(data1[:,0])
- line1 = PolySpline(data1, legend='Green Line', colour='green', width=6, style=wx.DOT)
+ line1 = PolySpline(data1, legend='Green Line', colour='green', width=6, style=wx.PENSTYLE_DOT)
# 50 points cos function, plotted as red dot-dash
data1 = 2.*_Numeric.pi*_Numeric.arange(100)/100.
data1.shape = (50,2)
data1[:,1] = _Numeric.cos(data1[:,0])
- line2 = PolySpline(data1, legend='Red Line', colour='red', width=3, style= wx.DOT_DASH)
+ line2 = PolySpline(data1, legend='Red Line', colour='red', width=3, style= wx.PENSTYLE_DOT_DASH)
# A few more points...
pi = _Numeric.pi
@@ -2221,7 +2221,7 @@ class TestFrame(wx.Frame):
"""
# ----------
dc.SetPen(wx.Pen(wx.BLACK))
- dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
+ dc.SetBrush(wx.Brush( wx.BLACK, wx.BRUSHSTYLE_SOLID ) )
sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point
@@ -2279,7 +2279,7 @@ class TestFrame(wx.Frame):
def OnPlotDraw3(self, event):
self.resetDefaults()
- self.client.SetFont(wx.Font(10,wx.SCRIPT,wx.NORMAL,wx.NORMAL))
+ self.client.SetFont(wx.Font(10,wx.FONTFAMILY_SCRIPT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_NORMAL))
self.client.SetFontSizeAxis(20)
self.client.SetFontSizeLegend(12)
self.client.SetXSpec('min')
@@ -2392,7 +2392,7 @@ class TestFrame(wx.Frame):
def resetDefaults(self):
"""Just to reset the fonts back to the PlotCanvas defaults"""
- self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
+ self.client.SetFont(wx.Font(10,wx.FONTFAMILY_SWISS,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_NORMAL))
self.client.SetFontSizeAxis(10)
self.client.SetFontSizeLegend(7)
self.client.setLogScale((False,False))
diff --git a/wx/lib/popupctl.py b/wx/lib/popupctl.py
index 019e5010..efe99a78 100644
--- a/wx/lib/popupctl.py
+++ b/wx/lib/popupctl.py
@@ -149,7 +149,7 @@ class PopupDialog(wx.Dialog):
class PopupControl(wx.Control):
def __init__(self,*_args,**_kwargs):
- if _kwargs.has_key('value'):
+ if 'value' in _kwargs:
del _kwargs['value']
style = _kwargs.get('style', 0)
if (style & wx.BORDER_MASK) == 0:
diff --git a/wx/lib/printout.py b/wx/lib/printout.py
index 05aaf994..5b7ad7c6 100644
--- a/wx/lib/printout.py
+++ b/wx/lib/printout.py
@@ -31,20 +31,20 @@ class PrintBase(object):
def SetPrintFont(self, font): # set the DC font parameters
fattr = font["Attr"]
if fattr[0] == 1:
- weight = wx.BOLD
+ weight = wx.FONTWEIGHT_BOLD
else:
- weight = wx.NORMAL
+ weight = wx.FONTWEIGHT_NORMAL
if fattr[1] == 1:
- set_style = wx.ITALIC
+ set_style = wx.FONTSTYLE_ITALIC
else:
- set_style = wx.NORMAL
+ set_style = wx.FONTSTYLE_NORMAL
underline = fattr[2]
fcolour = self.GetFontColour(font)
self.DC.SetTextForeground(fcolour)
- setfont = wx.Font(font["Size"], wx.SWISS, set_style, weight, underline)
+ setfont = wx.Font(font["Size"], wx.FONTFAMILY_SWISS, set_style, weight, underline)
setfont.SetFaceName(font["Name"])
self.DC.SetFont(setfont)
@@ -354,7 +354,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
def SetPointAdjust(self):
- f = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) # setup using 10 point
+ f = wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) # setup using 10 point
self.DC.SetFont(f)
f.SetFaceName(self.text_font["Name"])
x, y = self.DC.GetTextExtent("W")
@@ -526,7 +526,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
def LabelColorRow(self, colour):
- brush = wx.Brush(colour, wx.SOLID)
+ brush = wx.Brush(colour, wx.BRUSHSTYLE_SOLID)
self.DC.SetBrush(brush)
height = self.label_space + self.label_pt_space_before + self.label_pt_space_after
self.DC.DrawRectangle(self.column[0], self.y,
@@ -542,7 +542,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
if cellcolour is not None:
colour = cellcolour
- brush = wx.Brush(colour, wx.SOLID)
+ brush = wx.Brush(colour, wx.BRUSHSTYLE_SOLID)
self.DC.SetBrush(brush)
self.DC.SetPen(wx.Pen(wx.WHITE, 0))
diff --git a/wx/lib/progressindicator.py b/wx/lib/progressindicator.py
index c3373688..1930ea29 100644
--- a/wx/lib/progressindicator.py
+++ b/wx/lib/progressindicator.py
@@ -42,7 +42,7 @@ class ProgressIndicator(wx.Panel):
self.Sizer.Add(self.gauge, 1, wx.EXPAND)
size = wx.DefaultSize
- if kw.has_key('size'):
+ if 'size' in kw:
size = kw['size']
elif len(args) >= 4:
size=args[3] # parent, id, pos, size, style, name
diff --git a/wx/lib/pydocview.py b/wx/lib/pydocview.py
index 839e3f84..50385363 100644
--- a/wx/lib/pydocview.py
+++ b/wx/lib/pydocview.py
@@ -824,7 +824,7 @@ class DocTabbedParentFrame(wx.Frame, DocFrameMixIn, DocMDIParentFrameMixIn):
icon.SetWidth(16)
if wx.GetApp().GetDebug():
print("Warning: icon for '%s' isn't 16x16, not crossplatform" % template._docTypeName)
- iconIndex = iconList.AddIcon(icon)
+ iconIndex = iconList.Add(icon)
self._iconIndexLookup.append((template, iconIndex))
icon = Blank.GetIcon()
@@ -833,7 +833,7 @@ class DocTabbedParentFrame(wx.Frame, DocFrameMixIn, DocMDIParentFrameMixIn):
icon.SetWidth(16)
if wx.GetApp().GetDebug():
print("Warning: getBlankIcon isn't 16x16, not crossplatform")
- self._blankIconIndex = iconList.AddIcon(icon)
+ self._blankIconIndex = iconList.Add(icon)
self._notebook.AssignImageList(iconList)
@@ -2174,7 +2174,7 @@ class DocApp(wx.PySimpleApp):
splash_bmp = image
else:
splash_bmp = wx.Image(image).ConvertToBitmap()
- self._splash = wx.SplashScreen(splash_bmp, wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_NO_TIMEOUT, 0, None, -1, style=wx.SIMPLE_BORDER|wx.FRAME_NO_TASKBAR)
+ self._splash = wx.adv.SplashScreen(splash_bmp, wx.adv.SPLASH_CENTRE_ON_SCREEN|wx.adv.SPLASH_NO_TIMEOUT, 0, None, -1, style=wx.SIMPLE_BORDER|wx.FRAME_NO_TASKBAR)
self._splash.Show()
diff --git a/wx/lib/rcsizer.py b/wx/lib/rcsizer.py
index 67419d07..3cdad739 100644
--- a/wx/lib/rcsizer.py
+++ b/wx/lib/rcsizer.py
@@ -34,6 +34,9 @@ encouraged to switch.
import operator
import wx
+import six
+if six.PY3:
+ from functools import reduce as reduce
# After the lib and demo no longer uses this sizer enable this warning...
diff --git a/wx/lib/rpcMixin.py b/wx/lib/rpcMixin.py
index db9d2cab..7407e0a2 100644
--- a/wx/lib/rpcMixin.py
+++ b/wx/lib/rpcMixin.py
@@ -74,350 +74,350 @@
"""
-import new
-import SocketServer
-import sys
-import threading
-import xmlrpclib
-import xmlrpcserver
+import new
+import SocketServer
+import sys
+import threading
+import xmlrpclib
+import xmlrpcserver
-import wx
+import wx
rpcPENDING = 0
rpcDONE = 1
rpcEXCEPT = 2
class RPCRequest:
- """A wrapper to use for handling requests and their responses"""
- status = rpcPENDING
- result = None
+ """A wrapper to use for handling requests and their responses"""
+ status = rpcPENDING
+ result = None
# here's the ID for external events
wxEVT_EXTERNAL_EVENT = wx.NewEventType()
EVT_EXTERNAL_EVENT = wx.PyEventBinder(wxEVT_EXTERNAL_EVENT, 0)
class ExternalEvent(wx.PyEvent):
- """The custom event class used to pass xmlrpc calls from
- the server thread into the GUI thread
+ """The custom event class used to pass xmlrpc calls from
+ the server thread into the GUI thread
- """
- def __init__(self,method,args):
- wx.PyEvent.__init__(self)
- self.SetEventType(wxEVT_EXTERNAL_EVENT)
- self.method = method
- self.args = args
- self.rpcStatus = RPCRequest()
- self.rpcStatusLock = threading.Lock()
- self.rpcCondVar = threading.Condition()
+ """
+ def __init__(self,method,args):
+ wx.PyEvent.__init__(self)
+ self.SetEventType(wxEVT_EXTERNAL_EVENT)
+ self.method = method
+ self.args = args
+ self.rpcStatus = RPCRequest()
+ self.rpcStatusLock = threading.Lock()
+ self.rpcCondVar = threading.Condition()
- def Destroy(self):
- self.method=None
- self.args=None
- self.rpcStatus = None
- self.rpcStatusLock = None
- self.rpcondVar = None
+ def Destroy(self):
+ self.method=None
+ self.args=None
+ self.rpcStatus = None
+ self.rpcStatusLock = None
+ self.rpcondVar = None
class Handler(xmlrpcserver.RequestHandler):
- """The handler class that the xmlrpcserver actually calls
- when a request comes in.
-
- """
- def log_message(self,*args):
- """ causes the server to stop spewing messages every time a request comes in
+ """The handler class that the xmlrpcserver actually calls
+ when a request comes in.
"""
- pass
- def call(self,method,params):
- """When an xmlrpc request comes in, this is the method that
- gets called.
+ def log_message(self,*args):
+ """ causes the server to stop spewing messages every time a request comes in
- **Arguments**
+ """
+ pass
+ def call(self,method,params):
+ """When an xmlrpc request comes in, this is the method that
+ gets called.
- - method: name of the method to be called
+ **Arguments**
- - params: arguments to that method
+ - method: name of the method to be called
- """
- if method == '_rpcPing':
- # we just acknowledge these without processing them
- return 'ack'
+ - params: arguments to that method
- # construct the event
- evt = ExternalEvent(method,params)
+ """
+ if method == '_rpcPing':
+ # we just acknowledge these without processing them
+ return 'ack'
- # update the status variable
- evt.rpcStatusLock.acquire()
- evt.rpcStatus.status = rpcPENDING
- evt.rpcStatusLock.release()
+ # construct the event
+ evt = ExternalEvent(method,params)
- evt.rpcCondVar.acquire()
- # dispatch the event to the GUI
- wx.PostEvent(self._app,evt)
+ # update the status variable
+ evt.rpcStatusLock.acquire()
+ evt.rpcStatus.status = rpcPENDING
+ evt.rpcStatusLock.release()
- # wait for the GUI to finish
- while evt.rpcStatus.status == rpcPENDING:
- evt.rpcCondVar.wait()
- evt.rpcCondVar.release()
- evt.rpcStatusLock.acquire()
- if evt.rpcStatus.status == rpcEXCEPT:
- # The GUI threw an exception, release the status lock
- # and re-raise the exception
- evt.rpcStatusLock.release()
- raise evt.rpcStatus.result[0],evt.rpcStatus.result[1]
- else:
- # everything went through without problems
- s = evt.rpcStatus.result
+ evt.rpcCondVar.acquire()
+ # dispatch the event to the GUI
+ wx.PostEvent(self._app,evt)
- evt.rpcStatusLock.release()
- evt.Destroy()
- self._app = None
- return s
+ # wait for the GUI to finish
+ while evt.rpcStatus.status == rpcPENDING:
+ evt.rpcCondVar.wait()
+ evt.rpcCondVar.release()
+ evt.rpcStatusLock.acquire()
+ if evt.rpcStatus.status == rpcEXCEPT:
+ # The GUI threw an exception, release the status lock
+ # and re-raise the exception
+ evt.rpcStatusLock.release()
+ raise evt.rpcStatus.result[0],evt.rpcStatus.result[1]
+ else:
+ # everything went through without problems
+ s = evt.rpcStatus.result
+
+ evt.rpcStatusLock.release()
+ evt.Destroy()
+ self._app = None
+ return s
# this global Event is used to let the server thread
-# know when it should quit
+# know when it should quit
stopEvent = threading.Event()
stopEvent.clear()
class _ServerThread(threading.Thread):
- """ this is the Thread class which actually runs the server
+ """ this is the Thread class which actually runs the server
- """
- def __init__(self,server,verbose=0):
- self._xmlServ = server
- threading.Thread.__init__(self,verbose=verbose)
+ """
+ def __init__(self,server,verbose=0):
+ self._xmlServ = server
+ threading.Thread.__init__(self,verbose=verbose)
- def stop(self):
- stopEvent.set()
+ def stop(self):
+ stopEvent.set()
- def shouldStop(self):
- return stopEvent.isSet()
+ def shouldStop(self):
+ return stopEvent.isSet()
- def run(self):
- while not self.shouldStop():
- self._xmlServ.handle_request()
- self._xmlServ = None
+ def run(self):
+ while not self.shouldStop():
+ self._xmlServ.handle_request()
+ self._xmlServ = None
class rpcMixin:
- """A mixin class to provide xmlrpc server functionality to wxPython
- frames/windows
+ """A mixin class to provide xmlrpc server functionality to wxPython
+ frames/windows
- If you want to customize this, probably the best idea is to
- override the OnExternal method, which is what's invoked when an
- RPC is handled.
-
- """
-
- # we'll try a range of ports for the server, this is the size of the
- # range to be scanned
- nPortsToTry=20
- if sys.platform == 'win32':
- defPort = 800
- else:
- defPort = 8023
-
- def __init__(self,host='',port=-1,verbose=0,portScan=1):
- """Constructor
-
- **Arguments**
-
- - host: (optional) the hostname for the server
-
- - port: (optional) the port the server will use
-
- - verbose: (optional) if set, the server thread will be launched
- in verbose mode
-
- - portScan: (optional) if set, we'll scan across a number of ports
- to find one which is avaiable
+ If you want to customize this, probably the best idea is to
+ override the OnExternal method, which is what's invoked when an
+ RPC is handled.
"""
- if port == -1:
- port = self.defPort
- self.verbose=verbose
- self.Bind(EVT_EXTERNAL_EVENT,self.OnExternal)
- if hasattr(self,'OnClose'):
- self._origOnClose = self.OnClose
- self.Disconnect(-1,-1,wx.EVT_CLOSE_WINDOW)
- else:
- self._origOnClose = None
- self.OnClose = self.RPCOnClose
- self.Bind(wx.EVT_CLOSE,self.RPCOnClose)
- tClass = new.classobj('Handler%d'%(port),(Handler,),{})
- tClass._app = self
- if portScan:
- self.rpcPort = -1
- for i in xrange(self.nPortsToTry):
+ # we'll try a range of ports for the server, this is the size of the
+ # range to be scanned
+ nPortsToTry=20
+ if sys.platform == 'win32':
+ defPort = 800
+ else:
+ defPort = 8023
+
+ def __init__(self,host='',port=-1,verbose=0,portScan=1):
+ """Constructor
+
+ **Arguments**
+
+ - host: (optional) the hostname for the server
+
+ - port: (optional) the port the server will use
+
+ - verbose: (optional) if set, the server thread will be launched
+ in verbose mode
+
+ - portScan: (optional) if set, we'll scan across a number of ports
+ to find one which is avaiable
+
+ """
+ if port == -1:
+ port = self.defPort
+ self.verbose=verbose
+ self.Bind(EVT_EXTERNAL_EVENT,self.OnExternal)
+ if hasattr(self,'OnClose'):
+ self._origOnClose = self.OnClose
+ self.Disconnect(-1,-1,wx.EVT_CLOSE_WINDOW)
+ else:
+ self._origOnClose = None
+ self.OnClose = self.RPCOnClose
+ self.Bind(wx.EVT_CLOSE,self.RPCOnClose)
+
+ tClass = new.classobj('Handler%d'%(port),(Handler,),{})
+ tClass._app = self
+ if portScan:
+ self.rpcPort = -1
+ for i in xrange(self.nPortsToTry):
+ try:
+ xmlServ = SocketServer.TCPServer((host,port+i),tClass)
+ except Exception:
+ pass
+ else:
+ self.rpcPort = port+i
+ else:
+ self.rpcPort = port
+ try:
+ xmlServ = SocketServer.TCPServer((host,port),tClass)
+ except:
+ self.rpcPort = -1
+
+ if self.rpcPort == -1:
+ raise 'RPCMixinError','Cannot initialize server'
+ self.servThread = _ServerThread(xmlServ,verbose=self.verbose)
+ self.servThread.setName('XML-RPC Server')
+ self.servThread.start()
+
+ def RPCOnClose(self,event):
+ """ callback for when the application is closed
+
+ be sure to shutdown the server and the server thread before
+ leaving
+
+ """
+ # by setting the global stopEvent we inform the server thread
+ # that it's time to shut down.
+ stopEvent.set()
+ if event is not None:
+ # if we came in here from a user event (as opposed to an RPC event),
+ # then we'll need to kick the server one last time in order
+ # to get that thread to terminate. do so now
+ s1 = xmlrpclib.Server('http://localhost:%d'%(self.rpcPort))
+ try:
+ s1._rpcPing()
+ except Exception:
+ pass
+
+ if self._origOnClose is not None:
+ self._origOnClose(event)
+
+ def RPCQuit(self):
+ """ shuts down everything, including the rpc server
+
+ """
+ self.RPCOnClose(None)
+ def OnExternal(self,event):
+ """ this is the callback used to handle RPCs
+
+ **Arguments**
+
+ - event: an _ExternalEvent_ sent by the rpc server
+
+ Exceptions are caught and returned in the global _rpcStatus
+ structure. This allows the xmlrpc server to report the
+ exception to the client without mucking up any of the delicate
+ thread stuff.
+
+ """
+ event.rpcStatusLock.acquire()
+ doQuit = 0
try:
- xmlServ = SocketServer.TCPServer((host,port+i),tClass)
- except:
- pass
+ methsplit = event.method.split('.')
+ meth = self
+ for piece in methsplit:
+ meth = getattr(meth,piece)
+ except AttributeError as exc:
+ event.rpcStatus.result = 'No Such Method', exc
+ event.rpcStatus.status = rpcEXCEPT
else:
- self.rpcPort = port+i
- else:
- self.rpcPort = port
- try:
- xmlServ = SocketServer.TCPServer((host,port),tClass)
- except:
- self.rpcPort = -1
+ try:
+ res = meth(event.args)
+ except:
+ import traceback
+ if self.verbose: traceback.print_exc()
+ event.rpcStatus.result = sys.exc_info()[:2]
+ event.rpcStatus.status = rpcEXCEPT
+ else:
+ if res is None:
+ # returning None across the xmlrpc interface is problematic
+ event.rpcStatus.result = []
+ else:
+ event.rpcStatus.result = res
+ event.rpcStatus.status = rpcDONE
- if self.rpcPort == -1:
- raise 'RPCMixinError','Cannot initialize server'
- self.servThread = _ServerThread(xmlServ,verbose=self.verbose)
- self.servThread.setName('XML-RPC Server')
- self.servThread.start()
+ event.rpcStatusLock.release()
- def RPCOnClose(self,event):
- """ callback for when the application is closed
-
- be sure to shutdown the server and the server thread before
- leaving
-
- """
- # by setting the global stopEvent we inform the server thread
- # that it's time to shut down.
- stopEvent.set()
- if event is not None:
- # if we came in here from a user event (as opposed to an RPC event),
- # then we'll need to kick the server one last time in order
- # to get that thread to terminate. do so now
- s1 = xmlrpclib.Server('http://localhost:%d'%(self.rpcPort))
- try:
- s1._rpcPing()
- except:
- pass
-
- if self._origOnClose is not None:
- self._origOnClose(event)
-
- def RPCQuit(self):
- """ shuts down everything, including the rpc server
-
- """
- self.RPCOnClose(None)
- def OnExternal(self,event):
- """ this is the callback used to handle RPCs
-
- **Arguments**
-
- - event: an _ExternalEvent_ sent by the rpc server
-
- Exceptions are caught and returned in the global _rpcStatus
- structure. This allows the xmlrpc server to report the
- exception to the client without mucking up any of the delicate
- thread stuff.
-
- """
- event.rpcStatusLock.acquire()
- doQuit = 0
- try:
- methsplit = event.method.split('.')
- meth = self
- for piece in methsplit:
- meth = getattr(meth,piece)
- except AttributeError,msg:
- event.rpcStatus.result = 'No Such Method',msg
- event.rpcStatus.status = rpcEXCEPT
- else:
- try:
- res = apply(meth,event.args)
- except:
- import traceback
- if self.verbose: traceback.print_exc()
- event.rpcStatus.result = sys.exc_info()[:2]
- event.rpcStatus.status = rpcEXCEPT
- else:
- if res is None:
- # returning None across the xmlrpc interface is problematic
- event.rpcStatus.result = []
- else:
- event.rpcStatus.result = res
- event.rpcStatus.status = rpcDONE
-
- event.rpcStatusLock.release()
-
- # broadcast (using the condition var) that we're done with the event
- event.rpcCondVar.acquire()
- event.rpcCondVar.notify()
- event.rpcCondVar.release()
+ # broadcast (using the condition var) that we're done with the event
+ event.rpcCondVar.acquire()
+ event.rpcCondVar.notify()
+ event.rpcCondVar.release()
if __name__ == '__main__':
- import time
- if sys.platform == 'win32':
- port = 800
- else:
- port = 8023
+ import time
+ if sys.platform == 'win32':
+ port = 800
+ else:
+ port = 8023
- class rpcFrame(wx.Frame,rpcMixin):
- """A simple wxFrame with the rpcMixin functionality added
- """
- def __init__(self,*args,**kwargs):
- """ rpcHost or rpcPort keyword arguments will be passed along to
- the xmlrpc server.
- """
- mixinArgs = {}
- if kwargs.has_key('rpcHost'):
- mixinArgs['host'] = kwargs['rpcHost']
- del kwargs['rpcHost']
- if kwargs.has_key('rpcPort'):
- mixinArgs['port'] = kwargs['rpcPort']
- del kwargs['rpcPort']
- if kwargs.has_key('rpcPortScan'):
- mixinArgs['portScan'] = kwargs['rpcPortScan']
- del kwargs['rpcPortScan']
+ class rpcFrame(wx.Frame,rpcMixin):
+ """A simple wxFrame with the rpcMixin functionality added
+ """
+ def __init__(self,*args,**kwargs):
+ """ rpcHost or rpcPort keyword arguments will be passed along to
+ the xmlrpc server.
+ """
+ mixinArgs = {}
+ if 'rpcHost' in kwargs:
+ mixinArgs['host'] = kwargs['rpcHost']
+ del kwargs['rpcHost']
+ if 'rpcPort' in kwargs:
+ mixinArgs['port'] = kwargs['rpcPort']
+ del kwargs['rpcPort']
+ if 'rpcPortScan' in kwargs:
+ mixinArgs['portScan'] = kwargs['rpcPortScan']
+ del kwargs['rpcPortScan']
- apply(wx.Frame.__init__,(self,)+args,kwargs)
- apply(rpcMixin.__init__,(self,),mixinArgs)
+ wx.Frame.__init__(self, *args, **kwargs)
+ rpcMixin.__init__(self, mixinArgs)
- self.Bind(wx.EVT_CHAR,self.OnChar)
+ self.Bind(wx.EVT_CHAR,self.OnChar)
- def TestFunc(self,args):
- """a demo method"""
- return args
+ def TestFunc(self,args):
+ """a demo method"""
+ return args
- def OnChar(self,event):
- key = event.GetKeyCode()
- if key == ord('q'):
- self.OnQuit(event)
+ def OnChar(self,event):
+ key = event.GetKeyCode()
+ if key == ord('q'):
+ self.OnQuit(event)
- def OnQuit(self,event):
- self.OnClose(event)
+ def OnQuit(self,event):
+ self.OnClose(event)
- def OnClose(self,event):
- self.Destroy()
+ def OnClose(self,event):
+ self.Destroy()
- class MyApp(wx.App):
- def OnInit(self):
- self.frame = rpcFrame(None, -1, "wxPython RPCDemo", wx.DefaultPosition,
- (300,300), rpcHost='localhost',rpcPort=port)
- self.frame.Show(True)
- return True
+ class MyApp(wx.App):
+ def OnInit(self):
+ self.frame = rpcFrame(None, -1, "wxPython RPCDemo", wx.DefaultPosition,
+ (300,300), rpcHost='localhost',rpcPort=port)
+ self.frame.Show(True)
+ return True
- def testcon(port):
- s1 = xmlrpclib.Server('http://localhost:%d'%(port))
- s1.SetTitle('Munged')
- s1._rpcPing()
- if doQuit:
- s1.RPCQuit()
+ def testcon(port):
+ s1 = xmlrpclib.Server('http://localhost:%d'%(port))
+ s1.SetTitle('Munged')
+ s1._rpcPing()
+ if doQuit:
+ s1.RPCQuit()
- doQuit = 1
- if len(sys.argv)>1 and sys.argv[1] == '-q':
- doQuit = 0
- nT = threading.activeCount()
- app = MyApp(0)
- activePort = app.frame.rpcPort
- t = threading.Thread(target=lambda x=activePort:testcon(x),verbose=0)
- t.start()
+ doQuit = 1
+ if len(sys.argv)>1 and sys.argv[1] == '-q':
+ doQuit = 0
+ nT = threading.activeCount()
+ app = MyApp(0)
+ activePort = app.frame.rpcPort
+ t = threading.Thread(target=lambda x=activePort:testcon(x),verbose=0)
+ t.start()
- app.MainLoop()
- # give the threads time to shut down
- if threading.activeCount() > nT:
- print('waiting for all threads to terminate')
- while threading.activeCount() > nT:
- time.sleep(0.5)
+ app.MainLoop()
+ # give the threads time to shut down
+ if threading.activeCount() > nT:
+ print('waiting for all threads to terminate')
+ while threading.activeCount() > nT:
+ time.sleep(0.5)
diff --git a/wx/lib/sized_controls.py b/wx/lib/sized_controls.py
index 2127f7ad..e747d1bf 100644
--- a/wx/lib/sized_controls.py
+++ b/wx/lib/sized_controls.py
@@ -93,12 +93,12 @@ minsize = { "fixed": wx.FIXED_MINSIZE,
misc_flags = { "expand": wx.EXPAND, }
-class TableSizer(wx.PySizer):
+class TableSizer(wx.Sizer):
"""
An attempt at creating a more intuitive replacement for nesting box sizers.
"""
def __init__(self, rows=0, cols=0):
- wx.PySizer.__init__(self)
+ wx.Sizer.__init__(self)
self.rows = rows
self.cols = cols
self.fixed_width = 0
@@ -658,37 +658,37 @@ class SizedParent:
elif type == "table":
rows = cols = 0
- if options.has_key('rows'):
+ if 'rows' in options:
rows = int(options['rows'])
- if options.has_key('cols'):
+ if 'cols' in options:
cols = int(options['cols'])
sizer = TableSizer(rows, cols)
elif type == "grid":
sizer = wx.FlexGridSizer(0, 0, 0, 0)
- if options.has_key('rows'):
+ if 'rows' in options:
sizer.SetRows(int(options['rows']))
else:
sizer.SetRows(0)
- if options.has_key('cols'):
+ if 'cols' in options:
sizer.SetCols(int(options['cols']))
else:
sizer.SetCols(0)
- if options.has_key('growable_row'):
+ if 'growable_row' in options:
row, proportion = options['growable_row']
sizer.SetGrowableRow(row, proportion)
- if options.has_key('growable_col'):
+ if 'growable_col' in options:
col, proportion = options['growable_col']
sizer.SetGrowableCol(col, proportion)
- if options.has_key('hgap'):
+ if 'hgap' in options:
sizer.SetHGap(options['hgap'])
- if options.has_key('vgap'):
+ if 'vgap' in options:
sizer.SetVGap(options['vgap'])
if sizer:
self._SetNewSizer(sizer)
@@ -759,12 +759,7 @@ class SizedPanel(wx.Panel, SizedParent):
"""
Called automatically by wx, do not call it from user code.
"""
-
- if wx.VERSION < (2,8):
- wx.PyPanel.base_AddChild(self, child)
- else:
- wx.Panel.AddChild(self, child)
-
+ wx.Panel.AddChild(self, child)
SizedParent.AddChild(self, child)
def _SetNewSizer(self, sizer):
@@ -773,10 +768,7 @@ class SizedPanel(wx.Panel, SizedParent):
to new sizer.
"""
props = self._DetachFromSizer(sizer)
- if wx.VERSION < (2,8):
- wx.PyPanel.SetSizer(self, sizer)
- else:
- wx.Panel.SetSizer(self, sizer)
+ wx.Panel.SetSizer(self, sizer)
self._AddToNewSizer(sizer, props)
@@ -812,12 +804,7 @@ class SizedScrolledPanel(sp.ScrolledPanel, SizedParent):
:param `child`: child (window or another sizer) to be added to sizer.
"""
-
- if wx.VERSION < (2,8):
- sp.ScrolledPanel.base_AddChild(self, child)
- else:
- sp.ScrolledPanel.AddChild(self, child)
-
+ sp.ScrolledPanel.AddChild(self, child)
SizedParent.AddChild(self, child)
def _SetNewSizer(self, sizer):
diff --git a/wx/lib/splitter.py b/wx/lib/splitter.py
index f3520279..9da348b7 100644
--- a/wx/lib/splitter.py
+++ b/wx/lib/splitter.py
@@ -83,7 +83,7 @@ class MultiSplitterWindow(wx.Panel):
self._minimumPaneSize = 0
self._sashCursorWE = wx.Cursor(wx.CURSOR_SIZEWE)
self._sashCursorNS = wx.Cursor(wx.CURSOR_SIZENS)
- self._sashTrackerPen = wx.Pen(wx.BLACK, 2, wx.SOLID)
+ self._sashTrackerPen = wx.Pen(wx.BLACK, 2, wx.PENSTYLE_SOLID)
self._needUpdating = False
self._isHot = False
self._drawSashInBackgroundColour = False
diff --git a/wx/lib/stattext.py b/wx/lib/stattext.py
index b61424ec..205aad86 100644
--- a/wx/lib/stattext.py
+++ b/wx/lib/stattext.py
@@ -274,7 +274,7 @@ class GenStaticText(wx.Control):
themeColour = wx.MacThemeColour(kThemeBrushDialogBackgroundActive)
backBrush = wx.Brush(themeColour)
else:
- backBrush = wx.Brush(clr, wx.SOLID)
+ backBrush = wx.Brush(clr, wx.BRUSHSTYLE_SOLID)
dc.SetBackground(backBrush)
dc.Clear()
diff --git a/wx/lib/wordwrap.py b/wx/lib/wordwrap.py
index 26a2d69e..7cf12b3b 100644
--- a/wx/lib/wordwrap.py
+++ b/wx/lib/wordwrap.py
@@ -77,7 +77,7 @@ if __name__ == '__main__':
mdc.SetBackground(wx.Brush("white"))
mdc.Clear()
mdc.SetPen(wx.Pen("black"))
- mdc.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
+ mdc.SetFont(wx.Font(10, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
mdc.DrawRectangle(0,0, WIDTH, HEIGHT)
text = wordwrap(self.tc.GetValue(), WIDTH-2, mdc, False)
diff --git a/wx/lib/wxpTag.py b/wx/lib/wxpTag.py
index 532d78c3..a7ec03cf 100644
--- a/wx/lib/wxpTag.py
+++ b/wx/lib/wxpTag.py
@@ -105,7 +105,7 @@ class wxpTagHandler(wx.html.HtmlWinTagHandler):
def __init__(self):
wx.html.HtmlWinTagHandler.__init__(self)
self.ctx = None
-
+
def GetSupportedTags(self):
return WXPTAG+','+PARAMTAG
@@ -118,7 +118,7 @@ class wxpTagHandler(wx.html.HtmlWinTagHandler):
elif name == PARAMTAG:
return self.HandleParamTag(tag)
else:
- raise ValueError, 'unknown tag: ' + name
+ raise ValueError('unknown tag: ' + name)
def HandleWxpTag(self, tag):
@@ -136,12 +136,12 @@ class wxpTagHandler(wx.html.HtmlWinTagHandler):
# find and verify the class
if not tag.HasParam('CLASS'):
- raise AttributeError, "WXP tag requires a CLASS attribute"
+ raise AttributeError("WXP tag requires a CLASS attribute")
className = tag.GetParam('CLASS')
self.ctx.classObj = getattr(self.ctx.classMod, className)
#if type(self.ctx.classObj) not in [ types.ClassType, types.TypeType]:
- # raise TypeError, "WXP tag attribute CLASS must name a class"
+ # raise TypeError("WXP tag attribute CLASS must name a class")
# now look for width and height
width = -1
@@ -162,7 +162,7 @@ class wxpTagHandler(wx.html.HtmlWinTagHandler):
# create the object
parent = self.GetParser().GetWindowInterface().GetHTMLWindow()
-
+
if parent:
obj = self.ctx.classObj(parent, **self.ctx.kwargs)
obj.Show(True)