コード例 #1
0
def make_mixed():
    try:
        box.on = 'mixed'
    except ValueError:
        e = sys.exc_info()[1]
        say(e)
    report()
コード例 #2
0
 def select():
     i = group.value
     name = cursor_names[i]
     say("Selecting cursor no. %d (%s)" % (i, name))
     cursor = getattr(StdCursors, name)
     say("...", cursor)
     view.cursor = cursor
コード例 #3
0
 def do_old_files(self):
     say("Doing request_old_files")
     if self.filt.on:
         file_types = [self.file_type]
     else:
         file_types = None
     result = FileDialogs.request_old_files("Open Dusty Old Files:",
         default_dir = last_dir, file_types = file_types)
     self.save_result(result)
コード例 #4
0
def main():
    get_test_names()
    while 1:
        list_tests()
        name = get_test()
        print
        # cmd = r"c:\python25\python %s" % name
        cmd = "%s %s" % (sys.executable, name)
        say("Executing:", repr(cmd))
        os.system(cmd)
コード例 #5
0
 def do_new_file(self):
     say("Doing request_new_file with default_dir = %s, default_name = %r"
         % (last_dir, last_name))
     if self.filt.on:
         file_type = self.file_type
     else:
         file_type = None
     result = FileDialogs.request_new_file("Save Shiny New File:",
         default_dir = last_dir, default_name = last_name, file_type = file_type)
     self.save_result(result)
コード例 #6
0
def get_test():
    while 1:
        prefix = ask("Test? ")
        if not prefix:
            sys.exit(0)
        matches = glob("%s-*.py" % prefix)
        if not matches:
            say("Unknown test")
            continue
        if len(matches) > 1:
            say("Ambiguous")
            continue
        return matches[0]
コード例 #7
0
def modal_dialog():
    #global dlog ###
    dlog = ModalDialog(title = "Spanish Inquisition", size = (200, 140))
    dlog.place(Label(text = "Surprise!!!"), left = 20, top = 20)
    field = TextField()
    dlog.place(field, left = 20, top = 60, right = -20)
    field.become_target()
    dlog.default_button = DefaultButton()
    dlog.cancel_button = CancelButton()
    dlog.place(dlog.default_button, right = -20, bottom = -20)
    dlog.place(dlog.cancel_button, left = 20, bottom = -20)
    dlog.center()
    result = dlog.present()
    say("Result =", result)
    dlog.destroy()
コード例 #8
0
 def mouse_down(self, event):
     say("Mouse down:", event.position)
     for event in self.track_mouse():
         if event.kind == 'mouse_drag':
             say("Mouse drag:", event.position)
         elif event.kind == 'mouse_up':
             say("Mouse up:", event.position)
         else:
             say("Other event:", event.kind)
コード例 #9
0
 def draw(self, c, r):
     if self.report_update_rect:
         say("Update rect =", r)
     viewed_rect = self.viewed_rect()
     c.fillcolor = white
     c.fill_rect(viewed_rect)
     c.pensize = 6
     c.fillcolor = red
     x = 20
     y = 10
     for i in range(0, 20):
         c.newpath()
         c.moveto(x - 20, y + 20)
         c.rlineto(80, -20)
         c.rlineto(-40, 60)
         c.closepath()
         c.fill()
         c.stroke()
         x += 80
         y += 80
     ew, eh = self.extent
     c.frame_rect((0, 0, ew, eh))
コード例 #10
0
 def save_result(self, result):
     if isinstance(result, list):
         say("Result:")
         for item in result:
             say("   ", item)
     else:
         say("Result =", result)
     print
     global last_dir, last_name
     if result:
         if isinstance(result, FileRef):
             last_dir = result.dir
             last_name = result.name
         elif isinstance(result, DirRef):
             say("Setting last_dir to", result) ###
             last_dir = result
