Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/hst/training/events/Python/class6.pdf
Дата изменения: Wed Jun 15 23:10:29 2005
Дата индексирования: Sun Dec 23 00:37:26 2007
Кодировка:

Поисковые слова: http astrokuban.info astrokuban
STSCI Python Introduction
Class 6 Jim Hare

Today's Agenda
· Widget Programming Basics · Application Examples · A testing technique for GUI Driven Systems

1


Widget Basics
· Create an instance of a widget frame = Frame(master, width=500, height=400, bd=1) · Pack or use Grid to place it frame.pack() self.oldpw.grid(row=0, column=1, sticky=W)

Widget Basics Callback
· Callbacks are functions that are called as the result of an event being generated. self.filemenu.add('command', label = 'Exit', command = self.quit)

2


Simple Calculator calc1.py

3


Text Widget
· Example of a Text widget with several embedded objects text.py

A Testing Technique for GUI Driven Systems
· Record and Playback buttons can be attached to our system GUIs. · A module with objects and methods can be created to easily add record and playback functions. · The GUI can be bypassed

4


Why
· Provides easy method to script tests without needing to write scripts. · Automates the testing of GUIs. · Operations can use it for a command log or to provide procedures for problems. · Developers can use it to provide SDN tests. · Testers can use it for regression testing.

Record and Playback Widgets
· Record On/Off Button ­ recordHandler callback · Playback On/Off Button ­ startPlayback callback · Playback slider bar ­ sets control variable playSpeed

5


Record and Playback Features
· Capture initial conditions at time of recording and write to a log file. · Record commands and the delta time from the last recorded event to a log file. · Set initial conditions on starting playback. · Playback commands from the log file at a rate controllable by a slider bar.

Record and Playback Object Data
· · · · · · · recording -- recording on/off flag delta ­ delta time from last GUI command recordLast ­ Last time a command recorded playingback ­ playback on/off flag playTime ­ time at start of a playback cmd line ­ the current line for playback from the log file playSpeed ­ speed multiplier from slider bar

6


Record Methods
· recordHandler ­ Handler called when record button pushed, opens log file. · setinit ­ creates a data dictionary capturing the state of the GUI at the time of recording. · Record ­ records command, initialization, and delta · recordWrite ­ determines delta and calls Record to write to the log

Playback Methods
· startPlayback ­ callback for playback button · playInit ­ initializes GUI/system to state at the time of recording · getTagString ­ returns the log line command, initializaton string, or time delta · play ­ executes command after delta*playSpeed

7


Possible Additional Features
· Put record and playback buttons and slider in menu or pulldown menu. · Add entry field for test environment setup script to run. · Add entry field for naming the log file to be recorded. · Add entry field for selecting log file to playback. · Add entry field for baseline directory. · Add listbox for files to save and compare against baseline.

8