Reputation: 1800
I need to enable/disable fullscreen and maximized window (--zoomed) in Python 3.x using Tkinter. This is my code
from tkinter import *
tk = Tk()
def fullscreen_on(event):
tk.attributes(--fullscreen, True), repr.event.F11
def fullscreen_off(event):
tk.attributes(--fullscreen, False), repr.event.Escape
photo = PhotoImage(file="image.GIF")
image_label=Label(tk, image=photo)
image_label.grid(row=0, column=2)
tk.mainloop()
It shows the image, but i can't zoom/enable fullscreen.
Upvotes: 1
Views: 1809
Reputation: 2202
You are defining callbacks not binding them to anything in your application. To get a callback to react it needs to be bound to an event (e.g. tk.bind ("<Key>", callback)
)
Please have a look on the documentation of event / event-binding.
You can bind the event like shown in this SO question.
What is it you want to do using repr.event.F11 / repr.event.Escape? print something?
Please make sure to fix your indentation.
You can also bind F11
and Escape
to your callbacks using
tk.bind("<F11>", fullscreen_on)
tk.bind("<Escape>", fullscreen_off)
Upvotes: 1