mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-15 17:20:07 +01:00
Add wx.Simplbook
This commit is contained in:
@@ -68,6 +68,8 @@ Changes in this release include the following:
|
||||
* Fix for calls to wx.Notebook.HitTest calling the wrong instance (base class
|
||||
version) of the method. (#499)
|
||||
|
||||
* Add wx.Simplebook class.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
202
demo/Simplebook.py
Normal file
202
demo/Simplebook.py
Normal file
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import wx
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPage(wx.Panel):
|
||||
def __init__(self, parent, onNextPage, colour=None, title=None, text=None, extra=None):
|
||||
wx.Panel.__init__(self, parent)
|
||||
|
||||
vbox = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
if colour:
|
||||
self.SetBackgroundColour(colour)
|
||||
|
||||
if title:
|
||||
st = wx.StaticText(self, label=title)
|
||||
f = st.GetFont()
|
||||
f.SetPointSize(f.GetPointSize()+6)
|
||||
f.SetWeight(wx.FONTWEIGHT_BOLD)
|
||||
st.SetFont(f)
|
||||
vbox.Add(st, 0, wx.BOTTOM, 10)
|
||||
|
||||
if text:
|
||||
st = wx.StaticText(self, label=text)
|
||||
vbox.Add(st, 0, wx.BOTTOM, 10)
|
||||
|
||||
if extra:
|
||||
extra(self, vbox)
|
||||
|
||||
vbox.AddStretchSpacer()
|
||||
|
||||
btn = wx.Button(self, label="Next Page")
|
||||
vbox.Add(btn, 0, wx.ALIGN_RIGHT)
|
||||
self.Bind(wx.EVT_BUTTON, onNextPage, btn)
|
||||
|
||||
outer_sizer = wx.BoxSizer()
|
||||
outer_sizer.Add(vbox, 1, wx.EXPAND|wx.ALL, 15)
|
||||
self.SetSizer(outer_sizer)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TestSimplebook(wx.Simplebook):
|
||||
def __init__(self, parent):
|
||||
wx.Simplebook.__init__(self, parent)
|
||||
|
||||
self.showEffect = wx.SHOW_EFFECT_NONE
|
||||
self.hideEffect = wx.SHOW_EFFECT_NONE
|
||||
self.showTimeout = 0
|
||||
self.hideTimeout = 0
|
||||
|
||||
self.DoSetEffects()
|
||||
|
||||
page = TestPage(self, self.OnNextPage,
|
||||
'sky blue', 'Page 1 of 4', text="""\
|
||||
A wx.Simplebook is a notebook-like control that has no tabs or any other way
|
||||
for the user to be able to select which page is to be shown. Page selection is
|
||||
totally controlled by the application. For this example we are providing a
|
||||
button to switch to the next page in the stack.""",
|
||||
extra=self.MakeOptionsControls
|
||||
)
|
||||
self.AddPage(page, '')
|
||||
|
||||
page = TestPage(self, self.OnNextPage, 'pink', 'Page 2 of 4',
|
||||
extra=self.MakeBackHomeButton)
|
||||
self.AddPage(page, '')
|
||||
|
||||
page = TestPage(self, self.OnNextPage, 'medium aquamarine', 'Page 3 of 4',
|
||||
extra=self.MakeBackHomeButton)
|
||||
self.AddPage(page, '')
|
||||
|
||||
page = TestPage(self, self.OnNextPage, 'orchid', 'Page 4 of 4',
|
||||
'Clicking "Next Page" will cycle back to the first page.',
|
||||
extra=self.MakeBackHomeButton)
|
||||
self.AddPage(page, '')
|
||||
|
||||
|
||||
def MakeOptionsControls(self, panel, vbox):
|
||||
fgs = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
|
||||
|
||||
effects = [ 'wx.SHOW_EFFECT_NONE',
|
||||
'wx.SHOW_EFFECT_ROLL_TO_LEFT',
|
||||
'wx.SHOW_EFFECT_ROLL_TO_RIGHT',
|
||||
'wx.SHOW_EFFECT_ROLL_TO_TOP ',
|
||||
'wx.SHOW_EFFECT_ROLL_TO_BOTTOM',
|
||||
'wx.SHOW_EFFECT_SLIDE_TO_LEFT',
|
||||
'wx.SHOW_EFFECT_SLIDE_TO_RIGHT',
|
||||
'wx.SHOW_EFFECT_SLIDE_TO_TOP',
|
||||
'wx.SHOW_EFFECT_SLIDE_TO_BOTTOM',
|
||||
'wx.SHOW_EFFECT_BLEND',
|
||||
'wx.SHOW_EFFECT_EXPAND',
|
||||
]
|
||||
|
||||
showEffectChoice = wx.Choice(panel, choices=effects)
|
||||
showTimeoutSpin = wx.SpinCtrl(panel, initial=0, max=1000)
|
||||
hideEffectChoice = wx.Choice(panel, choices=effects)
|
||||
hideTimeoutSpin = wx.SpinCtrl(panel, initial=0, max=1000)
|
||||
|
||||
fgs.Add(wx.StaticText(panel, -1, "Show Effect:"))
|
||||
fgs.Add(showEffectChoice)
|
||||
fgs.Add(wx.StaticText(panel, -1, "Show Timeout (ms):"))
|
||||
fgs.Add(showTimeoutSpin)
|
||||
|
||||
fgs.AddSpacer(10)
|
||||
fgs.AddSpacer(10)
|
||||
|
||||
fgs.Add(wx.StaticText(panel, -1, "Hide Effect:"))
|
||||
fgs.Add(hideEffectChoice)
|
||||
fgs.Add(wx.StaticText(panel, -1, "Hide Timeout (ms):"))
|
||||
fgs.Add(hideTimeoutSpin)
|
||||
|
||||
vbox.Add(fgs, 0, wx.ALL|wx.ALIGN_CENTER, 10)
|
||||
|
||||
self.Bind(wx.EVT_CHOICE, self.OnShowEffectChoice, showEffectChoice)
|
||||
self.Bind(wx.EVT_CHOICE, self.OnHideEffectChoice, hideEffectChoice)
|
||||
self.Bind(wx.EVT_SPINCTRL, self.OnShowTimeoutSpin, showTimeoutSpin)
|
||||
self.Bind(wx.EVT_SPINCTRL, self.OnHideTimeoutSpin, hideTimeoutSpin)
|
||||
|
||||
|
||||
def MakeBackHomeButton(self, panel, vbox):
|
||||
btn = wx.Button(panel, -1, 'Back to page 1')
|
||||
self.Bind(wx.EVT_BUTTON, self.OnBackHome, btn)
|
||||
vbox.AddSpacer(75)
|
||||
vbox.Add(btn)
|
||||
|
||||
|
||||
def OnNextPage(self, evt):
|
||||
current = self.GetSelection()
|
||||
current += 1
|
||||
if current >= self.GetPageCount():
|
||||
current = 0
|
||||
self.ChangeSelection(current)
|
||||
|
||||
|
||||
def OnBackHome(self, evt):
|
||||
self.ChangeSelection(0)
|
||||
|
||||
|
||||
def OnShowEffectChoice(self, evt):
|
||||
self.showEffect = eval(evt.GetString())
|
||||
self.DoSetEffects()
|
||||
|
||||
|
||||
def OnHideEffectChoice(self, evt):
|
||||
self.hideEffect = eval(evt.GetString())
|
||||
self.DoSetEffects()
|
||||
|
||||
|
||||
def OnShowTimeoutSpin(self, evt):
|
||||
self.showTimeout = evt.GetEventObject().GetValue()
|
||||
self.DoSetEffects()
|
||||
|
||||
def OnHideTimeoutSpin(self, evt):
|
||||
self.hideTimeout = evt.GetEventObject().GetValue()
|
||||
self.DoSetEffects()
|
||||
|
||||
|
||||
def DoSetEffects(self):
|
||||
self.SetEffects(self.showEffect, self.hideEffect)
|
||||
self.SetEffectsTimeouts(self.showTimeout, self.hideTimeout)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
book = TestSimplebook(self)
|
||||
self.Sizer = wx.BoxSizer()
|
||||
self.Sizer.Add(book, 1, wx.EXPAND)
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>Simplebook</center></h2>
|
||||
|
||||
A wx.Simplebook is a notebook-like control that has no tabs or
|
||||
any other way for the user to be able to select which page is to
|
||||
be shown. Page selection is totally controlled by the application.
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys,os
|
||||
import run
|
||||
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||
|
||||
@@ -45,6 +45,7 @@ _treeList = [
|
||||
'ToolTip',
|
||||
'TimePickerCtrl',
|
||||
'BannerWindow',
|
||||
'Simplebook',
|
||||
]),
|
||||
|
||||
# managed windows == things with a (optional) caption you can close
|
||||
@@ -136,6 +137,7 @@ _treeList = [
|
||||
'FlatNotebook',
|
||||
'Listbook',
|
||||
'Notebook',
|
||||
'Simplebook',
|
||||
'Toolbook',
|
||||
'Treebook',
|
||||
]),
|
||||
|
||||
@@ -5515,6 +5515,7 @@
|
||||
"SimpleHelpProvider":"wx.",
|
||||
"SimpleHtmlListBox":"wx.html.",
|
||||
"SimpleHtmlListBoxNameStr":"wx.html.",
|
||||
"Simplebook":"wx.",
|
||||
"SingleChoiceDialog":"wx.",
|
||||
"SingleInstanceChecker":"wx.",
|
||||
"Size":"wx.",
|
||||
|
||||
@@ -178,6 +178,7 @@ INCLUDES = [ # base and core stuff
|
||||
'listbook',
|
||||
'toolbook',
|
||||
'treebook',
|
||||
'simplebook',
|
||||
'vlbox',
|
||||
|
||||
# toplevel and dialogs
|
||||
|
||||
51
etg/simplebook.py
Normal file
51
etg/simplebook.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#---------------------------------------------------------------------------
|
||||
# Name: etg/simplebook.py
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 05-Sep-2017
|
||||
# Copyright: (c) 2017 by Total Control Software
|
||||
# License: wxWindows License
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
import etgtools
|
||||
import etgtools.tweaker_tools as tools
|
||||
|
||||
PACKAGE = "wx"
|
||||
MODULE = "_core"
|
||||
NAME = "simplebook" # 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 = [ 'wxSimplebook',
|
||||
|
||||
]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
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/simplebook.h>')
|
||||
|
||||
c = module.find('wxSimplebook')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
tools.fixWindowClass(c)
|
||||
tools.fixBookctrlClass(c)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
27
unittests/test_simplebook.py
Normal file
27
unittests/test_simplebook.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import unittest
|
||||
from unittests import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class simplebook_Tests(wtc.WidgetTestCase):
|
||||
|
||||
def test_simplebook01(self):
|
||||
nb = wx.Simplebook(self.frame)
|
||||
|
||||
def test_simplebook02(self):
|
||||
nb = wx.Simplebook()
|
||||
nb.Create(self.frame)
|
||||
|
||||
def test_simplebook03(self):
|
||||
nb = wx.Simplebook(self.frame)
|
||||
p1 = wx.Panel(nb)
|
||||
nb.AddPage(p1, "")
|
||||
p2 = wx.Panel(nb)
|
||||
nb.AddPage(p2, "")
|
||||
nb.ChangeSelection(0)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user