[Tkinter-discuss] Keeping keyboard focus when window iconified (Win XP) ?
Amanjit Gill
amanjit.gill at gmx.de
Tue Jan 10 13:05:38 CET 2006
Hi there
ui updates with tkinter will only happen IMHO after your method returns.
use the widget.after() method (check
http://infohost.nmt.edu/tcc/help/pubs/tkinter/universal.html). Something
like this:
def screenshot(event):
fen1.iconify()
fen1.after(200,doscreen)
i=0
def doscreen():
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()
If you want ro remove the taskbar entry you can apply the win32 style
MYWS_EX_NOACTIVATE (at least with win2000 or later). This requires C
programming, and is just the first thing that came into my mind.
cheers
Amanjit Singh Gill
>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()
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Tkinter-discuss mailing list
>Tkinter-discuss at python.org
>http://mail.python.org/mailman/listinfo/tkinter-discuss
>
More information about the Tkinter-discuss
mailing list