[Tkinter-discuss] Keeping keyboard focus when window iconified (Win XP) ?
francois schnell
francois.schnell at gmail.com
Tue Jan 10 12:12:31 CET 2006
Hello,
I'm doing a small program to capture screenshots.
But obviously I don't wan my GUI to be visible during the sreenshots and I
want to continue to take sreenshots (with my key binding) even when the
program doesn't have the main focus anymore.
I'm running Python 2.4 on Win XP Family.
Do you have an idea how I could do this ?
Thanks in advance
francois
---
import sys, os, msvcrt, Image, ImageGrab
from Tkinter import *
from os import chdir
def exitapp():
fen1.quit()
fen1.destroy()
i=0
def screenshot(event):
fen1.iconify()
global i
print " screen !"
i= i+1
name = "session1picture"
name= name + str(i)
print name
myscreen= ImageGrab.grab()
myscreen.show()
myscreen.save("C:/"+name+ '.jpeg')
fen1.deiconify()
def invisible():
fen1.iconify()
#GUI launch
fen1=Tk()
fen1.title("Screenshots Tests")
bu11=Button(fen1, text='screenshot')
fen1.bind("s",screenshot)
#fen1.bind_all("s",screenshot)
bu11.bind("<Button-1>",screenshot)
buQuit=Button(fen1, width= 20, text='Quitter',command=exitapp)
bu12=Button(fen1, text='invisible', command=invisible)
bu11.pack()
bu12.pack()
buQuit.pack()
fen1.mainloop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060110/529f3baa/attachment.html
More information about the Tkinter-discuss
mailing list