I'm having a question related to functions in a class. My goal is to write a program with a Visualization class, which handles all the GUI related stuff with tkinter and another class called SensorHandling, which will mainly test sensors whether they work or not and return the result, which will then be displayed in Visualization. I'm having problems with my GUI class.
I have two different functions inside the class Visualization, namely StartPage and TestingHead_Page. I pass root in order for them to be able to modify my application directly. Now, I want to display the TestingHead_Page with my button bTestingHead, but I get an error that TestingHead_Page is not defined.
How do I go about this problem? Criticism is always appreciated as I want to learn.
import tkinter as tk
from tkinter import ttk
import serial
import platform
import time
LARGEFONT = ("Verdana", 35)
class Visualization:
def StartPage(self, root):
lTitle= ttk.Label(root, text ="Title", font = LARGEFONT)
lTitle.grid(row = 0, column = 1, sticky = "N", padx = 10, pady = 10)
lTitle.config(font = ('Calibri', 32, 'bold'))
lTesting = ttk.Label(root, text = "Testing", font = ('calibri', 20))
lTesting.grid(row = 1, column = 0, padx = 10, pady = 10)
bTestingHead = ttk.Button(root, text = "Testing Head", command = self.TestingHead_Page(root))
bTestingHead.grid(row = 2 , column = 0, padx = 20, pady = 20)
exit = tk.PhotoImage(file = "exit_icon.png")
bExit = ttk.Button(root, text = "exit", image = exit, command = root.destroy)
bExit.image = exit
bExit.place(relx = 1.0, rely = 0.0, anchor = 'ne')
def TestingHead_Page(self, root):
lTitle = ttk.Label(root, text = "Testing Head")
lTitle.grid(row = 0, column = 0, sticky = "W", padx = 10, pady = 10)
bStartPage = ttk.Button(root, text = "Start Page", command = "")
bStartPage.grid(row = 0, column = 1, sticky = "E", padx = 10, pady = 10)
exit = tk.PhotoImage(file = "exit_icon.png")
bExit = ttk.Button(root, text = "exit", image = exit, command = root.destroy)
bExit.image = exit
bExit.place(relx = 1.0, rely = 0.0, anchor = 'ne')
if __name__ == "__main__":
root = tk.Tk()
guiref = StartPage(self, root)
tk.mainloop()
#class SensorHandling():