Merge branch 'master' into propgrid

This commit is contained in:
Robin Dunn
2016-08-24 14:31:12 -07:00
30 changed files with 137 additions and 77 deletions

View File

@@ -2459,13 +2459,10 @@ class wxPythonDemo(wx.Frame):
def OnOpenWidgetInspector(self, evt):
# Activate the widget inspection tool
# Activate the widget inspection tool, giving it a widget to preselect
# in the tree. Use either the one under the cursor, if any, or this
# frame.
from wx.lib.inspection import InspectionTool
if not InspectionTool().initialized:
InspectionTool().Init()
# Find a widget to be selected in the tree. Use either the
# one under the cursor, if any, or this frame.
wnd = wx.FindWindowAtPointer()
if not wnd:
wnd = self

View File

@@ -0,0 +1,10 @@
class MyClass(public BaseClass): # something inheriting from wx.EvtHandler
...
def TryAfter(self, event):
if (BaseClass.TryAfter(self, event))
return True
return self.MyPostProcess(event)

View File

@@ -0,0 +1,10 @@
class MyClass(BaseClass): # something inheriting from wx.EvtHandler
...
def TryBefore(self, event):
if (self.MyPreProcess(event)):
return True
return BaseClass.TryBefore(self, event)

View File

@@ -0,0 +1,9 @@
# some code in HandleTag for "MYITEMS"...
self.Parser.PushTagHandler(self, "PARAM")
self.ParseInner(tag)
self.Parser.PopTagHandler()
# back to working on "MYITEMS"...

View File

@@ -0,0 +1,9 @@
# In Python the value returned will be a sip wrapper around a void* type,
# and it can be converted to the address being pointed to with int().
webview_ptr = self.webview.GetNativeBackend()
# Assuming you are able to get a ctypes, cffi or similar access to the
# webview library, you can use that pointer value to give it access to the
# WebView backend to operate upon.
theWebViewLib.doSomething(int(webview_ptr))

View File

@@ -0,0 +1,10 @@
# connect to the media event
self.Bind(wx.media.EVT_MEDIA_STOP, self.OnMediaStop, self.mediactrl)
# ...
def OnMediaStop(self, evt):
if self.userWantsToSeek:
self.mediactrl.SetPosition(someOtherPosition)
evt.Veto()

View File

@@ -0,0 +1,9 @@
dc = wx.MetafileDC()
if dc.IsOk():
self.DoDrawing(dc)
metafile = dc.Close()
if metafile:
success = metafile.SetClipboard(dc.MaxX() + 10, dc.MaxY() + 10)

View File

@@ -150,6 +150,14 @@ def run():
if func.findItem('item'):
func.find('item').transfer = True
c.addCppMethod('wxSizerItem*', 'Add',
'(const wxSize& size, const wxGBPosition& pos, '
'const wxGBSpan& span = wxDefaultSpan, int flag = 0, '
'int border = 0, wxObject* userData /Transfer/ = NULL)',
doc="Add a spacer using a :class:`Size` object.",
body="return self->Add(size->x, size->y, *pos, *span, flag, border, userData);")
c.addPyCode(
"GridBagSizer.CheckForIntersectionPos = wx.deprecated(GridBagSizer.CheckForIntersection, 'Use CheckForIntersection instead.')")

View File

@@ -38,6 +38,7 @@ def run():
c = module.find('wxRibbonBar')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
c.find('SetArtProvider.art').transfer = True
c = module.find('wxRibbonBarEvent')

View File

