I am working on a program with a window that needs to be fullscreen on all plugged-in Monitors and/or external displays. Is there any way I can do this in Tkinter or do I have to use a different library? So far I have managed to get the window in Fullscreen on my main display but I also need it on the other one(s). This is my code so far:
def create_screencanvas():
global master_screen
master_screen = Toplevel(mywindow)
picture_frame = Frame(master_screen, background = "blue")
picture_frame.pack(fill=BOTH, expand=YES)
global screenCanvas
screenCanvas = Canvas(picture_frame, cursor="cross", bg="grey5")
screenCanvas.pack(fill=BOTH, expand=YES)
master_screen.attributes('-fullscreen', True)#Fullscreen on main display but not others
master_screen.attributes('-alpha', .3)
master_screen.lift()
master_screen.attributes("-topmost", True)
mywindow = Tk()
mywindow.title("New Project")
mywindow.geometry("780x640")
mywindow.minsize(540, 420)
mywindow.configure(bg="blue")
mybtn = Button(text="activate", command=create_screencanvas, cursor="cross")
mybtn.pack() #Button opens the fullscrean window
mywindow.mainloop()
For screenshot taking purposes, you can make your Toplevel
window cover all the displays by changing manually its geometry instead of making it fullscreen. So, remove
master_screen.attributes('-fullscreen', True)
and replace it with
w = master_screen.winfo_screenwidth()
h = master_screen.winfo_screenheight()
master_screen.geometry(f"{w}x{h}+0+0")
However, your window now has unwanted decorations. Depending on the OS you are using, you can either use
master_screen.overrideredirect(True)
or, if you are using Linux (in which case, overrideredirect
might not allow you to have window transparency),
master_screen.attributes('-type', 'dock')
In both cases, you no longer need
master_screen.attributes("-topmost", True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.