Search code examples
pythonuser-interfacetkintertkinter-canvastkinter-entry

i want my tool stay display on desktop even if i click on browser or other program


i made a simple Tool with Tkinter, and i want this tool to stay display on desktop even if i click on browser or other program ,so i want the tool always stay on front until i click minimize . thank you .

import pyautogui as p
import time
import tkinter
from tkinter import ttk
from tkinter import *

top = Tk()
top.title("past")

def brk():
    

    #from dofus-map.com
    time.sleep(0.2)
    p.moveTo(238,627)
    p.tripleClick()
    p.hotkey('ctrl','c')
    #from website
    time.sleep(0.1)
    p.moveTo(84,742)
    p.tripleClick()
    p.hotkey('ctrl','v')
    #to game
    time.sleep(0.1)
    p.click(88,801)
    p.tripleClick()




but = Button(text="past",width = 6, height = 3, font = ("blood",15,""), bg = "lightgreen", fg = "black" , command=brk)
but.pack()


top.mainloop()


Solution

  • Try using this

    top.attributes("-topmost", True)
    

    This will always keep your window on top of the screen, regardless of what other programs you use.