import W import Wkeys import WASTEconst import re num = re.compile("^-?([1-9][0-9]*|0)(.[0-9]+)?$") w = W.Dialog((200, 92), "Number Dialog") w.text = W.TextBox((4, 4, -4, 18), "Please enter a number:", fontsettings = ("charcoal",0,12,(0,0,0))) def do_key(char, modifiers): if (char != Wkeys.returnkey and char != Wkeys.enterkey): content = w.display.get() w.OK.enable(num.match(content)) w.display = W.EditText((4,22,-4,22), "0", callback = do_key, fontsettings = ("geneva",0,12,(0,0,0))) def done(): print w.display.get() w.close() w.OK = W.Button((-70, 60, 58,20), "OK", done) w.cancel = W.Button((-140,60,58,20), "Cancel", w.close) w.setdefaultbutton(w.OK) w.bind(Wkeys.returnkey, w.OK.push) w.bind(Wkeys.enterkey, w.OK.push) w.open() w.display.ted.WESetAlignment(WASTEconst.weFlushRight)