diff --git a/demo/ListCtrl.py b/demo/ListCtrl.py index 8c25ca68..757ff49d 100644 --- a/demo/ListCtrl.py +++ b/demo/ListCtrl.py @@ -183,7 +183,7 @@ class TestListCtrlPanel(wx.Panel, listmix.ColumnSorterMixin): items = musicdata.items() for key, data in items: - index = self.list.InsertItem(sys.maxint, data[0], self.idx1) + index = self.list.InsertItem(sys.maxsize, data[0], self.idx1) self.list.SetItem(index, 1, data[1]) self.list.SetItem(index, 2, data[2]) self.list.SetItemData(index, key) diff --git a/demo/agw/GenericMessageDialog.py b/demo/agw/GenericMessageDialog.py index 4b3800d8..a0ba3c67 100644 --- a/demo/agw/GenericMessageDialog.py +++ b/demo/agw/GenericMessageDialog.py @@ -32,7 +32,7 @@ _msg = "This is the about dialog of GenericMessageDialog demo.\n\n" + \ ART_ICONS = [] for d in dir(wx): if d.startswith('ART_'): - if not eval('wx.%s'%d).endswith('_C'): + if not eval('wx.%s'%d).endswith(b'_C'): ART_ICONS.append(eval('wx.%s'%d)) diff --git a/demo/agw/PeakMeter.py b/demo/agw/PeakMeter.py index edac56fc..a7c9a6f5 100644 --- a/demo/agw/PeakMeter.py +++ b/demo/agw/PeakMeter.py @@ -129,7 +129,7 @@ class PeakMeterCtrlDemo(wx.Panel): nElements = 15 arrayData = [] - for i in xrange(nElements): + for i in range(nElements): nRandom = random.randint(0, 100) arrayData.append(nRandom) diff --git a/demo/agw/PersistentControls.py b/demo/agw/PersistentControls.py index b9e356f0..f19cc4a9 100644 --- a/demo/agw/PersistentControls.py +++ b/demo/agw/PersistentControls.py @@ -7,6 +7,8 @@ import sys import images import random +import wx.dataview as dv + from wx.lib.expando import ExpandoTextCtrl import wx.lib.agw.aui as AUI import wx.lib.agw.floatspin as FS @@ -446,19 +448,19 @@ class PersistentFrame2(wx.Frame): il.Add(images.Smiles.GetBitmap()) listCtrl = wx.ListCtrl(self.notebook, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER, name="ListCtrl1") - for col in xrange(6): + for col in range(6): listCtrl.InsertColumn(col, "Column %d"%col) listCtrl.AssignImageList(il, wx.IMAGE_LIST_SMALL) text = "Row: %d, Col: %d" - for row in xrange(30): + for row in range(30): if random.randint(0, 1): - idx = listCtrl.InsertImageStringItem(sys.maxint, text%(row+1, 1), 0) + idx = listCtrl.InsertItem(sys.maxsize, text%(row+1, 1), 0) else: - idx = listCtrl.InsertStringItem(sys.maxint, text%(row+1, 1)) + idx = listCtrl.InsertItem(sys.maxsize, text%(row+1, 1)) - for col in xrange(1, 6): - listCtrl.SetStringItem(idx, col, text%(row+1, col+1), random.randint(0, 1)-1) + for col in range(1, 6): + listCtrl.SetItem(idx, col, text%(row+1, col+1), random.randint(0, 1)-1) return listCtrl @@ -466,7 +468,7 @@ class PersistentFrame2(wx.Frame): def CreateTreeListCtrl(self, isTreeList): if isTreeList: - treeList = wx.adv.TreeListCtrl(self.notebook, style=wx.TR_DEFAULT_STYLE|wx.TR_FULL_ROW_HIGHLIGHT| + treeList = dv.TreeListCtrl(self.notebook, style=wx.TR_DEFAULT_STYLE|wx.TR_FULL_ROW_HIGHLIGHT| wx.SUNKEN_BORDER|wx.TR_MULTIPLE, name="TreeList1") else: treeList = wx.TreeCtrl(self.split1, style=wx.TR_DEFAULT_STYLE|wx.SUNKEN_BORDER|wx.TR_MULTIPLE, @@ -487,7 +489,7 @@ class PersistentFrame2(wx.Frame): treeList.SetColumnWidth(0, 175) if isTreeList: - root = treeList.InsertItem(treeList.GetRootItem(), wx.adv.TLI_FIRST, "The Root Item") + root = treeList.InsertItem(treeList.GetRootItem(), dv.TLI_FIRST, "The Root Item") else: root = treeList.AddRoot("The Root Item") diff --git a/unittests/test_lib_agw_floatspin.py b/unittests/test_lib_agw_floatspin.py index a6f56954..886429cf 100644 --- a/unittests/test_lib_agw_floatspin.py +++ b/unittests/test_lib_agw_floatspin.py @@ -51,6 +51,22 @@ class lib_agw_floatspin_Tests(wtc.WidgetTestCase): def test_lib_agw_floatspinEvents(self): FS.EVT_FLOATSPIN FS.wxEVT_FLOATSPIN + + def test_lib_agw_floatspin_fixedpoint(self): + f1 = FS.FixedPoint(20) + f2 = FS.FixedPoint(30) + f3 = FS.FixedPoint("20", 20) + f4 = FS.FixedPoint("20", 20) + + self.assertEqual(f1, 20) + self.assertEqual(f2, 30) + self.assertEqual(f3, f4) + self.assertGreaterEqual(f2, f1) + self.assertGreaterEqual(f2, 20) + self.assertGreater(f2, 20) + self.assertLessEqual(f1, f2) + self.assertLessEqual(f1, 30) + self.assertLess(f1, 30) #--------------------------------------------------------------------------- diff --git a/unittests/test_lib_agw_persist_persistencemanager.py b/unittests/test_lib_agw_persist_persistencemanager.py new file mode 100644 index 00000000..f4877c9f --- /dev/null +++ b/unittests/test_lib_agw_persist_persistencemanager.py @@ -0,0 +1,36 @@ +import imp_unittest, unittest +import wtc +import wx +import random + +import os +import wx.lib.agw.persist as PM + +#--------------------------------------------------------------------------- + +class lib_agw_persist_persistencemanager_Tests(wtc.WidgetTestCase): + + def test_lib_agw_persist_persistencemanagerCtor(self): + + self._persistMgr = PM.PersistenceManager.Get() + + dirName = os.path.abspath(__file__) + _configFile1 = os.path.join(dirName, "PersistTest1") + self._persistMgr.SetPersistenceFile(_configFile1) + + # give the frame a Name for below + self.frame.SetName('PersistTestFrame') + + self._persistMgr.RegisterAndRestoreAll(self.frame) + + + def test_lib_agw_persist_persistencemanagerConstantsExist(self): + PM.PM_SAVE_RESTORE_AUI_PERSPECTIVES + PM.PM_SAVE_RESTORE_TREE_LIST_SELECTIONS + PM.PM_PERSIST_CONTROL_VALUE + PM.PM_RESTORE_CAPTION_FROM_CODE + PM.PM_DEFAULT_STYLE +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main() diff --git a/wx/lib/agw/floatspin.py b/wx/lib/agw/floatspin.py index 82aebf32..675c91a8 100644 --- a/wx/lib/agw/floatspin.py +++ b/wx/lib/agw/floatspin.py @@ -1472,14 +1472,23 @@ class FixedPoint(object): __copy__ = __deepcopy__ = copy - - def __cmp__(self, other): - + def __eq__(self, other): if (other == None): - return 1 + return False xn, yn, p = _norm(self, other) - return _cmp(xn, yn) + return not _cmp(xn, yn) + def __ge__(self, other): + if other is None: + return False + xn, yn, p = _norm(self, other) + return xn >= yn + + def __le__(self, other): + if other is None: + return False + xn, yn, p = _norm(self, other) + return xn <= yn def __hash__(self): # caution! == values must have equal hashes, and a FixedPoint diff --git a/wx/lib/agw/foldpanelbar.py b/wx/lib/agw/foldpanelbar.py index 2f47d0a7..4808929b 100644 --- a/wx/lib/agw/foldpanelbar.py +++ b/wx/lib/agw/foldpanelbar.py @@ -53,7 +53,7 @@ # # Or, Obviously, To The wxPython Mailing List!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------- # diff --git a/wx/lib/agw/fourwaysplitter.py b/wx/lib/agw/fourwaysplitter.py index 81c5f517..048d7eda 100644 --- a/wx/lib/agw/fourwaysplitter.py +++ b/wx/lib/agw/fourwaysplitter.py @@ -17,7 +17,7 @@ # # Or, Obviously, To The wxPython Mailing List!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/genericmessagedialog.py b/wx/lib/agw/genericmessagedialog.py index a121180d..2b55908a 100644 --- a/wx/lib/agw/genericmessagedialog.py +++ b/wx/lib/agw/genericmessagedialog.py @@ -18,7 +18,7 @@ # # Or, obviously, to the wxPython mailing list!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/gradientbutton.py b/wx/lib/agw/gradientbutton.py index 43efd4d0..41a5065b 100644 --- a/wx/lib/agw/gradientbutton.py +++ b/wx/lib/agw/gradientbutton.py @@ -18,7 +18,7 @@ # # Or, obviously, to the wxPython mailing list!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/hyperlink.py b/wx/lib/agw/hyperlink.py index f6572c37..c05edec6 100644 --- a/wx/lib/agw/hyperlink.py +++ b/wx/lib/agw/hyperlink.py @@ -21,7 +21,7 @@ # # Or, obviously, to the wxPython mailing list!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------- # diff --git a/wx/lib/agw/hypertreelist.py b/wx/lib/agw/hypertreelist.py index 43666ecb..fd6ad5fa 100644 --- a/wx/lib/agw/hypertreelist.py +++ b/wx/lib/agw/hypertreelist.py @@ -35,7 +35,7 @@ # # Or, Obviously, To The wxPython Mailing List!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/infobar.py b/wx/lib/agw/infobar.py index ca9aca56..ae018208 100644 --- a/wx/lib/agw/infobar.py +++ b/wx/lib/agw/infobar.py @@ -21,7 +21,7 @@ # # Or, Obviously, To The wxPython Mailing List!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------- # diff --git a/wx/lib/agw/knobctrl.py b/wx/lib/agw/knobctrl.py index efdad064..e79b1cdf 100644 --- a/wx/lib/agw/knobctrl.py +++ b/wx/lib/agw/knobctrl.py @@ -17,7 +17,7 @@ # # Or, Obviously, To The wxPython Mailing List!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/labelbook.py b/wx/lib/agw/labelbook.py index 4053040e..93833c5f 100644 --- a/wx/lib/agw/labelbook.py +++ b/wx/lib/agw/labelbook.py @@ -27,7 +27,7 @@ # between the controls and the pages so the background # colour can flow into the window background # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # # End Of Comments diff --git a/wx/lib/agw/multidirdialog.py b/wx/lib/agw/multidirdialog.py index 4da44165..dd7ebf9c 100644 --- a/wx/lib/agw/multidirdialog.py +++ b/wx/lib/agw/multidirdialog.py @@ -21,7 +21,7 @@ # # Or, obviously, to the wxPython mailing list!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/peakmeter.py b/wx/lib/agw/peakmeter.py index de3b829f..cb0d6839 100644 --- a/wx/lib/agw/peakmeter.py +++ b/wx/lib/agw/peakmeter.py @@ -20,7 +20,7 @@ # # Or, obviously, to the wxPython mailing list!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------------- # diff --git a/wx/lib/agw/persist/persist_constants.py b/wx/lib/agw/persist/persist_constants.py index 3c77145c..4deb78ba 100644 --- a/wx/lib/agw/persist/persist_constants.py +++ b/wx/lib/agw/persist/persist_constants.py @@ -3,6 +3,8 @@ This module contains all the constants used by the persistent objects. """ import wx +import wx.dataview as dv +import wx.lib.six as six # ----------------------------------------------------------------------------------- # # PersistenceManager styles @@ -17,12 +19,23 @@ PM_DEFAULT_STYLE = PM_SAVE_RESTORE_AUI_PERSPECTIVES | PM_PER CONFIG_PATH_SEPARATOR = "/" BAD_DEFAULT_NAMES = ["widget", "wxSpinButton", "auiFloating", "AuiTabCtrl", "maskedTextCtrl", - "numctrl", "IpAddrCtrl", "masked.num", "time", "scrolledpanel", "cPanel"] + "numctrl", "IpAddrCtrl", "masked.num", "time", "scrolledpanel", "cPanel", + "wxdataviewctrlmainwindow"] for name in dir(wx): if "NameStr" in name: - BAD_DEFAULT_NAMES.append(eval("wx.%s"%name)) + val = getattr(wx, name) + if six.PY3 and isinstance(val, bytes): + val = val.decode('utf-8') + BAD_DEFAULT_NAMES.append(val) +for name in dir(dv): + if "NameStr" in name: + val = getattr(dv, name) + if six.PY3 and isinstance(val, bytes): + val = val.decode('utf-8') + BAD_DEFAULT_NAMES.append(val) + # ----------------------------------------------------------------------------------- # # String constants used by BookHandler diff --git a/wx/lib/agw/persist/persist_handlers.py b/wx/lib/agw/persist/persist_handlers.py index 8b77fac6..08c26b2b 100644 --- a/wx/lib/agw/persist/persist_handlers.py +++ b/wx/lib/agw/persist/persist_handlers.py @@ -11,6 +11,9 @@ import datetime import wx.adv import wx.html +# use this instead of wx.gizmos.TreeListCtrl +import wx.dataview as dv + # Will likely not be wrapped # import wx.aui @@ -47,8 +50,6 @@ except: import wx.lib.agw.ultimatelistctrl as ULC -import persistencemanager as PM - from .persist_constants import * @@ -120,6 +121,9 @@ class AbstractHandler(object): self._pObject = pObject self._window = pObject.GetWindow() + # need to move the import to here, otherwise we error in Python 3 + from . import persistencemanager as PM + self._manager = PM.PersistenceManager.Get() def Save(self): """ @@ -184,8 +188,7 @@ class BookHandler(AbstractHandler): obj.SaveValue(PERSIST_BOOK_SELECTION, book.GetSelection()) if issubclass(book.__class__, AUI.AuiNotebook): - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: # Allowed to save and restore perspectives perspective = book.SavePerspective() obj.SaveValue(PERSIST_BOOK_AGW_AUI_PERSPECTIVE, perspective) @@ -198,8 +201,7 @@ class BookHandler(AbstractHandler): retVal = True if issubclass(book.__class__, AUI.AuiNotebook): - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: retVal = False # Allowed to save and restore perspectives perspective = obj.RestoreValue(PERSIST_BOOK_AGW_AUI_PERSPECTIVE) @@ -298,8 +300,7 @@ class AUIHandler(AbstractHandler): if not isAGWAui: return True - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: # Allowed to save and restore perspectives perspective = eventHandler.SavePerspective() if isAGWAui: @@ -322,12 +323,11 @@ class AUIHandler(AbstractHandler): if not isAGWAui: return True - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_AUI_PERSPECTIVES: # Allowed to save and restore perspectives if isAGWAui: name = PERSIST_AGW_AUI_PERSPECTIVE - restoreCodeCaption = manager.GetManagerStyle() + restoreCodeCaption = self._manager.GetManagerStyle() restoreCodeCaption &= ~(PM_RESTORE_CAPTION_FROM_CODE) else: name = PERSIST_AUI_PERSPECTIVE @@ -580,8 +580,7 @@ class ListBoxHandler(AbstractHandler): def Save(self): - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS == 0: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS == 0: # We don't want to save selected items return True @@ -598,8 +597,7 @@ class ListBoxHandler(AbstractHandler): def Restore(self): - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS == 0: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS == 0: # We don't want to save selected items return True @@ -1577,8 +1575,7 @@ class TreeCtrlHandler(AbstractHandler): if issubclass(tree.__class__, (HTL.HyperTreeList, CT.CustomTreeCtrl)): obj.SaveCtrlValue(PERSIST_TREECTRL_CHECKED_ITEMS, self.GetCheckedState()) - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS == 0: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS == 0: # We don't want to save selected items return True @@ -1595,8 +1592,7 @@ class TreeCtrlHandler(AbstractHandler): if expansion is not None: self.SetExpansionState(expansion) - manager = PM.PersistenceManager.Get() - if manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS: + if self._manager.GetManagerStyle() & PM_SAVE_RESTORE_TREE_LIST_SELECTIONS: # We want to restore selected items if selections is not None: self.SetSelectionState(selections) @@ -2507,7 +2503,7 @@ HANDLERS = [ LBK.LabelBook, LBK.FlatImageBook)), ("TLWHandler", (wx.TopLevelWindow, )), ("CheckBoxHandler", (wx.CheckBox, )), - ("TreeCtrlHandler", (wx.TreeCtrl, wx.GenericDirCtrl, CT.CustomTreeCtrl)), + ("TreeCtrlHandler", (wx.TreeCtrl, wx.GenericDirCtrl, CT.CustomTreeCtrl, dv.TreeListCtrl)), ("MenuBarHandler", (wx.MenuBar, FM.FlatMenuBar)), ("ToolBarHandler", (AUI.AuiToolBar, )), ("ListBoxHandler", (wx.ListBox, wx.VListBox, wx.html.HtmlListBox, wx.html.SimpleHtmlListBox, diff --git a/wx/lib/agw/persist/persistencemanager.py b/wx/lib/agw/persist/persistencemanager.py index 059f9cc0..66714350 100644 --- a/wx/lib/agw/persist/persistencemanager.py +++ b/wx/lib/agw/persist/persistencemanager.py @@ -20,7 +20,7 @@ # # Or, Obviously, To The wxPython Mailing List!!! # -# Tags: phoenix-port, unittest, documented +# Tags: phoenix-port, unittest, documented, py3-port # # End Of Comments # --------------------------------------------------------------------------- #