source: packages/vanilla/trunk/Lib/vanilla/test/testAll.py @ 1003

Revision 1003, 23.7 KB checked in by tal, 19 months ago (diff)
Added an object browser. Probably useful for hacking.
Line 
1import time
2import os
3import sys
4from AppKit import *
5import vanilla
6reload(vanilla)
7from vanilla import *
8#from RBSplitView.vanillaRBSplitView import VRBSplitView as SplitView
9
10import objc
11objc.setVerbose(True)
12
13vanillaPath = os.path.dirname(os.path.dirname(os.path.dirname(vanilla.__file__)))
14iconPath = os.path.join(vanillaPath, "Data", "testIcon.tif")
15
16sizeStyles = ["regular", "small", "mini"]
17
18listOptions = sys.modules.keys()
19sortedListOptions = list(listOptions)
20sortedListOptions.sort()
21
22class BaseTest(object):
23
24    def drawGrid(self):
25        w, h = self.w.getPosSize()[2:]
26        increment = 10
27        for i in xrange(int(w/increment)):
28            if i == 0:
29                continue
30            attrName = "vline%d" % i
31            line = VerticalLine((increment*i, 0, 1, h))
32            setattr(self.w, attrName, line)
33        for i in xrange(int(h/increment)):
34            if i == 0:
35                continue
36            attrName = "hline%d" % i
37            line = HorizontalLine((0, increment*i, w, 1))
38            setattr(self.w, attrName, line)
39
40    def basicCallback(self, sender):
41        print sender
42
43    def titleCallback(self, sender):
44        print sender, sender.getTitle()
45
46    def getCallback(self, sender):
47        print sender, sender.get()
48
49
50class WindowTest(BaseTest):
51
52    def __init__(self, textured=False):
53        self.textured = textured
54        self.w = Window((200, 130), "Window Test", textured=textured)
55        self.w.windowButton = Button((10, 10, -10, 20), "Window", callback=self.windowCallback)
56        self.w.sheetButton = Button((10, 40, -10, 20), "Sheet", callback=self.sheetCallback)
57        self.w.drawerButton = Button((10, 70, -10, 20), "Drawer", callback=self.drawerCallback)
58        self.w.floatButton = Button((10, 100, -10, 20), "Floating Window", callback=self.floatCallback)
59        self.w.open()
60
61    def windowCallback(self, sender):
62        WindowTest(not self.textured)
63
64    def sheetCallback(self, sender):
65        self.sheet = Sheet((300, 100), self.w)
66        self.sheet.closeButton = Button((10, -30, -10, 20), "Close", callback=self._closeSheet)
67        self.sheet.open()
68
69    def _closeSheet(self, sender):
70        self.sheet.close()
71        del self.sheet
72
73    def drawerCallback(self, sender):
74        if not hasattr(self, "drawer1"):
75            self.drawer1 = Drawer((50, 50), self.w, preferredEdge="left")
76            self.drawer2 = Drawer((50, 50), self.w, preferredEdge="top")
77            self.drawer3 = Drawer((50, 50), self.w, preferredEdge="right")
78            self.drawer4 = Drawer((50, 50), self.w, preferredEdge="bottom")
79        self.drawer1.toggle()
80        self.drawer2.toggle()
81        self.drawer3.toggle()
82        self.drawer4.toggle()
83
84    def floatCallback(self, sender):
85        floater = FloatingWindow((100, 100))
86        floater.open()
87
88
89class TextTest(BaseTest):
90
91    def __init__(self, drawGrid=False):
92        self.w = Window((440, 190), "Text Test")
93
94        _top = 10
95        top = _top
96
97        textSizeStyles = [("regular", 17), ("small", 14), ("mini", 11)]
98        for sizeStyle, height in textSizeStyles:
99            attrName = "TextBox_%s" % sizeStyle
100            button = TextBox((10, top, 100, height), attrName, sizeStyle=sizeStyle)
101            setattr(self.w, attrName, button)
102            top += 30
103
104        textSizeStyles = [("regular", 22), ("small", 19), ("mini", 15)]
105        for sizeStyle, height in textSizeStyles:
106            attrName = "SearchBox_%s" % sizeStyle
107            button = SearchBox((10, top, 100, height), attrName, callback=self.getCallback, sizeStyle=sizeStyle)
108            setattr(self.w, attrName, button)
109            top += 30
110
111        top = _top
112        textSizeStyles = [("regular", 22), ("small", 19), ("mini", 16)]
113        for sizeStyle, height in textSizeStyles:
114            attrName = "EditText_%s" % sizeStyle
115            button = EditText((120, top, 100, height), attrName, callback=self.getCallback, sizeStyle=sizeStyle)
116            setattr(self.w, attrName, button)
117            top += 30
118
119        textSizeStyles = [("regular", 21), ("small", 17), ("mini", 14)]
120        for sizeStyle, height in textSizeStyles:
121            attrName = "ComboBox_%s" % sizeStyle
122            button = ComboBox((120, top, 100, height), items=listOptions, callback=self.getCallback, sizeStyle=sizeStyle)
123            setattr(self.w, attrName, button)
124            top += 30
125
126        self.w.TextEditor = TextEditor((240, 10, 190, 170), sys.copyright, callback=self.getCallback)
127
128        if drawGrid:
129            self.drawGrid()
130
131        self.w.open()
132
133
134class ButtonTest(BaseTest):
135
136    def __init__(self, drawGrid=False):
137        self.w = Window((440, 800), "Button Test")
138
139        _top = 10
140        top = _top
141
142        buttonSizeStyles = [("regular", 20), ("small", 17), ("mini", 14)]
143        for sizeStyle, height in buttonSizeStyles:
144            attrName = "Button_%s" % sizeStyle
145            button = Button((10, top, 150, height), attrName, callback=self.titleCallback, sizeStyle=sizeStyle)
146            setattr(self.w, attrName, button)
147            top += 30
148
149        height = 20
150        for sizeStyle in sizeStyles:
151            attrName = "SquareButton_%s" % sizeStyle
152            button = SquareButton((10, top, 150, height), attrName, callback=self.titleCallback, sizeStyle=sizeStyle)
153            setattr(self.w, attrName, button)
154            top += 30
155
156        settings = [(None, False, "top"),
157                    (None, True, "top"),
158                    ("bop", True, "top"),
159                    ("bop", True, "bottom"),
160                    ("bop", True, "left"),
161                    ("bop", True, "right"),]
162        for title, bordered, imagePosition in settings:
163            attrName = "ImageButton_%s_%s_%s" % (title, bordered, imagePosition)
164            button = ImageButton((10, top, 150, 50), title=title, imagePath=iconPath, bordered=bordered, imagePosition=imagePosition, callback=self.basicCallback)
165            setattr(self.w, attrName, button)
166            top += 60
167
168        segmentedControlSizeStyles = [("regular", 20), ("small", 17), ("mini", 14)]
169        descriptions = [{"title":"One"}, {"title":"Two"}, {"title":"3", "enabled":False}]
170        for sizeStyle, height in segmentedControlSizeStyles:
171            attrName = "SegmentedButton_%s" % sizeStyle
172            button = SegmentedButton((10, top, 150, height), descriptions, callback=None, sizeStyle=sizeStyle)
173            setattr(self.w, attrName, button)
174            top += 30
175
176        top = _top
177        _left = 170
178        left = _left
179        height = 100
180
181        sliderSizeStyles = [("regular", 15), ("small", 11), ("mini", 10)]
182        for sizeStyle, width in sliderSizeStyles:
183            attrName = "VSlider_noTicks_%s" % sizeStyle
184            button = Slider((left, top, width, height), 0, 100, callback=self.getCallback, sizeStyle=sizeStyle)
185            setattr(self.w, attrName, button)
186            left += 30
187        sliderSizeStyles = [("regular", 23), ("small", 17), ("mini", 16)]
188        for sizeStyle, width in sliderSizeStyles:
189            attrName = "VSlider_rightTicks_%s" % sizeStyle
190            button = Slider((left, top, width, height), 0, 100, tickMarkCount=10, callback=self.getCallback, sizeStyle=sizeStyle)
191            setattr(self.w, attrName, button)
192            left += 30
193        for sizeStyle, width in sliderSizeStyles:
194            attrName = "VSlider_leftTicks_%s" % sizeStyle
195            button = Slider((left, top, width, height), 0, 100, tickMarkCount=10, callback=self.getCallback, sizeStyle=sizeStyle)
196            button.setTickMarkPosition("left")
197            setattr(self.w, attrName, button)
198            left += 30
199
200        left = _left
201        width = 260
202        top = 130
203        sliderSizeStyles = [("regular", 15), ("small", 12), ("mini", 10)]
204        for sizeStyle, height in sliderSizeStyles:
205            attrName = "HSlider_noTicks_%s" % sizeStyle
206            button = Slider((left, top, width, height), 0, 100, callback=self.getCallback, sizeStyle=sizeStyle)
207            setattr(self.w, attrName, button)
208            top += 30
209        sliderSizeStyles = [("regular", 24), ("small", 17), ("mini", 16)]
210        for sizeStyle, height in sliderSizeStyles:
211            attrName = "HSlider_belowTicks_%s" % sizeStyle
212            button = Slider((left, top, width, height), 0, 100, tickMarkCount=30, callback=self.getCallback, sizeStyle=sizeStyle)
213            setattr(self.w, attrName, button)
214            top += 30
215        for sizeStyle, height in sliderSizeStyles:
216            attrName = "HSlider_aboveTicks_%s" % sizeStyle
217            button = Slider((left, top, width, height), 0, 100, tickMarkCount=30, callback=self.getCallback, sizeStyle=sizeStyle)
218            button.setTickMarkPosition("top")
219            setattr(self.w, attrName, button)
220            top += 30
221
222        _top = top
223
224        popupSizeStyles = [("regular", 20), ("small", 17), ("mini", 15)]
225        width = 120
226        for sizeStyle, height in popupSizeStyles:
227            attrName = "PopUpButton_%s" % sizeStyle
228            button = PopUpButton((left, top, width, height), listOptions, callback=self.getCallback, sizeStyle=sizeStyle)
229            setattr(self.w, attrName, button)
230            top += 30
231
232        top = _top
233        checkboxSizeStyles = [("regular", 22), ("small", 18), ("mini", 11)]
234        width = 125
235        left = 300
236        for sizeStyle, height in popupSizeStyles:
237            attrName = "CheckBox_%s" % sizeStyle
238            button = CheckBox((left, top, width, height), attrName, callback=self.getCallback, sizeStyle=sizeStyle)
239            setattr(self.w, attrName, button)
240            top += 30
241
242        _top = top
243
244        left = _left
245        width = 120
246        self.w.DLevelIndicator = LevelIndicator((left, top, width, 18), style="discrete",
247                    value=5, warningValue=7, criticalValue=9,
248                    callback=self.getCallback)
249        top += 30
250        self.w.DLevelIndicator_ticksAbove = LevelIndicator((left, top, width, 25), style="discrete",
251                    value=5, warningValue=7, criticalValue=9,
252                    tickMarkPosition="above", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)
253        top += 30
254        self.w.DLevelIndicator_ticksBelow = LevelIndicator((left, top, width, 25), style="discrete",
255                    value=5, warningValue=7, criticalValue=9,
256                    tickMarkPosition="below", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)
257
258        left = 300
259        top = _top
260        width = 120
261        self.w.CLevelIndicator = LevelIndicator((left, top, width, 16), style="continuous",
262                    value=5, warningValue=7, criticalValue=9,
263                    callback=self.getCallback)
264        top += 30
265        self.w.CLevelIndicator_ticksAbove = LevelIndicator((left, top, width, 23), style="continuous",
266                    value=5, warningValue=7, criticalValue=9,
267                    tickMarkPosition="above", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)
268        top += 30
269        self.w.CLevelIndicator_ticksBelow = LevelIndicator((left, top, width, 23), style="continuous",
270                    value=5, warningValue=7, criticalValue=9,
271                    tickMarkPosition="below", minorTickMarkCount=5, majorTickMarkCount=3, callback=self.getCallback)
272
273        _top = 660
274        top = _top
275        pathControlSizeStyles = [("regular", 22), ("small", 20), ("mini", 18)]
276        left = 10
277        width = -10
278        url = NSURL.fileURLWithPath_(__file__)
279        for sizeStyle, height in pathControlSizeStyles:
280            attrName = "PathControl_%s" % sizeStyle
281            button = PathControl((left, top, width, height), url, callback=None, sizeStyle=sizeStyle)
282            setattr(self.w, attrName, button)
283            top += 30
284
285        if drawGrid:
286            self.drawGrid()
287
288        self.w.open()
289
290
291class ListTest(BaseTest):
292
293    def __init__(self, drawGrid=False):
294        self.w = Window((440, 500), "List Test", minSize=(400, 400))
295
296        simpleList = List((0, 0, 0, 0), listOptions, enableTypingSensitivity=True)
297
298        multiItems = [
299            {"name": name, "path": os.path.basename(getattr(module, "__file__", "Unknown"))}
300            for name, module in sys.modules.items()
301        ]
302        columnDescriptions = [
303            {"title": "Module Name", "key": "name"},
304            {"title": "File Name", "key": "path"}
305        ]
306        multiList = List((0, 0, 0, 0), multiItems, columnDescriptions=columnDescriptions, enableTypingSensitivity=True)
307
308        miscItems = [
309            {"slider": 50, "checkBox": False},
310            {"slider": 20, "checkBox": True},
311            {"slider": 70, "checkBox": False},
312            {"slider": 20, "checkBox": True},
313            {"slider": 10, "checkBox": True},
314            {"slider": 90, "checkBox": False},
315        ]
316        columnDescriptions = [
317            {"title": "SliderListCell", "key": "slider",
318            "cell": SliderListCell()},
319            {"title": "CheckBoxListCell", "key": "checkBox",
320            "cell": CheckBoxListCell()},
321        ]
322        miscCellList = List((0, 0, 0, 0), items=miscItems, columnDescriptions=columnDescriptions)
323
324        paneDescriptions = [
325            dict(view=simpleList, identifier="simpleList"),
326            dict(view=multiList, identifier="multiList"),
327            dict(view=miscCellList, identifier="miscCellList"),
328        ]
329
330        # only add the ListIndicator tests if the controls are available
331        try:
332            listIndicatorItems = [
333                {"discrete": 3, "continuous": 4, "rating": 1, "relevancy": 9},
334                {"discrete": 8, "continuous": 3, "rating": 5, "relevancy": 5},
335                {"discrete": 3, "continuous": 7, "rating": 3, "relevancy": 4},
336                {"discrete": 2, "continuous": 5, "rating": 4, "relevancy": 7},
337                {"discrete": 6, "continuous": 9, "rating": 3, "relevancy": 2},
338                {"discrete": 4, "continuous": 0, "rating": 6, "relevancy": 8},
339            ]
340            columnDescriptions = [
341                {"title": "discrete",
342                "cell": LevelIndicatorListCell(style="discrete", warningValue=7, criticalValue=9)},
343                {"title": "continuous",
344                "cell": LevelIndicatorListCell(style="continuous", warningValue=7, criticalValue=9)},
345                {"title": "rating",
346                "cell": LevelIndicatorListCell(style="rating", maxValue=6)},
347                {"title": "relevancy",
348                "cell": LevelIndicatorListCell(style="relevancy")},
349            ]
350            levelIndicatorList = List((0, 0, 0, 0), items=listIndicatorItems, columnDescriptions=columnDescriptions)
351            paneDescriptions.append(dict(view=levelIndicatorList, identifier="levelIndicatorList"))
352        except NameError:
353            pass
354
355        self.w.splitView = SplitView((0, 0, -0, -0), paneDescriptions, isVertical=False)
356
357        if drawGrid:
358            self.drawGrid()
359
360        self.w.open()
361
362class BrowserTest(BaseTest):
363
364    def __init__(self, drawGrid=False):
365        self.w = Window((440, 500), "Browser Test", minSize=(400, 400))
366
367        import vanilla
368        self.w.browser = ObjectBrowser((0, 0, 0, 0), vanilla)
369
370        if drawGrid:
371            self.drawGrid()
372
373        self.w.open()
374
375
376class TestCustomNSView(NSView):
377
378    def viewDidEndLiveResize(self):
379        self._recalcSize()
380
381    def _recalcSize(self):
382        # XXX Note that this is specific for embedding in a ScrollView,
383        # it may behave strangely when used in another context.
384        w, h = self.superview().visibleRect()[1]
385        self.setFrame_(((0, 0), (w, h)))
386
387    def drawRect_(self, rect):
388        if self.inLiveResize():
389            self._recalcSize()
390        from random import random
391        NSColor.redColor().set()
392        NSRectFill(self.bounds())
393        width, height = self.frame()[1]
394        w = width / 5
395        h = height / 5
396        for xI in xrange(5):
397            for yI in xrange(5):
398                x = xI * w
399                y = height - (yI * h) - h
400                r = ((x, y), (w, h))
401                NSColor.colorWithDeviceRed_green_blue_alpha_(random(), random(), random(), 1.0).set()
402                NSRectFill(r)
403
404
405class ViewTest(BaseTest):
406
407    def __init__(self, drawGrid=False):
408        self.w = Window((450, 350), "View Test", minSize=(350, 300))
409
410        self.w.tabs = Tabs((10, 10, 220, 120), ["Small", "Mini"])
411        self.w.tabs[0].tabs = Tabs((10, 10, -10, -10), ["One", "Two", "Three"], sizeStyle="small")
412        self.w.tabs[1].tabs = Tabs((10, 10, -10, -10), ["One", "Two", "Three"], sizeStyle="mini")
413
414        self.w.box = Box((10, 140, 220, 70), "Box")
415        self.w.box.box = Box((10, 10, -10, -10))
416
417        self.scrollViewNSView = TestCustomNSView.alloc().initWithFrame_(((0, 0), (500, 500)))
418        self.w.scrollView = ScrollView((240, 10, 200, 200), self.scrollViewNSView, backgroundColor=NSColor.redColor())
419
420        self.splitViewNSView1 = TestCustomNSView.alloc().initWithFrame_(((0, 0), (0, 0)))
421        self.splitViewNSView2 = TestCustomNSView.alloc().initWithFrame_(((0, 0), (0, 0)))
422        view1 = ScrollView((0, 0, 0, 50), self.splitViewNSView1, autohidesScrollers=True, backgroundColor=NSColor.redColor())
423        view2 = ScrollView((0, 0, 0, -10), self.splitViewNSView2, autohidesScrollers=True, backgroundColor=NSColor.redColor())
424        paneDescriptions = [
425            dict(view=view1, identifier="view1"),
426            dict(view=view2, identifier="view2"),
427        ]
428        self.w.splitView = SplitView((10, 220, -10, -10), paneDescriptions)
429
430        if drawGrid:
431            self.drawGrid()
432
433        self.w.open()
434
435
436class ToolbarTest(BaseTest):
437
438    def __init__(self, drawGrid=False):
439        self.w = Window((350, 20), "Toolbar Test", minSize=(250, 20))
440
441        customView = NSSegmentedControl.alloc().initWithFrame_(((0, 0), (100, 30)))
442        cell = customView.cell()
443        cell.setTrackingMode_(NSSegmentSwitchTrackingSelectOne)
444        cell.setSegmentCount_(2)
445        cell.setImage_forSegment_(NSCursor.arrowCursor().image(), 0)
446        cell.setImage_forSegment_(NSCursor.crosshairCursor().image(), 1)
447        customView.sizeToFit()
448
449        toolbarItems = [
450            {"itemIdentifier": "Test Item One",
451             "label": "Test One",
452             "imagePath": iconPath,
453             "callback": self.basicCallback},
454            {"itemIdentifier": "Test Item Two",
455             "label": "Test Two",
456             "imagePath": iconPath,
457             "callback": self.basicCallback},
458            {"itemIdentifier": "Test Item Three",
459             "imagePath": iconPath,
460             "callback": self.basicCallback},
461            {"itemIdentifier": "Test Item Four",
462             "label": "Test Four",
463             "view": customView,
464             "callback": self.basicCallback},
465            {"itemIdentifier": NSToolbarPrintItemIdentifier, "visibleByDefault": False},
466            {"itemIdentifier": NSToolbarFlexibleSpaceItemIdentifier},
467            {"itemIdentifier": NSToolbarCustomizeToolbarItemIdentifier},
468        ]
469
470        self.w.addToolbar("Vanilla Test Toolbar", toolbarItems=toolbarItems)
471
472        self.w.open()
473
474
475class MiscTest(BaseTest):
476
477    def __init__(self, drawGrid=False):
478        self.w = Window((150, 180), "Misc. Test")
479
480        self.w.spinner1 = ProgressSpinner((10, 10, 32, 32), sizeStyle="regular")
481        self.w.spinner2 = ProgressSpinner((50, 10, 16, 16), sizeStyle="small")
482
483        self.w.bar1 = ProgressBar((10, 50, -10, 16))
484        self.w.bar2 = ProgressBar((10, 70, -10, 10), isIndeterminate=True, sizeStyle="small")
485
486        self.w.progressStartButton = Button((10, 90, -10, 20), "Start Progress", callback=self.startProgress)
487
488        self.w.colorWell = ColorWell((10, 130, -10, -10), callback=self.getCallback, color=NSColor.redColor())
489
490        if drawGrid:
491            self.drawGrid()
492
493        self.w.open()
494
495    def startProgress(self, sender):
496        self.w.spinner1.start()
497        self.w.spinner2.start()
498        self.w.bar2.start()
499        for i in xrange(10):
500            self.w.bar1.increment(10)
501            time.sleep(.1)
502        time.sleep(.5)
503        self.w.spinner1.stop()
504        self.w.spinner2.stop()
505        self.w.bar2.stop()
506        self.w.bar1.set(0)
507
508
509class _VanillaTestViewForSplitView(NSView):
510
511    def drawRect_(self, rect):
512        from AppKit import NSRectFill, NSBezierPath, NSColor
513        self.color.set()
514        NSRectFill(self.bounds())
515        NSColor.blackColor().set()
516        p = NSBezierPath.bezierPathWithRect_(self.bounds())
517        p.setLineWidth_(10)
518        p.stroke()
519
520
521class TestSplitSubview(VanillaBaseObject):
522
523    def __init__(self, posSize, color):
524        self._setupView(_VanillaTestViewForSplitView, posSize)
525        self._nsObject.color = color
526
527class TestSplitView(BaseTest):
528
529    def __init__(self, drawGrid=False):
530        self.w = Window((600, 500), "", minSize=(300, 250))
531
532        grp = Group((0, 0, 0, 0))
533        grp.button = Button((10, 10, -10, 20), "Toggle", self.buttonCallback)
534
535        self.view1 = TestSplitSubview((0, 0, 0, 0), NSColor.redColor())
536        paneDescriptions2 = [
537            dict(view=self.view1, canCollapse=True, size=50, identifier="pane1"),
538            dict(view=grp, identifier="pane2"),
539            dict(view=TestSplitSubview((0, 0, 0, 0), NSColor.greenColor()), minSize=50, identifier="pane3"),
540            dict(view=TestSplitSubview((0, 0, 0, 0), NSColor.yellowColor()), identifier="pane4"),
541        ]
542        self.nestedSplit = SplitView((0, 0, 0, 0), paneDescriptions2, isVertical=True)
543        paneDescriptions1 = [
544            dict(view=self.nestedSplit, identifier="pane5"),
545            dict(view=TestSplitSubview((0, 0, 0, 0), NSColor.magentaColor()), minSize=100, size=100, canCollapse=True, identifier="pane6"),
546        ]
547        self.w.splitView = SplitView((10, 10, -10, -10), paneDescriptions1, isVertical=False)
548
549        if drawGrid:
550            self.drawGrid()
551        self.w.open()
552
553    def buttonCallback(self, sender):
554        self.nestedSplit.togglePane("pane1")
555
556
557class Test(object):
558
559    def __init__(self):
560        self.w = FloatingWindow((200, 300, 120, 340))
561        self.w.drawGrid = CheckBox((10, 10, -10, 22), "Draw Grid", value=False)
562        self.w.windows = Button((10, 40, -10, 20), "Windows", callback=self.openTestCallback)
563        self.w.geometry = Button((10, 70, -10, 20), "Geometry", callback=self.openTestCallback)
564        self.w.text = Button((10, 100, -10, 20), "Text", callback=self.openTestCallback)
565        self.w.buttons = Button((10, 130, -10, 20), "Buttons", callback=self.openTestCallback)
566        self.w.list = Button((10, 160, -10, 20), "List", callback=self.openTestCallback)
567        self.w.browser = Button((10, 190, -10, 20), "Browser", callback=self.openTestCallback)
568        self.w.view = Button((10, 220, -10, 20), "Views", callback=self.openTestCallback)
569        self.w.toolbar = Button((10, 250, -10, 20), "Toolbar", callback=self.openTestCallback)
570        self.w.misc = Button((10, 280, -10, 20), "Misc.", callback=self.openTestCallback)
571        self.w.split = Button((10, 310, -10, 20), "SplitView", callback=self.openTestCallback)
572        self.w.open()
573
574    def openTestCallback(self, sender):
575        title = sender.getTitle()
576        if title == "Windows":
577            WindowTest()
578        elif title == "Geometry":
579            from vanilla.test.testGeometry import TestGeometry
580            TestGeometry()
581        elif title == "Text":
582            TextTest(self.w.drawGrid.get())
583        elif title == "Buttons":
584            ButtonTest(self.w.drawGrid.get())
585        elif title == "List":
586            ListTest(self.w.drawGrid.get())
587        elif title == "Browser":
588            BrowserTest(self.w.drawGrid.get())
589        elif title == "Views":
590            ViewTest(self.w.drawGrid.get())
591        elif title == "Toolbar":
592            ToolbarTest(self.w.drawGrid.get())
593        elif title == "Misc.":
594            MiscTest(self.w.drawGrid.get())
595        elif title == "SplitView":
596            TestSplitView(self.w.drawGrid.get())
597
598
599if __name__ == "__main__":
600    from vanilla.test.testTools import executeVanillaTest
601    executeVanillaTest(Test)
Note: See TracBrowser for help on using the repository browser.