#
#   Python GUI - Test application and menus
#

import GUI

class TestApp(GUI.Application):

    def __init__(self):
        GUI.Application.__init__(self)
#		foo_menu = GUI.Menu("Foo",
#			("Blarg/B", 'blarg_cmd')
#		)
#		self.menus += [foo_menu]
#		
#	def setup_menus(self, m):
#		GUI.Application.setup_menus(self, m)
#		m.blarg_cmd.enabled = 1
#	
#	def blarg_cmd(self):
#		print "Blarg!"
    
    def key_down(self, event):
        print "Key down:", event
        if event.char == "E":
            raise Exception("This is a test exception.")
    
    def key_up(self, event):
        print "Key up:", event
    
    def auto_key(self, event):
        print "Auto key:", event

app = TestApp()

#print "Created TestApp"

if not app.zero_windows_allowed():
    #print "Creating window"
    win = GUI.Window(title = "TestApp")
    #print "Created window"
    win.show()
    #print "Shown window"

instructions = """
On platforms capable of running an application without windows,
there should be no windows, otherwise there should be a single
window.

If menus have been implemented, the standard menus should be
available, the New, Open and Quit items should be enabled, and
the Quit command should work both by menu selection and keyboard
equivalent.

Key down, key up and auto key events should be reported.

Type capital E to test exception handling. Either a dialog
box should appear reporting the exception, or if dialog boxes
are not yet implemented, the message 'Exception while handling
exception' should be printed followed by two tracebacks.
"""

print instructions
app.run()
