mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-07-21 12:41:10 +02:00
Added wrappers for the wx.CollapsibleHeaderCtrl class
This commit is contained in:
@@ -81,6 +81,8 @@ New and improved in this release:
|
||||
|
||||
* Added wrappers for the wx.ActivityIndicator class.
|
||||
|
||||
* Added wrappers for the wx.CollapsibleHeaderCtrl class.
|
||||
|
||||
|
||||
|
||||
|
||||
|
85
demo/CollapsibleHeaderCtrl.py
Normal file
85
demo/CollapsibleHeaderCtrl.py
Normal file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import wx
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
# Create some controls
|
||||
self.chc = wx.CollapsibleHeaderCtrl(self, label='the label')
|
||||
setBtn = wx.Button(self, label='Set Collapsed')
|
||||
unsetBtn = wx.Button(self, label='Unset Collapsed')
|
||||
|
||||
# Set up the layout
|
||||
sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
sizer.Add(wx.StaticText(self, label='wx.CollapsibleHeaderCtrl: '),
|
||||
wx.SizerFlags().CenterVertical())
|
||||
sizer.Add(self.chc, wx.SizerFlags().Border(wx.LEFT, 10))
|
||||
sizer.Add(setBtn, wx.SizerFlags().Border(wx.LEFT, 40))
|
||||
sizer.Add(unsetBtn, wx.SizerFlags().Border(wx.LEFT, 10))
|
||||
|
||||
# Put it all in an outter box with a border
|
||||
box = wx.BoxSizer()
|
||||
box.Add(sizer, wx.SizerFlags(1).Border(wx.ALL, 30))
|
||||
self.SetSizer(box)
|
||||
|
||||
# Set up the event handlers
|
||||
self.Bind(wx.EVT_BUTTON, self.OnSetBtn, setBtn)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnUnsetBtn, unsetBtn)
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnCheckBtnStatus, setBtn)
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnCheckBtnStatus, unsetBtn)
|
||||
self.Bind(wx.EVT_COLLAPSIBLEHEADER_CHANGED, self.OnCollapseChanged)
|
||||
|
||||
|
||||
def OnSetBtn(self, evt):
|
||||
self.chc.SetCollapsed(True)
|
||||
|
||||
def OnUnsetBtn(self, evt):
|
||||
self.chc.SetCollapsed(False)
|
||||
|
||||
def OnCheckBtnStatus(self, evt):
|
||||
obj = evt.GetEventObject()
|
||||
collapsed = self.chc.IsCollapsed()
|
||||
if obj.Label.startswith('Set'):
|
||||
evt.Enable(not collapsed)
|
||||
if obj.Label.startswith('Unset'):
|
||||
evt.Enable(collapsed)
|
||||
|
||||
def OnCollapseChanged(self, evt):
|
||||
self.log.write('OnCollapseChanged: {}'.format(self.chc.IsCollapsed()))
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>wx.CollapsibleHeaderCtrl</center></h2>
|
||||
|
||||
A header control to be used above a collapsible pane.
|
||||
|
||||
The collapsible header usually consists of a small indicator of the collapsed
|
||||
state and some label text beside it. This class is used by the generic
|
||||
implementation of wx.CollapsiblePane but it may be used in more complex layouts
|
||||
for other uses.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
@@ -693,6 +693,8 @@
|
||||
"Clipboard":"wx.",
|
||||
"ClipboardTextEvent":"wx.",
|
||||
"CloseEvent":"wx.",
|
||||
"CollapsibleHeaderCtrl":"wx.",
|
||||
"CollapsibleHeaderCtrlNameStr":"wx.",
|
||||
"CollapsiblePane":"wx.",
|
||||
"CollapsiblePaneEvent":"wx.",
|
||||
"CollapsiblePaneNameStr":"wx.",
|
||||
@@ -7046,6 +7048,7 @@
|
||||
"wxEVT_CHOICEBOOK_PAGE_CHANGED":"wx.",
|
||||
"wxEVT_CHOICEBOOK_PAGE_CHANGING":"wx.",
|
||||
"wxEVT_CLOSE_WINDOW":"wx.",
|
||||
"wxEVT_COLLAPSIBLEHEADER_CHANGED":"wx.",
|
||||
"wxEVT_COLLAPSIBLEPANE_CHANGED":"wx.",
|
||||
"wxEVT_COLOURPICKER_CHANGED":"wx.",
|
||||
"wxEVT_COLOURPICKER_CURRENT_CHANGED":"wx.",
|
||||
|
@@ -185,6 +185,7 @@ INCLUDES = [ # base and core stuff
|
||||
'simplebook',
|
||||
'vlbox',
|
||||
'activityindicator',
|
||||
'collheaderctrl',
|
||||
|
||||
# toplevel and dialogs
|
||||
'nonownedwnd',
|
||||
|
57
etg/collheaderctrl.py
Normal file
57
etg/collheaderctrl.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#---------------------------------------------------------------------------
|
||||
# Name: etg/collheaderctrl.py
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 29-Oct-2019
|
||||
# Copyright: (c) 2019 by Total Control Software
|
||||
# License: wxWindows License
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
import etgtools
|
||||
import etgtools.tweaker_tools as tools
|
||||
|
||||
PACKAGE = "wx"
|
||||
MODULE = "_core"
|
||||
NAME = "collheaderctrl" # Base name of the file to generate to for this script
|
||||
DOCSTRING = ""
|
||||
|
||||
# The classes and/or the basename of the Doxygen XML files to be processed by
|
||||
# this script.
|
||||
ITEMS = [ 'wxCollapsibleHeaderCtrl',
|
||||
]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def run():
|
||||
# Parse the XML file(s) building a collection of Extractor objects
|
||||
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
|
||||
etgtools.parseDoxyXML(module, ITEMS)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# Tweak the parsed meta objects in the module object as needed for
|
||||
# customizing the generated code and docstrings.
|
||||
|
||||
module.addHeaderCode('#include <wx/collheaderctrl.h>')
|
||||
|
||||
c = module.find('wxCollapsibleHeaderCtrl')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
tools.fixWindowClass(c)
|
||||
c.find('wxCollapsibleHeaderCtrl.label').default = '""'
|
||||
c.find('Create.label').default = '""'
|
||||
|
||||
module.addGlobalStr('wxCollapsibleHeaderCtrlNameStr', c)
|
||||
module.addItem(etgtools.WigCode(
|
||||
"wxEventType wxEVT_COLLAPSIBLEHEADER_CHANGED /PyName=wxEVT_COLLAPSIBLEHEADER_CHANGED/;"))
|
||||
module.addPyCode("""\
|
||||
EVT_COLLAPSIBLEHEADER_CHANGED = PyEventBinder(wxEVT_COLLAPSIBLEHEADER_CHANGED, 1)
|
||||
""")
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
34
unittests/test_collheaderctrl.py
Normal file
34
unittests/test_collheaderctrl.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import unittest
|
||||
from unittests import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class collheaderctrl_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_collheaderctrl1(self):
|
||||
chc = wx.CollapsibleHeaderCtrl(self.frame, label='Hello')
|
||||
chc.SetCollapsed(True)
|
||||
assert chc.IsCollapsed()
|
||||
chc.SetCollapsed(False)
|
||||
assert not chc.IsCollapsed()
|
||||
|
||||
|
||||
def test_collheaderctrl2(self):
|
||||
chc = wx.CollapsibleHeaderCtrl()
|
||||
chc.Create(self.frame, label='Hello')
|
||||
chc.SetCollapsed(True)
|
||||
assert chc.IsCollapsed()
|
||||
chc.SetCollapsed(False)
|
||||
assert not chc.IsCollapsed()
|
||||
|
||||
|
||||
def test_collheaderctrl3(self):
|
||||
wx.wxEVT_COLLAPSIBLEHEADER_CHANGED
|
||||
wx.EVT_COLLAPSIBLEHEADER_CHANGED
|
||||
assert wx.EVT_COLLAPSIBLEHEADER_CHANGED.typeId == wx.wxEVT_COLLAPSIBLEHEADER_CHANGED
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in New Issue
Block a user