stay on top of any window

Hi,
I would like to know if it is possible to force a wxpython frame to stay on top
of a specific window, which was not created by the python code running, e.g.
force a (wxpython-) window to stay on top of the outlook main window (on XP/7).
Best regards, Christian

Hi,
You need wx.STAY_ON_TOP style:

class MainFrame(wx.Frame):
  def __init__(self, parent, log, config, inipath):
    fOnTop = config.getboolean('Global','AlwaysOnTop') and wx.STAY_ON_TOP or 0
    wx.Frame.__init__(self, parent, -1,
                    style=wx.DEFAULT_FRAME_STYLE|wx.CLIP_CHILDREN | fOnTop,
              title="..." )

Regards,
M.A.

···

On Fri, Oct 19, 2012 at 5:16 PM, Christian K. <ckkart@hoc.net> wrote:

Hi,
I would like to know if it is possible to force a wxpython frame to stay on top
of a specific window, which was not created by the python code running, e.g.
force a (wxpython-) window to stay on top of the outlook main window (on XP/7).
Best regards, Christian

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

Minas Abrahamyan <minas.subs <at> gmail.com> writes:

Hi,
You need wx.STAY_ON_TOP style:

class MainFrame(wx.Frame):
  def __init__(self, parent, log, config, inipath):
    fOnTop = config.getboolean('Global','AlwaysOnTop') and wx.STAY_ON_TOP or 0
    wx.Frame.__init__(self, parent, -1,
                    style=wx.DEFAULT_FRAME_STYLE|wx.CLIP_CHILDREN | fOnTop,
              title="..." )

Tthe problem is that I do not have a parent window and that STAY_ON_TOP does not
help. Eventually it should behave like a modal dialog which cannot be lowered
below its parent window. I guess I could get the window handle with help of
pywin32 but can I use that as parent for wx.Frame?

Chrisitan

I may not have been very clear. Actually I meant something like the following.
This works only if the parent window is not minimized. I cannot figure out
currently how to restore it. Only a wx.TopLevelWindow has a Maximize method. Any
ideas?

import win32gui
import wx

windows = []
win32gui.EnumWindows(lambda a,b: b.append(a), windows)

for w in windows:
    if 'Outlook' in win32gui.GetWindowText(w):
        print w, win32gui.GetWindowText(w)
        break
    
p = wx.PySimpleApp()
parent = wx.Window_FromHWND(None, w)
print parent
f = wx.Frame(parent, -1, 'always on top',
             style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT)
f.Show()
p.MainLoop()

Once more answering to myself: I found out how to raise the window using pywin32.

import win32con
import win32gui

win32gui.ShowWindow(whnd, win32con.SW_SHOWNORMAL) # SW_RESTORE does not work

Christian

Hi Christian,

I may not have been very clear. Actually I meant something like the following.
This works only if the parent window is not minimized. I cannot figure out
currently how to restore it. Only a wx.TopLevelWindow has a Maximize method. Any
ideas?

import win32gui
import wx

windows =
win32gui.EnumWindows(lambda a,b: b.append(a), windows)

for w in windows:
     if 'Outlook' in win32gui.GetWindowText(w):
         print w, win32gui.GetWindowText(w)
         break
     p = wx.PySimpleApp()
parent = wx.Window_FromHWND(None, w)
print parent
f = wx.Frame(parent, -1, 'always on top',
              style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT)
f.Show()
p.MainLoop()

Really just guessing as I don't use win32gui stuff, but maybe the following helps, i.e. use a function on your "w" variable which does maximize.

Werner

···

On 19/10/2012 16:47, Christian K. wrote: