0

I am making a GUI and in my def Makewindow() function i make the different labels i want, but i also want them to be clickable. However the problem is that i want to make the Line_icon to be animated when a different tab such as Display_icon or Settings_icon is clicked. I simply want it glide until its underneath the label (in this case it is a image saying Display) and vice versa for the settings icon.

Heres my code:

from tkinter import *  # Import the tkinter module (For the Graphical User Interface)
from PIL import ImageTk, Image  # PILLOW for image formatting

width = 1920
height = 1080
RootGeo = str(width) + "x" + str(height)  # Make a def for RootGeo so the Root geometry isn't hardcoded


def Display_Click(event):
    print("[DISPLAY_CLICK] [INFO] [DEBUG] Display_icon has been clicked.")


def Settings_click(event):
    print("[SETTINGS_CLICK] [INFO] [DEBUG] Settings_icon has been clicked.")


def PicDir(PictureName):
    __DIRECTORY__ = "C:\\Users\\Gotta\\PythonProjects\\AutoCam\\Icons\\"
    __PICTURE_DIRECTORY__ = __DIRECTORY__ + PictureName

    print("[PICDIR] [INFO] [DEBUG] Photo Directory: ", __PICTURE_DIRECTORY__)
    return __PICTURE_DIRECTORY__


def MakeWindow():
    # -----Root_Attributes-----

    Root = Tk()
    Root.geometry(RootGeo)
    Root.state("zoomed")

    # -----Root_Attributes, Root_Containers-----

    SETTINGS = Image.open(PicDir("Settings.png"))
    SETTINGS_RENDER = ImageTk.PhotoImage(SETTINGS)
    Settings_icon = Label(Root, image=SETTINGS_RENDER)

    Settings_icon.grid(column=0, row=0, padx=(5, 5), pady=(3, 0))
    Settings_icon.bind("<ButtonRelease>", Settings_click)

    DISPLAY = Image.open(PicDir("Display.png"))
    DISPLAY_RENDER = ImageTk.PhotoImage(DISPLAY)
    Display_icon = Label(Root, image=DISPLAY_RENDER)

    Display_icon.grid(column=1, row=0, padx=(0, 5), pady=(3, 0))
    Display_icon.bind("<ButtonRelease>", Settings_click)

    LINE = Image.open(PicDir("Line.png"))
    LINE_RENDER = ImageTk.PhotoImage(LINE)
    Line_icon = Label(Root, image=LINE_RENDER)

    Line_icon.grid(column=0, row=1)

    '''RUN COMMAND: py -3 tkinkertest.py'''
    # -----Root_Containers----- ### NOT WORKING ###

    Root.mainloop()


MakeWindow()

0 Answers0