Python 2.7 无法使用tkinter(Python)生成表

Python 2.7 无法使用tkinter(Python)生成表,python-2.7,tkinter,Python 2.7,Tkinter,我是一个完全的新手,正在努力学习一些python。 试图使用tkinter模块创建表,但我遇到了以下问题: (我正在尝试查看Table类是否可以使用提供的/默认参数成功实例化可视表对象) 守则: from Tkinter import * class Table : ## contructor with the attributes def__init__(self,window,color='black',net_color='green',width=600,height=

我是一个完全的新手,正在努力学习一些python。 试图使用tkinter模块创建表,但我遇到了以下问题: (我正在尝试查看Table类是否可以使用提供的/默认参数成功实例化可视表对象)

守则:

from Tkinter import *

class Table :
## contructor with the attributes
        def__init__(self,window,color='black',net_color='green',width=600,height=400,vertical_net=False,horizontal_net=False):
        self.width=width
        self.height=height
        self.color=color

my_table = Table(window)
这就是我得到的:

Traceback (most recent call last):
  File "table.py", line 13, in <module>
    my_table = Table(window)
NameError: name 'window' is not defined
回溯(最近一次呼叫最后一次):
文件“table.py”,第13行,在
我的桌子=桌子(窗口)
名称错误:未定义名称“窗口”

非常感谢任何对我的帮助

这里的问题是,
窗口
尚未定义且从未打开。您可以通过执行以下操作来解决此问题:

1) 在
my_table=表格(窗口)
行之前添加此行:

window = Tk() #create the window
window.mainloop() #open the window
2) 在
my_table=表格(窗口)
行之后添加此行:

window = Tk() #create the window
window.mainloop() #open the window

另外,在
\uuuu init\uuuu()前面缺少一个空格

谢谢。我意识到了我在概念上的错误。