Home > OS >  Why my tkinter title bar is not changing?
Why my tkinter title bar is not changing?

Time:06-29

I don't understand why the title bar is not changing:

from tkinter import*
from tkinter import ttk
from PIL import Image, ImageTk

    class Face_Recognization_System:
        def _init_(self, root):
            self.root = root
            self.root.title("Simple Prog")
            self.root.geometry("1530x790 0 0")
    
    
    if __name__ == "__main__":
    
        root = Tk()
        obj = Face_Recognization_System()
    
        root.mainloop()

CodePudding user response:

There are two errors the first is in the syntax of Initialization it's

__init__    Not   _init_

Second you should enter the root as an input.

And finally you change it up a little to separate the initialization from the other method .

from tkinter import* 
from tkinter import ttk 
from PIL import Image, ImageTk

class Face_Recognization_System:
    def __init__(self, root):
        self.root = root
    def change(self):
        self.root.title("Simple Prog")
        self.root.geometry("1530x790 0 0")

if __name__ == "__main__":

    root = Tk()
    obj = Face_Recognization_System(root)
    obj.change()

    root.mainloop()

CodePudding user response:

You don't pass your root in parameter of the function. This should be better

obj = Face_Recognization_System(root)
  • Related