msvcrt - Button problem

George Korony <[email protected]>
Newsgroups gmane.comp.python.tkinter
Message-ID <CAO6RUs10KT49j=wwX=U31W0q2aMDkOE4BuVPO3Wk2hti1DhzHg@mail.gmail.com>
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

_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.