コード例 #11
0
def show_text(win):
    fields = [win.tf1, win.tf2, win.tf3]
    n = None
    t = application().target
    for i, f in enumerate(fields):
        say("Field %d:" % (i + 1), repr(f.text))
        if f is t:
            n = i + 1
    if n:
        say("Focus: Field %d: Selection = %r" % (n, t.selection))
    else:
        say("No focus")
コード例 #12
0
 def key_down(self, e):
     say(e)
     Window.key_down(self, e)
コード例 #13
0
 def key_down(self, event):
     say(self.name, "Key down:", event)
コード例 #14
0
 def mouse_down(self, event):
     say(self.name, "Mouse down:", event)
コード例 #15
0
 def action():
     say("Slider %s value = %s" % (name, slider.value))
コード例 #16
0
 def mouse_drag(self, event):
     say(self.name, "Mouse drag:", event)
コード例 #17
0
from GUI import Window, ListButton, application
from testing import say

def report():
    print "Value =", but.value

but = ListButton(position = (20, 20),
    titles = ["Item %d" % i for i in xrange(30)],
    action = report)
but.value = 42
win = Window(title = "List Button")
win.add(but)
but.become_target()
win.show()

instructions = """
There should be a list button containing 30 items.
   
Selecting an item should cause its value to be reported. On Windows,
it should be possible to make a selection by typing the first letter
of the title.
"""

say(instructions)
application().run()
コード例 #18
0
ファイル: 02-window.py プロジェクト: mnabeelp/PyGUI
	def key_up(self, event):
		say(self.name, "Key up:", event)
		print
コード例 #19
0
ファイル: 10-view.py プロジェクト: tomihasa/pygui
from GUI import Window, application
from TestViews import TestDrawing, fancy_font as f
from TestInput import TestKeyEvents, TestTrackMouse
from testing import say

class TestView(TestKeyEvents, TestTrackMouse, TestDrawing):
    pass

win = Window(width = 320, height = 200)
view = TestView(width = 320, height = 200)
win.add(view)
view.become_target()
win.show()

say("""
There should be a red triangle, a blue triangle and half a green
triangle, outlined in black, on a yellow background, and three
pieces of text. Each text line should sit accurately on the
baseline drawn under it.

The following events in the view should be reported: mouse down,
mouse drag, mouse up, key down, key up, auto key.
""")

say("Font ascent =", f.ascent, "descent =", f.descent, "height =", f.height)
application().run()
コード例 #20
0
ファイル: 19-file_dialogs.py プロジェクト: JongW/pyLauncher
 def do_new_dir(self):
     say("Doing request_new_directory")
     result = FileDialogs.request_new_directory("Create Sparkling New Directory:",
         default_dir = last_dir, default_name = last_name)
     self.save_result(result)
コード例 #21
0
ファイル: 12-scroll.py プロジェクト: mnabeelp/PyGUI
	def extent(self, w, h):
		self.view.extent = (w, h)
		self.view.invalidate()
		say("Extent =", self.view.extent)
コード例 #22
0
ファイル: 04-button.py プロジェクト: mnabeelp/PyGUI
def say_hello():
    say("Hello, world!")
    btn2.enabled = 1
コード例 #23
0
ファイル: TestInput.py プロジェクト: mnabeelp/PyGUI
 def report_mouse_event(self, mess):
     say(mess)
コード例 #24
0
ファイル: TestInput.py プロジェクト: mnabeelp/PyGUI
 def key_down(self, event):
     which = self.which_key(event)
     if event.auto:
         say("Auto key:", which)
     else:
         say("Key down:", which)
コード例 #25
0
ファイル: TestInput.py プロジェクト: mnabeelp/PyGUI
 def key_up(self, event):
     say("Key up:", self.which_key(event))
コード例 #26
0
def say_goodbye():
  say("Goodbye, world!")
  btn2.enabled = 0
コード例 #27
0
ファイル: 04-button.py プロジェクト: mnabeelp/PyGUI
 def key_down(self, e):
     say(e)
     Window.key_down(self, e)
