In my Tkinter project, there is one functionality which goes like this:
- User clicks on a button
- A new settings window opens
- The settings window has it's own widgets and related functions
I used the Toplevel
call from Tkinter to create a new window. The problem that occurs is that even though I am able to see the widgets on the new window, they aren't working. So far I have a button with an image on it. The image does not appear (I tested for the path and it is correct), and also nothing happens when I click it. I have tested this window as a seperate Tkinter project so I know it works. It does not work when called from a different file.
This is the main code:
from tkinter import*
from datetime import datetime
from tkinter import ttk
import os
import settingsController
root = Tk()
root.title("Main")
root.geometry("480x320")
root.resizable(0, 0)
root.configure(background="white")
root.overrideredirect(0)
settings_logo = PhotoImage(file="settings_icon.gif")
settings_button = Button(root, image=settings_logo,command=lambda: settingsController.begin(root))
settings_button.place(x= 277, y= 220)
settings_label = Label(root, fg = "black", font = "Times 10 bold", text="Settings", background= "white")
settings_label.place(x = 274, y = 275, width= 60, height= 25)
root.mainloop()
And this is the relevant part of the settingsController
from tkinter import *
root = None
def begin(rootWindow):
global root
root = Toplevel(rootWindow)
root.attributes('-fullscreen', True)
# root.geometry("400x400")
# root.title("Settings")
root.configure(bg="white")
screen_width = rootWindow.winfo_screenwidth()
screen_height = rootWindow.winfo_screenheight()
img = PhotoImage(file="icon_50x50.png")
btn = Button(root,image=img,bg="white",command=foo,height=50,width=50)
btn.place(x=0,y=0)
print("Screen width:", screen_width)
print("Screen height:", screen_height)
How do I accomplish this? This is a big project and I've been specifically asked to create seperate files, so I cannot dump all of this in just 1 file.