简体   繁体   中英

Why my tkinter title bar is not changing?

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()

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()

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

obj = Face_Recognization_System(root)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM