Reputation: 43
I'm wondering if there is a way to draw tkinter windows over fullscreen applications, so far I have this:
from tkinter import *
#MAIN WINDOW
root = Tk()
root.title('Test Title')
root.geometry("500x200")
root.wm_attributes('-transparentcolor', root['bg'])
root.wm_attributes("-topmost", 1)
my_frame = Frame(root, width=500, height=200)
my_frame.pack(pady=20, ipady=20, ipadx=20)
#STAT TEXT
my_label = Label(my_frame, font=("Helvetica", 40), fg="#09d2f6")
my_label.config(text="TEST TEXT")
my_label.pack(pady=20)
root.mainloop()
This draws the window on top of all applications but not fullscreen ones. I had the idea to have a loop where it will constantly bring the window forward but have no idea how to do that.
Upvotes: 4
Views: 1544
Reputation: 2234
This code will enable you to choose a picture to view on the fullscreen.
Your code will run in transparent mode above it - no problems
Press Escape key to exit
Try making your widget fullscreen using title button for weird effect!
Had to edit this due to the effect of filedialog
on results.
Moved the attribute setting so that it is invoked after image is loaded.
import os
import tkinter as tk
from tkinter import filedialog
def closer( ev ):
ev.widget.destroy()
# FULL SCREEN
master = tk.Tk()
master.rowconfigure( 0, weight = 1 )
master.columnconfigure( 0, weight = 1 )
master.bind( "<Escape>", closer )
pathfile = filedialog.askopenfilename( title = 'pick mage' )
my_image = tk.PhotoImage( file = pathfile ).zoom( 2,2 )
label = tk.Label( master, text = 'Image', compound = "top", image = my_image )
label.grid(row=0, column=0,sticky='nsew')
master.wm_attributes("-fullscreen", 1)
# removed for first time use - unrem this for second time
# master.wm_attributes("-topmost", 1)
# Your code
root = tk.Toplevel(master)
root.title('Test Title')
root.geometry("500x200")
root.bind( "<Escape>", closer )
root.wm_attributes('-transparentcolor', root['bg'])
root.wm_attributes("-topmost", 1)
my_frame = tk.Frame(root, width=500, height=200)
my_frame.pack(pady=20, ipady=20, ipadx=20)
#STAT TEXT
my_label = tk.Label(my_frame, font=("Helvetica", 40), fg="#09d2f6")
my_label.config(text="TEST TEXT")
my_label.pack(pady=20)
master.mainloop()
Upvotes: 0