擅长:python、mysql、java
<p>您想在这里使用类属性,如下所示</p>
<pre><code>class GuiPart:
def createWindow(self):
root = Tk()
root.resizable(width=False, height=False)
root.title = "Priorities"
root.mainloop()
self.root = root
return root
def display(self):
Label(self.root,
text="testes").grid(row=0, column=1)
</code></pre>
<p>注意<code>root</code>的值是如何分配给<code>self.root</code>,然后再从<code>self.root</code>读取的。<code>self</code>可用于在对象的生存期内存储对象属性。你知道吗</p>