[Tkinter-discuss] msvcrt - Button problem
George Korony
george.korony at avx.com
Wed Dec 24 21:05:37 CET 2014
I am running Python on Windows. (Do not ask why....I have to!)
In the following code I do register the keyboard hit for the first run of
the program. But if I wait and then restart the run with the button command
the hit does not register.
Of course the program has to be run "directly" - not using the GUI.
Is there a solution for my problem?
Thanks, George
from Tkinter import *
from time import sleep
import msvcrt
class Test(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.parent = master
self.grid()
self.button= Button(self, text="start",
relief="raised",bd=5, padx=10, command=self.doLoop)
self.button.grid()
self.doLoop()
def doLoop(self):
n=5
while n>0:
print "n: ",n
sleep(1)
print "hit: ",msvcrt.kbhit()
n-=1
root=Tk()
app=Test(root)
root.mainloop()
--
George Korony
AVX Corporation
801 17th Ave S.
Myrtle Beach, SC 29578
Phone: 843-444-2859
Fax: 843-444-2809
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20141224/f5b878be/attachment.html>
More information about the Tkinter-discuss
mailing list