How to make python window run as "Always On Top"?

Asked
Active3 hr before
Viewed126 times

6 Answers

alwayspythonwindow
90%

A window can be made a topmost window either by setting the hWndInsertAfter parameter to HWND_TOPMOST and ensuring that the SWP_NOZORDER flag is not set, or by setting a window's position in the Z order so that it is above any existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its owners, however, are not changed.,You might also want to search things like "x11 always on top". The underlying concept seems to be that you're giving the window manager a "hint" that it should keep the window above the others. The window manager, however, has free reign and can do whatever it wants.,The x and y specify the new coordinates for the window being set. I wanted the window to stay at its current position when the SetWindowPos function was called on it. Alas, I couldn't find a way to easily pass the current window (x,y) position into the function. I was able to find a work around, but assume I shouldn't introduce a new topic into this question.,So, the -1 makes sure the window is above any other existing topmost windows, but this may not work in all cases. Maybe a -2 beats a -1? It currently works for me. :)

The question is more like which windowing toolkit are you using ? PyGTK and similar educated googling gave me this:

gtk.Window.set_keep_above
load more v
88%

So, you want this window to have an "always on top" quality to it, like you can do with Winamp, right? And you want the window to be not only on top of all the other Tkinter/WxPython/whatever windows, but on top of every running app window currently on your desktop, right?, Center a Tkinter Window 1 , how to opening a new window on clicking menu item? 1 , Tkinter window background 3

There is a thing like that in Tkinter, observe ...

# to create additional windows, you can use Toplevel()
# when you quit the root window the child window also quits

from Tkinter
import *

# create root window
root = Tk()
root.title('root win')
# create child…
load more v
72%

How to make python window run as “Always On Top”?,I need to make a pygame window stay on top of other windows. I found a way to do so on this discussion:,But this doesn’t work in my python code.,For ctypes.windll to work, you have to first configure the types of the function’s arguments (IIRC you don’t have to this if you’re on a 32-bit machine).

# Imports
import pygame as pg
from ctypes
import windll

SetWindowPos = windll.user32.SetWindowPos

pg.init()
win = pg.display.set_mode((200, 30))

x, y = 100, 100
# Pin Window to the top
SetWindowPos(pygame.display.get_wm_info()['window'], -1, x, y, 0, 0, 0x0001)

#Main Loop
run = True
while run:
   for event in pg.event.get():
   if event.type == pg.QUIT:
   run = False
break
load more v
65%

I found a program called TurboTop that can do this from system tray, but in Windows 10, TurboTop list all programs that is not even running in its list, twice. It is a mess.,WindowPinner does it better, but it still include not running programs in the list., 3 Just want to add a better option for this, you can use AquaSnap, it is even easier since you just have to shake the window to make it always on top instead of right clicking/long tap. – Nur Jun 19 '16 at 8:14 ,It's hard for me to trust utilities that are downloaded from somebody's Google Drive or Dropbox account. But I do trust Nir Sofer of Nirsoft. He has a tiny app called WinLister where we can set a window to be always on top. It's not very user friendly if you do it often, but I only occasionally need to pin a window to the top, so it works for me.

You can use AutoHotkey and make a script with just a single line of code:

^ SPACE::Winset, AlwaysOnTop, , A

Using a hotkey for toggling AlwaysOnTop is the most convenient, but if you intent to not use your keyboard, here's a GUI way to do this since it was requested:

#Persistent
Menu, Tray, Add, Toggle Always On Top, AlwaysOnTop

AlwaysOnTop:
   Sleep, 100
Winset, AlwaysOnTop, , A
return
load more v
75%

Use the window.attributes('-topmost', 1) to make the window always on top.,For example, the following changes the title of the root window to 'Tkinter Window Demo':,To ensure that a window is always at the top of the stacking order, you can use the -topmost attribute like this:,Home » Tkinter » Tkinter Window

Let’s start with a simple program that consists of a window:

.wp - block - code {
      border: 0;
      padding: 0;
   }

   .wp - block - code > div {
      overflow: auto;
   }

   .shcb - language {
      border: 0;
      clip: rect(1 px, 1 px, 1 px, 1 px); -
      webkit - clip - path: inset(50 % );
      clip - path: inset(50 % );
      height: 1 px;
      margin: -1 px;
      overflow: hidden;
      padding: 0;
      position: absolute;
      width: 1 px;
      word - wrap: normal;
      word - break: normal;
   }

   .hljs {
      box - sizing: border - box;
   }

   .hljs.shcb - code - table {
      display: table;
      width: 100 % ;
   }

   .hljs.shcb - code - table > .shcb - loc {
      color: inherit;
      display: table - row;
      width: 100 % ;
   }

   .hljs.shcb - code - table.shcb - loc > span {
      display: table - cell;
   }

   .wp - block - code code.hljs: not(.shcb - wrap - lines) {
      white - space: pre;
   }

   .wp - block - code code.hljs.shcb - wrap - lines {
      white - space: pre - wrap;
   }

   .hljs.shcb - line - numbers {
      border - spacing: 0;
      counter - reset: line;
   }

   .hljs.shcb - line - numbers > .shcb - loc {
      counter - increment: line;
   }

   .hljs.shcb - line - numbers.shcb - loc > span {
      padding - left: 0.75 em;
   }

   .hljs.shcb - line - numbers.shcb - loc::before {
      border - right: 1 px solid #ddd;
      content: counter(line);
      display: table - cell;
      padding: 0 0.75 em;
      text - align: right; -
      webkit - user - select: none; -
      moz - user - select: none; -
      ms - user - select: none;
      user - select: none;
      white - space: nowrap;
      width: 1 % ;
   }
import tkinter as tk

root = tk.Tk()
root.mainloop() Code language: Python(python)
load more v
40%

PySimpleGUI runs on Windows, Linux and Mac, just like tkinter, Qt, WxPython and Remi do. If you can get the underlying GUI Framework installed / running on your machine then PySimpleGUI will also run there.,PySimpleGUI Runs on all Python3 platforms that have tkinter running on them. It has been tested on Windows, Mac, Linux, Raspberry Pi. Even runs on pypy3.,Access to nearly every underlying GUI Framework's Widgets.,The Underlying GUI Frameworks & Status of Each

Install

pip install pysimplegui
or
pip3 install pysimplegui
load more v

Other "always-python" queries related to "How to make python window run as "Always On Top"?"