Re: [python-win32] keep tkinter window always on top

2005-08-21 Thread Mark Hammond
 Does anyone know how to keep a tkinter window always on top, despite
 attempts to focus other windows?  Here is my failed attempt.  I've
 tried both tkinter-only and win32-specific solutions.  For this code,
 the window does stay in front of the dos box it's launched from if I
 try to focus the dos box, but that's the only one it stays in front
 of.  Thanks, Benjamin

Try something like:

import win32gui
win32gui.SetWindowPos(hWnd, win32con.HWND_TOPMOST, 0,0,0,0,
win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)

Mark

___
Python-win32 mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] keep tkinter window always on top

2005-08-21 Thread Benjamin Rutt
Mark Hammond [EMAIL PROTECTED] writes:

 Does anyone know how to keep a tkinter window always on top, despite
 attempts to focus other windows?  Here is my failed attempt.  I've
 tried both tkinter-only and win32-specific solutions.  For this code,
 the window does stay in front of the dos box it's launched from if I
 try to focus the dos box, but that's the only one it stays in front
 of.  Thanks, Benjamin

 Try something like:

 import win32gui
 win32gui.SetWindowPos(hWnd, win32con.HWND_TOPMOST, 0,0,0,0,
 win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)

Argh, it turns out that I needed to do

hwnd = int(eval(root.wm_frame()))

not

hwnd = root.winfo_id()

So much for trusting the first code for tkinter root window-window
handle I come across on the net. :)

Thanks, it almost works now.  Just one last problem, while it is
always on top, it doesn't always have the input focus.  Any recipes
for that?  That is, I want it to steal the focus if it doesn't have
it.  Thanks,
-- 
Benjamin Rutt

___
Python-win32 mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] keep tkinter window always on top

2005-08-21 Thread Benjamin Rutt
Mark Hammond [EMAIL PROTECTED] writes:

 Does anyone know how to keep a tkinter window always on top, despite
 attempts to focus other windows?  Here is my failed attempt.  I've
 tried both tkinter-only and win32-specific solutions.  For this code,
 the window does stay in front of the dos box it's launched from if I
 try to focus the dos box, but that's the only one it stays in front
 of.  Thanks, Benjamin

 Try something like:

 import win32gui
 win32gui.SetWindowPos(hWnd, win32con.HWND_TOPMOST, 0,0,0,0,
 win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)

Hmm, that didn't work either.  Below is the full program I used.  Do
you think the fact that it's being run from a tkinter callback is why
it isn't working?  Like maybe tkinter is stealing/inhibiting these
Windows API calls while it's running the callbacks?

Running WinXP SP2, python 2.4.1, win32all build 204 here.

#!/usr/bin/env python

from Tkinter import *
import win32ui, win32con, win32gui

root = None
reps = 0

def show():
hwnd = root.winfo_id()
win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0,0,0,0,
  win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)

def reshow():
global reps
reps += 1
print 'reshow(%d)' % (reps)
show()
if reps  100:
root.after(100, reshow)
else:
root.destroy()

root = Tk()
root.config(width=400, height=400)
show()
root.after(100, reshow)
root.mainloop()

___
Python-win32 mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-win32