为什么我的TKINTER标题栏没有更改?

发布于 2025-02-11 16:00:46 字数 486 浏览 5 评论 0原文

我不明白为什么标题栏没有改变:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橙味迷妹 2025-02-18 16:00:46

有两个错误,第一个是在初始化的语法中,

__init__    Not   _init_

第二个错误是您应该作为输入输入根。

最后,您将其更改一些,以将初始化与其他方法分开。

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

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()
二智少女 2025-02-18 16:00:46

您不会在功能的参数中传递根。这应该更好

obj = Face_Recognization_System(root)

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

obj = Face_Recognization_System(root)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文