mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 04:50:07 +01:00
PR #74: some more wx.lib.agw fixes for Py33
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@76373 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
36
unittests/test_lib_agw_persist_persistencemanager.py
Normal file
36
unittests/test_lib_agw_persist_persistencemanager.py
Normal file
@@ -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()
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------------- #
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user