Add wx.ActivityIndicator

This commit is contained in:
Robin Dunn
2019-10-29 15:21:57 -07:00
parent 7734fb1f10
commit e972814cd3
6 changed files with 163 additions and 0 deletions

80
demo/ActivityIndicator.py Normal file
View File

@@ -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 = """<html><body>
<h2><center>wx.ActivityIndicator</center></h2>
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.
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

View File

@@ -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',

View File

@@ -293,6 +293,7 @@
"AcceleratorTable":"wx.",
"Accessible":"wx.",
"ActivateEvent":"wx.",
"ActivityIndicator":"wx.",
"AffineMatrix2D":"wx.",
"AffineMatrix2DBase":"wx.",
"Alignment":"wx.",

View File

@@ -184,6 +184,7 @@ INCLUDES = [ # base and core stuff
'treebook',
'simplebook',
'vlbox',
'activityindicator',
# toplevel and dialogs
'nonownedwnd',

49
etg/activityindicator.py Normal file
View File

@@ -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 <wx/some_header_file.h>')
c = module.find('wxActivityIndicator')
assert isinstance(c, etgtools.ClassDef)
tools.fixWindowClass(c)
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)
#---------------------------------------------------------------------------
if __name__ == '__main__':
run()

View File

@@ -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()