@@ -1,7 +1,12 @@
#!/usr/bin/env python
import os
import sys
"""
This module implements a demo application that shows many of the features of
the RibbonBar and related classes found in the wx.ribbon module. It is very
similar to the pure-python implementation found in the wx.lib.agw.ribbon
package. In fact, this demo was ported from the AGW version of the demo with
just a few relatively minor edits.
"""
import wx
import wx.ribbon as RB
@@ -9,7 +14,6 @@ import wx.ribbon as RB
import images
# --------------------------------------------------- #
# Some constants for ribbon buttons
@@ -335,7 +339,6 @@ class RibbonFrame(wx.Frame):
if event.GetGalleryItem() != None:
if provider == self._ribbon.GetArtProvider():
provider = provider.Clone()
gallery.SetArtProvider(provider)
provider.SetColour(RB.RIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR,
@@ -616,7 +619,7 @@ class RibbonFrame(wx.Frame):
gallery.SetSelection(item)
# Send an event to respond to the selection change
dummy = RB.RibbonGalleryEvent(RB.wxEVT_COMMAND_RIBBONGALLERY_SELECTED,
dummy = RB.RibbonGalleryEvent(RB.wxEVT_RIBBONGALLERY_SELECTED,
gallery.GetId())
dummy.SetEventObject(gallery)
dummy.SetGallery(gallery)

View File

@@ -182,6 +182,8 @@ def replaceCppItems(line):
item = 'string'
elif 'wxCoord' == item:
item = 'int'
elif 'time_t' == item:
item = 'int'
elif item == 'char':
item = 'int'
elif item == 'double':

View File

@@ -67,7 +67,7 @@ class BufferedDCTests(wtc.WidgetTestCase):
self.frame.SendSizeEvent()
panel.Refresh()
self.myUpdate(panel)
self.myYield()
self.waitFor(200)
self.assertTrue(panel.onPaintCalled == True)
@@ -88,7 +88,7 @@ class BufferedDCTests(wtc.WidgetTestCase):
self.frame.SendSizeEvent()
panel.Refresh()
self.myUpdate(panel)
self.myYield()
self.waitFor(200)
self.assertTrue(panel.onPaintCalled == True)

View File

@@ -33,7 +33,7 @@ class ClientDCTests(wtc.WidgetTestCase):
self.frame.SendSizeEvent()
panel.Refresh()
self.myUpdate(panel)
self.myYield()
self.waitFor(200)
self.assertTrue(panel.onPaintCalled == True)

View File

@@ -62,6 +62,7 @@ class lib_agw_flatmenu_Tests(wtc.WidgetTestCase):
fPt = self.frame.GetPosition()
popMenu.Popup(wx.Point(fPt.x, fPt.y), self.frame)
popMenu.Dismiss(True, True)
# Clear the capture since the test won't do a normal shudown of the flatmenu
cap = wx.Window.GetCapture()

View File

@@ -12,6 +12,7 @@ class lib_agw_pyprogress_Tests(wtc.WidgetTestCase):
dlg = PP.PyProgress(self.frame, -1, 'PyProgress Example',
'An Informative Message',
agwStyle=wx.PD_APP_MODAL|wx.PD_ELAPSED_TIME)
dlg.Destroy()
def test_lib_agw_pyprogressMethods(self):
dlg = PP.PyProgress(self.frame, -1, 'PyProgress Example',
@@ -29,6 +30,7 @@ class lib_agw_pyprogress_Tests(wtc.WidgetTestCase):
self.assertEqual(dlg.GetFirstGradientColour(), wx.Colour('white'))
self.assertEqual(dlg.GetSecondGradientColour(), wx.Colour('blue'))
self.assertTrue(dlg.GetAGWWindowStyleFlag() & wx.PD_REMAINING_TIME == 0)
dlg.Destroy()
def test_lib_agw_pyprogressConstantsExists(self):
PP.LAYOUT_MARGIN

View File

@@ -25,7 +25,7 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
self.pub.setListenerExcHandler(excPublisher)
# create a listener that raises an exception:
from lib_pubsub_except_raisinglistener import getRaisingListener
from .lib_pubsub_except_raisinglistener import getRaisingListener
raisingListener = getRaisingListener()
self.pub.setNotificationFlags(all=False)
@@ -42,7 +42,7 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
def testHandleExcept1b(self):
# create a listener that raises an exception:
from lib_pubsub_except_raisinglistener import getRaisingListener
from .lib_pubsub_except_raisinglistener import getRaisingListener
raisingListener = getRaisingListener()
self.pub.subscribe(raisingListener, 'testHandleExcept1b')
@@ -66,7 +66,7 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
# finally the string for formatted traceback:
msg = excTraceback.getFormattedString()
assert msg.startswith(' File')
assert msg.endswith("global name 'RuntimeError2' is not defined\n")
assert msg.endswith("name 'RuntimeError2' is not defined\n")
from wx.lib.pubsub.utils.exchandling import ExcPublisher
topic = self.pub.getDefaultTopicMgr().getTopic(ExcPublisher.topicUncaughtExc)

View File

@@ -5,6 +5,7 @@
"""
import six
import unittest
from unittests import wtc
@@ -194,7 +195,9 @@ class lib_pubsub_ArgsInfo(wtc.PubsubTestCase):
def tmpFn(self):
pass
Listener( DOA.tmpFn, ArgsInfoMock() )
self.assertRaises(ValueError, getListener1)
# Py3 doesn't have unbound methods so this won't throw a ValueError
if not six.PY3:
self.assertRaises(ValueError, getListener1)
# test DOA of tmp callable:
def getListener2():

View File

@@ -227,8 +227,11 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
assert diffs == ['- ', '+ ']
# now for module:
import sys
sys.path.append(os.path.dirname(__file__))
provider = self.pub.addTopicDefnProvider('lib_pubsub_provider_expect',
self.pub.TOPIC_TREE_FROM_MODULE)
sys.path.remove(os.path.dirname(__file__))
self.pub.instantiateAllDefinedTopics(provider)
modDoc = provider.getTreeDoc()
assert modDoc.startswith('\nTree docs, can be anything you')
@@ -248,7 +251,7 @@ class lib_pubsub_Except(wtc.PubsubTestCase):
assert self.pub.getDefaultTopicMgr().getTopic('root_topic1', True) is None
assert self.pub.getDefaultTopicMgr().getTopic('root_topic2.sub_topic21', True) is None
import lib_pubsub_provider_my_import_topics
from . import lib_pubsub_provider_my_import_topics
provider = self.pub.addTopicDefnProvider(lib_pubsub_provider_my_import_topics,
self.pub.TOPIC_TREE_FROM_CLASS)
self.pub.instantiateAllDefinedTopics(provider)

View File

@@ -54,10 +54,14 @@ class msgdlg_Tests(wtc.WidgetTestCase):
def test_gmsgdlg1(self):
dlg = wx.GenericMessageDialog(None, 'Message', 'Caption')
wx.CallLater(250, dlg.EndModal, wx.ID_OK)
dlg.ShowModal()
dlg.Destroy()
def test_gmsgdlg2(self):
dlg = wx.GenericMessageDialog(self.frame, 'Message', 'Caption')
wx.CallLater(250, dlg.EndModal, wx.ID_OK)
dlg.ShowModal()
dlg.Destroy()
def test_gmsgdlg3(self):
@@ -69,6 +73,8 @@ class msgdlg_Tests(wtc.WidgetTestCase):
self.assertEqual(dlg.GetMessage(), 'message')
self.assertEqual(dlg.GetOKLabel(), 'okidoky')
self.assertEqual(dlg.GetCancelLabel(), 'bye-bye')
wx.CallLater(250, dlg.EndModal, wx.ID_OK)
dlg.ShowModal()
dlg.Destroy()
#---------------------------------------------------------------------------

View File

@@ -1,5 +1,6 @@
import unittest
import sys, os, subprocess
import wx
#---------------------------------------------------------------------------
@@ -16,7 +17,7 @@ class PIImportTest(unittest.TestCase):
def runPI(self, filename):
cwd = os.getcwd()
dirname = os.path.join(os.path.dirname(__file__), '../wx')
dirname = os.path.dirname(wx.__file__)
os.chdir(dirname)
sp = subprocess.Popen('%s %s' % (sys.executable, filename),
@@ -66,4 +67,4 @@ class PIImportTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()

View File

@@ -15,11 +15,14 @@ class radiobut_Tests(wtc.WidgetTestCase):
b.Create(self.frame, label="radiobutton")
def test_radiobutValue(self):
b = wx.RadioButton(self.frame, label='radiobutton')
b = wx.RadioButton(self.frame, label='radiobutton', style=wx.RB_GROUP)
b1 = wx.RadioButton(self.frame, label='radiobutton1')
b1.Value = True
self.assertTrue(b.GetValue() == False)
self.assertTrue(b1.GetValue() == True)
b.Value = True
self.assertTrue(b.GetValue() == True)
b.Value = False
self.assertTrue(b.GetValue() == False)
self.assertTrue(b1.GetValue() == False)
#---------------------------------------------------------------------------

View File

@@ -8,10 +8,14 @@ class richmsgdlg_Tests(wtc.WidgetTestCase):
def test_richmsgdlg1(self):
dlg = wx.RichMessageDialog(None, 'Message', 'Caption')
wx.CallLater(250, dlg.EndModal, wx.ID_OK)
dlg.ShowModal()
dlg.Destroy()
def test_richmsgdlg2(self):
dlg = wx.RichMessageDialog(self.frame, 'Message', 'Caption')
wx.CallLater(250, dlg.EndModal, wx.ID_OK)
dlg.ShowModal()
dlg.Destroy()
def test_richmsgdlg3(self):
@@ -31,6 +35,8 @@ class richmsgdlg_Tests(wtc.WidgetTestCase):
self.assertEqual(dlg.CheckBoxText, "Checkbox")
self.assertEqual(dlg.DetailedText, "Detailed Text")
wx.CallLater(250, dlg.EndModal, wx.ID_OK)
dlg.ShowModal()
dlg.Destroy()
#---------------------------------------------------------------------------

View File

@@ -61,7 +61,7 @@ class scrolwin_Tests(wtc.WidgetTestCase):
self.commonBits(w)
w.Refresh()
self.myUpdate(w)
self.myYield()
self.waitFor(100)
self.assertTrue(w.flag) # True if OnDraw was called
#---------------------------------------------------------------------------

View File

@@ -952,8 +952,8 @@ class ModernDockArt(AuiDefaultDockArt):
self.hTheme1 = winxptheme.OpenThemeData(hwnd, "Window")
self.usingTheme = True
if not self.hTheme1:
self.usingTheme = False
if not self.hTheme1:
self.usingTheme = False
self._button_size = 13

View File

@@ -8019,46 +8019,6 @@ class UltimateListMainWindow(wx.ScrolledWindow):
self.MoveToFocus()
def SetEventAttrs(self, oldEvent, newEvent):
"""
Copies (almost) all of the ``m_*`` attributes from the original :class:`KeyEvent` event
to the copy (`newEvent`). Successfully passes the key codes to the application
as expected.
:param `oldEvent`: the original :class:`KeyEvent` event to be processed;
:param `newEvent`: the new :class:`KeyEvent` event to be processed.
.. todo::
Find out why getting `m_rawFlags` returns a Python ``long`` but the setter
expects to receive an ``unsigned int``.
.. versionadded:: 0.9.5
"""
if _VERSION_STRING < '2.9':
attributes = ['m_altDown', 'm_controlDown', 'm_keyCode',
'm_metaDown', 'm_rawCode', 'm_scanCode',
'm_shiftDown', 'm_x', 'm_y']
for attr in attributes:
setattr(newEvent, attr, getattr(oldEvent, attr))
else:
# 2.9.something
methods = ['AltDown', 'ControlDown', 'MetaDown', 'ShiftDown']
for meth in methods:
eval('newEvent.Set%s(oldEvent.%s())'%(meth, meth))
attributes = ['m_keyCode', 'm_rawCode', 'm_x', 'm_y']
for attr in attributes:
setattr(newEvent, attr, getattr(oldEvent, attr))
def OnKeyDown(self, event):
"""
Handles the ``wx.EVT_KEY_DOWN`` event for :class:`UltimateListMainWindow`.
@@ -8069,8 +8029,7 @@ class UltimateListMainWindow(wx.ScrolledWindow):
parent = self.GetParent()
# we propagate the key event upwards
ke = wx.KeyEvent(event.GetEventType())
self.SetEventAttrs(event, ke)
ke = event.Clone()
ke.SetEventObject(parent)
if parent.GetEventHandler().ProcessEvent(ke):
@@ -8090,8 +8049,7 @@ class UltimateListMainWindow(wx.ScrolledWindow):
parent = self.GetParent()
# we propagate the key event upwards
ke = wx.KeyEvent(event.GetEventType())
self.SetEventAttrs(event, ke)
ke = event.Clone()
ke.SetEventObject(parent)
if parent.GetEventHandler().ProcessEvent(ke):
@@ -8127,8 +8085,7 @@ class UltimateListMainWindow(wx.ScrolledWindow):
wx.WXK_PAGEUP, wx.WXK_PAGEDOWN, wx.WXK_END, wx.WXK_HOME]:
# propagate the char event upwards
ke = wx.KeyEvent(event.GetEventType())
self.SetEventAttrs(event, ke)
ke = event.Clone()
ke.SetEventObject(parent)
if parent.GetEventHandler().ProcessEvent(ke):
return

View File

@@ -18,8 +18,8 @@
# to provide Hot-Key access to the inspection tool.
"""
This modules provides the :class:`~lib.inspection.InspectionTool` and everything else needed to
provide the Widget Inspection Tool (WIT).
This modules provides the :class:`~wx.lib.inspection.InspectionTool` and
everything else needed to provide the Widget Inspection Tool (WIT).
"""
@@ -45,12 +45,18 @@ class InspectionTool:
# instances of this class are actually using the same set of
# instance data. See
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531
__shared_state = {}
__shared_state = None
def __init__(self):
self.__dict__ = self.__shared_state
if not InspectionTool.__shared_state:
InspectionTool.__shared_state = self.__dict__
else:
self.__dict__ = InspectionTool.__shared_state
if not hasattr(self, 'initialized'):
self.initialized = False
def Init(self, pos=wx.DefaultPosition, size=wx.Size(850,700),
config=None, locals=None, app=None):
"""

View File

@@ -55,6 +55,8 @@ class TopicTreeTraverser:
def extendQueue(subtopics):
topics.append(visitor._startChildren)
# put subtopics in list in alphabetical order
subtopics.sort(key=topicObj.__class__.getName)
topics.extend(subtopics)
topics.append(visitor._endChildren)