0

I have written a little python utility that monitors my typing speed, using pyxhook to hook keyboard events, and a thread timer to update my words per minute number.

Right now it just prints to the terminal every 2 seconds.

How can I make this appear in a little always-on-top gui box?

I tried playing around with tkinter, but the mainloop() function doesn't like my key listener and timer. It seems I can only run the gui OR my event handlers, but not both.

Unfortunately I don't think I can use the keyhandler in tkinter, since I am wanting to capture events from other windows.

Any suggestions?

Brent
  • 16,259
  • 12
  • 42
  • 42
  • You could try putting the components in separate threads and have them communicate with each other via one or more queues as necessary. – martineau Jul 30 '13 at 22:56
  • My first thought was to write the pyxhook data to a pipe and read it from Tkinter. Funnily enough, a quick search resulted in [threads and queues](http://mail.python.org/pipermail/python-list/2012-December/637093.html). There is also [Using Python and Tkinter to capture script output](http://www.executionunit.com/blog/2012/10/26/using-python-and-tkinter-capture-script-output/), but I don't know how that will play with the pyxhook event handlers. – Paulo Almeida Jul 30 '13 at 23:08
  • You can refer to this, http://stackoverflow.com/questions/2883205/freezing-a-dual-mode-gui-and-console-application-using-cx-freeze. May be helpful. – cfh008 Jul 31 '13 at 08:13
  • Thanks. The point is not that I keep the console output, however. I just don't know how to make a simple gui in python. – Brent Jul 31 '13 at 12:31
  • I recommend using [EasyGui](http://easygui.sourceforge.net) which is based on Tkinter and is open-source. – martineau Jul 31 '13 at 19:39

1 Answers1

1

I don't know how to go about doing this in tk, but I've been using PySide lately and I know you could use that.

One way to do it in pyside would be with two classes running in separate threads that communicate using the Qt signal & slot mechanism available in pyside. One class would subclass QThread & get methods that run your existing code & pass the data via signals to the Ui class. The 2nd class would be the one for your gui elements. it would call for an instance of the first class, connect the signals & slots, then start it & begin drawing the display.

resources if you go the pyside route:

Nate Smith
  • 11
  • 1