ANN: PyGUI 2.0

member thudfoo thudfoo at opensuse.us
Tue Apr 14 20:39:14 CEST 2009


On Tue, Apr 14, 2009 at 10:02 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> greg wrote:
[...]

fwiw, the following python script could be used, when run from the
Tests directory, to selectively run the numbered tests:

--------- runtests.py------------------------------------
import glob
import os
import subprocess
from GUI import Window, Menu, Label, application, stop_alert

class TestWindow(Window):

    def setup_menus(self, m):
        m.new_cmd.enabled = 0
        m.open_cmd.enabled = 0
        m.runtest.enabled = 1
        for ndx in range(len(runmenuitems)):
            if ndx in ranmenuitems:
                m.runtest[ndx].checked = True

    def runtest(self, i):
        try:
            filename = '%s.py' % runmenuitems[i]
            retcode = subprocess.call("python %s" % (filename), shell=True)
            if retcode < 0:
                stop_alert("Child was terminated by signal" + -retcode)
        except OSError, e:
            stop_alert("Execution of %s failed: %s" % (filename, str(e)))
        else:
            ranmenuitems.add(i)

def getrunmenuitems():
    filenames = glob.glob('./[0-9][0-9]-*.py')
    menuitems = []
    for filename in filenames:
        menuitems.append(os.path.basename(filename)[:-3])
    return sorted(menuitems)

runmenuitems = getrunmenuitems()
ranmenuitems = set()

win = TestWindow(title="Run Tests", size=(240, 60))
win.menus = [Menu('Run', [(runmenuitems, 'runtest')])]
win.add(Label("Select a test from the Run menu", position = (20, 20),
width = 200))
win.show()
application().run()
--------------------------------------------------------------



More information about the Python-list mailing list