コード例 #28
0
 def mouse_down(self, event):
     say("Mouse down in", self.title)
コード例 #29
0
ファイル: 26-targeting.py プロジェクト: mnabeelp/PyGUI
 def untargeted(self):
     say("%s untargeted" % self.name)
コード例 #30
0
ファイル: 04-button.py プロジェクト: mnabeelp/PyGUI
def say_goodbye():
    say("Goodbye, world!")
    btn2.enabled = 0
コード例 #31
0
ファイル: 19-file_dialogs.py プロジェクト: tomihasa/pygui
from GUI import FileDialogs
functions = {}
function_names = [
    'request_old_file',
    'request_old_files',
    'request_new_file',
    'request_old_directory',
    'request_old_directories',
    'request_new_directory',
]
for name in function_names:
    if hasattr(FileDialogs, name):
        functions[name] = getattr(FileDialogs, name)
    else:
        say("*** Missing function:", name)

last_dir = DirRef(path=os.path.abspath(os.path.dirname(sys.argv[0])))
last_name = ""

say("last_dir =", last_dir)  ###


class TestWindow(Window):

    file_type = FileType(name="TIFF Image", suffix="tiff")

    def __init__(self):
        Window.__init__(self, size=(200, 200))
        self.filt = CheckBox("%ss only" % self.file_type.name)
        #self.multi = CheckBox("Multiple Selection")
コード例 #32
0
ファイル: 02-window.py プロジェクト: mnabeelp/PyGUI
	def mouse_down(self, event):
		say(self.name, "Mouse down:", event)
コード例 #33
0
ファイル: 19-file_dialogs.py プロジェクト: tomihasa/pygui
 def do_old_dirs(self):
     say("Doing request_old_directories")
     result = FileDialogs.request_old_directories(
         "Open Mouldy Old Directories:", default_dir=last_dir)
     self.save_result(result)
コード例 #34
0
    bounds = (50, 70, 250, 270),
    auto_position = False)
win1.name = "Win1"
win1.show()

win2 = TestWindow(title = "Hello Again!",
    auto_position = False, 
    position = (300, 70),
    size = (400, 300),
    resizable = 0)
win2.name = "Win2"
win2.show()

instructions = """
There should be two windows, one titled 'Hello PyGUI!' positioned at (50, 70)
with size (200, 200) and resizable, and one titled 'Hello Again!' positioned
at (300, 70) with size (400, 300) and not resizable. Both should be movable
and closable.

Mouse down, mouse drag, mouse up, key down and key up events in both windows
should be reported. Mouse drag and mouse up events should be reported for the
window in which the preceding mouse down event occurred, and should be reported
even if the mouse is moved outside the original window.
"""

say(instructions)
say("win1 position =", win1.position, "size =", win1.size)
say("win2 position =", win2.position, "size =", win2.size)

run()
コード例 #35
0
ファイル: 26-targeting.py プロジェクト: mnabeelp/PyGUI
 def targeted(self):
     say("%s targeted" % self.name)
コード例 #36
0
 def mouse_up(self, event):
     say(self.name, "Mouse up:", event)
     print
コード例 #37
0
 def targeted(self):
     say("%s targeted" % self.name)
コード例 #38
0
 def key_up(self, event):
     say(self.name, "Key up:", event)
     print
コード例 #39
0
 def key_up(self, event):
     say("Key up: %s\n" % event)
コード例 #40
0
        Window.key_down(self, e)

win = TWindow(width = 260, height = btn3.bottom + 30, title = "Btns", 
    resizable = 0, zoomable = 0)
    
win.add(btn1)
win.add(btn2)
win.add(btn3)
win.show()

instructions = """
There should be 3 buttons arranged vertically:
1. Title "Hello", natural width, style 'default'
2. Title "Goodbye" in a serif font, width 200, initially disabled
3. Title "Gidday Mate" in red italic, width 200, style 'cancel', right aligned
Pressing button 1 should print "Hello, world!" and enable button 2.
Pressing button 2 should print "Goodbye, world!" and disable button 2.
Pressing button 3 should simulate pressing button 1.
"""

