当我尝试绘制游戏板时,来自tkinter的回溯

时间:2017-03-18 04:03:01

标签: python tkinter

当我为奥赛罗游戏画游戏板时,下面是来自tkinter的追溯。

Traceback (most recent call last):
  File "C:/Users/SYN/Desktop/o_game.py", line 16, in <module>
    start.display_board(gamestate)
  File "C:/Users/SYN/Desktop\o_gui.py", line 131, in display_board
    self.draw_board(gamestate)
  File "C:/Users/SYN/Desktop\o_gui.py", line 145, in draw_board
    columnspan = 3)
  File "F:\PYTHON\lib\tkinter\__init__.py", line 2073, in grid_configure
    + self._options(cnf, kw))

_tkinter.TclError:不明确的选项“-col”:必须是-column,-columnspan,-in,-ipadx,-ipady,-padx,-pady,-row,-rowspan或-sticky

以下是绘图板的相关代码。

def draw_board(self, gamestate):
    '''draw the game board, ready to resize'''
    self.gamestate = gamestate
    self.rows = gamestate.row
    self.cols = gamestate.col
    self.Ocanvas = tkinter.Canvas(master = self._root_window,
                                 width = 600, height = 600,
                                 background = 'pink')

    self.Ocanvas.grid(row = 1, col = 0, padx = 10, pady = 10,
                     sticky = tkinter.N + tkinter.S + tkinter.E + tkinter.W,
                     columnspan = 3)

    self.Ocanvas.bind('<Button-1>', self.on_canavs_clicked)
    self.Ocanvas.bind('<Configure>', self.on_canvas_resized)

    self._root_window.columnconfigure(0, weight = 1)
    self._root_window.columnconfigure(1, weight = 1)
    self._root_window.columnconfigure(2, weight = 1)
    self._root_window.rowconfigure(0, weight = 1)
    self._root_window.rowconfigure(1, weight = 1)

步骤self.canvas.grid似乎存在一些问题。但它有什么问题?

0 个答案:

没有答案