Dialog_test.py :  » GUI » Pmw » Pmw.1.3.2 » src » Pmw » Pmw_1_3 » tests » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » Pmw 
Pmw » Pmw.1.3.2 » src » Pmw » Pmw_1_3 » tests » Dialog_test.py
# Based on iwidgets2.2.0/tests/dialog.test code.   

import sys
import Tkinter
import Test
import Pmw

Test.initialise()

if Tkinter.TkVersion >= 8.3:
  version = sys.version_info
  if version[0] > 2 or (version[0] == 2 and version[1] > 0):
      expected1 = "AttributeError: Dialog instance has no attribute 'bogus'"
  else:
      expected1 = "AttributeError: 'Dialog' instance has no attribute 'bogus'"
else:
  expected1 = 'AttributeError: bogus'

c = Pmw.Dialog

def _addListbox():
    global _lb
    w = Test.currentWidget()
    _lb = Tkinter.Listbox(w.interior(), relief = 'sunken')
    _lb.pack(fill = 'both', expand = 'yes')

def _addListEntry(text):
    _lb.insert('end', text)

def _test_deactivate(result):
    w = Test.currentWidget()
    w.after(Test.delay() + 4000,
        lambda widget=w, r=result: widget.deactivate(r))

def _createOtherToplevel():
    global tempToplevel
    Test.root.deiconify()
    Test.root.geometry('+0+0')
    tempToplevel = Tkinter.Toplevel()
    tempToplevel.geometry('+0+0')
    label = Tkinter.Label(tempToplevel, text =
        'The cursor should turn to a\n' +
        'clock over this window if the\n' +
  'blt busy command is available.\n' +
  'In any case, the button will be inactive\n' +
  'while the modal dialog is active.')
    label.pack(padx=100, pady=100)
    button = Tkinter.Button(tempToplevel, text = 'Try to press me')
    button.pack(pady=100, expand=1)

def _hideOtherToplevel():
    global tempToplevel
    tempToplevel.withdraw()
    Test.root.withdraw()

def _bogus():
    w = Test.currentWidget()
    w.bogus()

kw_1 = {
  'buttons' : (),
  'buttonbox_padx': 30,
}
tests_1 = (
  ('buttons', ('OK',)),
  ('buttons', ('OK', 'Cancel',)),
  ('defaultbutton', 'OK'),
  (_addListbox, ()),
  (Test.num_options, (), 9),
  ('hull_background', '#d9d9d9'),
  ('buttons', ('A', 'B', 'C', 'D')),
  ('hull_cursor', 'gumby'),
  (c.title, 'Dialog Shell', ''),
  (c.interior, (), Tkinter.Frame),
  ('buttons', ()),
  ('buttons', ('OK',)),
  ('buttons', ('OK', 'Cancel')),
  ('buttons', ('OK', 'Cancel', 'Help')),
  ('defaultbutton', 'OK'),
  ('buttons', ('Apply', 'OK', 'Cancel', 'Help')),
  ('buttons', ('Apply', 'OK', 'Cancel')),
  ('defaultbutton', 'Cancel'),
  (c.invoke, 'OK', 'None'),
  ('buttonbox_OK_text', 'OOOOOKKKKK'),
  (c.show, ()),
  (c.withdraw, (), ''),
  ('buttons', ('Apply', 'OK', 'Cancel', 'Foo')),
  ('buttons', ('Apply', 'OK', 'Cancel')),
  (c.show, ()),
  (c.withdraw, (), ''),
  (_createOtherToplevel, ()),
  (_addListEntry, 'Testing application activate/deactivate'),
  (_addListEntry, 'Please wait'),
  (_test_deactivate, 'Hello World'),
  (c.activate, (), 'Hello World'),
  ('defaultbutton', ''),
  (_addListEntry, 'Now testing global activate/deactivate'),
  (_addListEntry, 'Please wait a bit more'),
  (_test_deactivate, 'Hello World'),
  (c.activate, (1), 'Hello World'),
  (_hideOtherToplevel, ()),
  ('buttons', ('Apply', 'OK', 'Cancel', 'Foo', '1')),
  (c.show, (), {}),
  (_bogus, (), expected1),
)

kw_2 = {'buttonboxpos' : 'e', 'separatorwidth' : 5}
tests_2 = (
  ('buttons', ('OK',)),
  ('buttons', ('OK', 'Cancel',)),
  ('defaultbutton', 'OK'),
)

alltests = (
  (tests_1, kw_1),
  (tests_2, kw_2),
)

testData = ((c, alltests),)

if __name__ == '__main__':
    Test.runTests(testData)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.