'trying to learn python tkinter. but when i run the following code the tkinter window does not open[error: "RMS" is not defined"] "

error: "RMS" is not definedtkinter window is not opening

    from tkinter import*
    class RMS:
    def __init__(self,root):
    self.root=root
    self.root.title("Result Management System")
    self.root.geometry("1350x700+0+0")

    if __name__ == '__main__':
    root = Tk()
    obj=RMS(root)
    root.mainloop()


Solution 1:[1]

The indentation in the code is wrong because of which main is being checked inside the class definition.

The indentation should be as below:

from tkinter import *
class RMS:
    self.root = root
    ....
    self.root.geometry("...")

if __name__ == "main":
    root = TK()
    obj = RMS(root)
    ....

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Manu mathew