我的设计功能与root.title(winTitle)
类似。这是我的代码:
from tkinter import *
class UIWindow():
def __init__(self):
Tk()
def setWindowTitle(winTitle):
self.title(winTitle)
但是当我运行它时,它会给出错误:
TypeError: setWindowTitle() takes one positional argument but two was given
我该如何解决这个问题?
答案 0 :(得分:1)
from Tkinter import *
class UIWindow():
def __init__(self, *arg, **kwarg):
self.root=Tk(*arg, **kwarg)
def setWindowTitle(self, winTitle):
self.root.title(winTitle)
x = UIWindow()
x.setWindowTitle("This is the Test Title.")
x.root.mainloop()
您缺少自我。这是显示带标题的窗口的小例子。