say(instructions)
say("Testing readback of button 3 properties:")
say("title =", btn3.title)
say("font =", btn3.font)
say("color =", btn3.color)
say("just =", btn3.just)
say("End of readback test")
say()

application().run()
コード例 #41
0
 def key_down(self, event):
     say("char = %r key = %r unichars = %r _keycode = 0x%04x" % (
         event.char, event.key, event.unichars, event._keycode))
コード例 #42
0
def say_hello():
  say("Hello, world!")
  btn2.enabled = 1
コード例 #43
0
ファイル: 26-targeting.py プロジェクト: mnabeelp/PyGUI
 def mouse_down(self, e):
     say("%s clicked" % self.name)
     self.become_target()
コード例 #44
0
 def key_down(self, event):
     say("Key down: %s\n" % event)
     if event.char == "E":
         raise Exception("This is a test exception.")
コード例 #45
0
 def key_down(self, event):
     say("Key down in", self.title)
     self.other.show()
コード例 #46
0
 def auto_key(self, event):
     say("Auto key: %s\n" % event)
コード例 #47
0
ファイル: 02-window.py プロジェクト: mnabeelp/PyGUI
	bounds = (50, 70, 250, 270),
	auto_position = False)
win1.name = "Win1"
win1.show()

win2 = TestWindow(title = "Hello Again!",
	auto_position = False, 
	position = (300, 70),
	size = (400, 300),
	resizable = 0)
win2.name = "Win2"
win2.show()

instructions = """
There should be two windows, one titled 'Hello PyGUI!' positioned at (50, 70)
with size (200, 200) and resizable, and one titled 'Hello Again!' positioned
at (300, 70) with size (400, 300) and not resizable. Both should be movable
and closable.

Mouse down, mouse drag, mouse up, key down and key up events in both windows
should be reported. Mouse drag and mouse up events should be reported for the
window in which the preceding mouse down event occurred, and should be reported
even if the mouse is moved outside the original window.
"""

say(instructions)
say("win1 position =", win1.position, "size =", win1.size)
say("win2 position =", win2.position, "size =", win2.size)

run()
コード例 #48
0
 def bing():
     say("Bing!")
コード例 #49
0
ファイル: 02-window.py プロジェクト: mnabeelp/PyGUI
	def mouse_drag(self, event):
		say(self.name, "Mouse drag:", event)
コード例 #50
0
ファイル: 02-window.py プロジェクト: mnabeelp/PyGUI
	def mouse_up(self, event):
		say(self.name, "Mouse up:", event)
		print
コード例 #51
0
ファイル: 02-window.py プロジェクト: mnabeelp/PyGUI
	def key_down(self, event):
		say(self.name, "Key down:", event)
コード例 #52
0
 def untargeted(self):
     say("%s untargeted" % self.name)
コード例 #53
0
ファイル: 04-button.py プロジェクト: mnabeelp/PyGUI
              height=btn3.bottom + 30,
              title="Btns",
              resizable=0,
              zoomable=0)

win.add(btn1)
win.add(btn2)
win.add(btn3)
win.show()

instructions = """
There should be 3 buttons arranged vertically:
1. Title "Hello", natural width, style 'default'
2. Title "Goodbye" in a serif font, width 200, initially disabled
3. Title "Gidday Mate" in red italic, width 200, style 'cancel', right aligned
Pressing button 1 should print "Hello, world!" and enable button 2.
Pressing button 2 should print "Goodbye, world!" and disable button 2.
Pressing button 3 should simulate pressing button 1.
"""

say(instructions)
say("Testing readback of button 3 properties:")
say("title =", btn3.title)
say("font =", btn3.font)
say("color =", btn3.color)
say("just =", btn3.just)
say("End of readback test")
say()

application().run()