tdlg.py 697 Bytes
Newer Older
1 2 3 4
# Function to display a message and wait for the user to hit OK.
# This uses a DLOG resource with ID=256 which is part of the standard
# Python library.
# The ID can be overridden by passing a second parameter.
5 6

from Dlg import *
7 8
from Events import *
import string
9

10
ID = 256
11

12 13 14 15 16
def f(d, event):
	what, message, when, where, modifiers = event
	if what == keyDown and modifiers & cmdKey and \
	   string.lower(chr(message & charCodeMask)) == 'o':
		return 1
17

18 19
def message(str = "Hello, world!", id = ID):
	d = GetNewDialog(id, -1)
20 21
	tp, h, rect = d.GetDialogItem(2)
	SetDialogItemText(h, str)
22 23 24 25 26 27 28 29 30
	while 1:
		n = ModalDialog(f)
		if n == 1: break

def test():
	message()

if __name__ == '__main__':
	test()