From e972814cd342517ddf2d95be742b83de51162084 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 29 Oct 2019 15:21:57 -0700 Subject: [PATCH] Add wx.ActivityIndicator --- demo/ActivityIndicator.py | 80 +++++++++++++++++++++++++++++ demo/demodata.py | 2 + docs/sphinx/itemToModuleMap.json | 1 + etg/_core.py | 1 + etg/activityindicator.py | 49 ++++++++++++++++++ unittests/test_activityindicator.py | 30 +++++++++++ 6 files changed, 163 insertions(+) create mode 100644 demo/ActivityIndicator.py create mode 100644 etg/activityindicator.py create mode 100644 unittests/test_activityindicator.py diff --git a/demo/ActivityIndicator.py b/demo/ActivityIndicator.py new file mode 100644 index 00000000..54635087 --- /dev/null +++ b/demo/ActivityIndicator.py @@ -0,0 +1,80 @@ +#!/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.ai = wx.ActivityIndicator(self) + self.ai.Start() + startBtn = wx.Button(self, label='Start') + stopBtn = wx.Button(self, label='Stop') + + # Set up the layout + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add(wx.StaticText(self, label='wx.ActivityIndicator: '), + wx.SizerFlags().CenterVertical()) + sizer.Add(self.ai, wx.SizerFlags().Border(wx.LEFT, 10)) + sizer.Add(startBtn, wx.SizerFlags().Border(wx.LEFT, 40)) + sizer.Add(stopBtn, 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.OnStart, startBtn) + self.Bind(wx.EVT_BUTTON, self.OnStop, stopBtn) + self.Bind(wx.EVT_UPDATE_UI, self.OnCheckBtnStatus, startBtn) + self.Bind(wx.EVT_UPDATE_UI, self.OnCheckBtnStatus, stopBtn) + + + def OnStart(self, evt): + self.ai.Start() + + + def OnStop(self, evt): + self.ai.Stop() + + + def OnCheckBtnStatus(self, evt): + obj = evt.GetEventObject() + running = self.ai.IsRunning() + if obj.Label == 'Start': + evt.Enable(not running) + if obj.Label == 'Stop': + evt.Enable(running) + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

wx.ActivityIndicator

+ +The wx.ActivityIndicator is a small platform-specifc control showing an +animation that can be used to indicate that the program is currently busy +performing some background task. + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) + diff --git a/demo/demodata.py b/demo/demodata.py index e109edcb..468b3779 100644 --- a/demo/demodata.py +++ b/demo/demodata.py @@ -46,6 +46,7 @@ _treeList = [ 'AddPrivateFont', 'SVGImage_Bitmap', 'SVGImage_Render', + 'ActivityIndicator', ]), # managed windows == things with a (optional) caption you can close @@ -86,6 +87,7 @@ _treeList = [ # core controls ('Core Windows/Controls', [ + 'ActivityIndicator', 'BitmapButton', 'Button', 'CheckBox', diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json index aba2b091..1ee54e58 100644 --- a/docs/sphinx/itemToModuleMap.json +++ b/docs/sphinx/itemToModuleMap.json @@ -293,6 +293,7 @@ "AcceleratorTable":"wx.", "Accessible":"wx.", "ActivateEvent":"wx.", +"ActivityIndicator":"wx.", "AffineMatrix2D":"wx.", "AffineMatrix2DBase":"wx.", "Alignment":"wx.", diff --git a/etg/_core.py b/etg/_core.py index 782fb042..d74c75f5 100644 --- a/etg/_core.py +++ b/etg/_core.py @@ -184,6 +184,7 @@ INCLUDES = [ # base and core stuff 'treebook', 'simplebook', 'vlbox', + 'activityindicator', # toplevel and dialogs 'nonownedwnd', diff --git a/etg/activityindicator.py b/etg/activityindicator.py new file mode 100644 index 00000000..91345b0d --- /dev/null +++ b/etg/activityindicator.py @@ -0,0 +1,49 @@ +#--------------------------------------------------------------------------- +# Name: etg/activityindicator.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 = "activityindicator" # 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 = [ 'wxActivityIndicator', + ] + +#--------------------------------------------------------------------------- + +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 ') + + c = module.find('wxActivityIndicator') + assert isinstance(c, etgtools.ClassDef) + tools.fixWindowClass(c) + + + #----------------------------------------------------------------- + tools.doCommonTweaks(module) + tools.runGenerators(module) + + +#--------------------------------------------------------------------------- +if __name__ == '__main__': + run() + diff --git a/unittests/test_activityindicator.py b/unittests/test_activityindicator.py new file mode 100644 index 00000000..1c7d82bd --- /dev/null +++ b/unittests/test_activityindicator.py @@ -0,0 +1,30 @@ +import unittest +from unittests import wtc +import wx + +#--------------------------------------------------------------------------- + +class activityindicator_Tests(wtc.WidgetTestCase): + + def test_activityindicator1(self): + ai = wx.ActivityIndicator(self.frame) + ai.Start() + self.myYield() + assert ai.IsRunning() + ai.Stop() + assert not ai.IsRunning() + + def test_activityindicator2(self): + ai = wx.ActivityIndicator() + ai.Create(self.frame) + ai.Start() + self.myYield() + assert ai.IsRunning() + ai.Stop() + assert not ai.IsRunning() + + +#--------------------------------------------------------------------------- + +if __name__ == '__main__': + unittest.main()