本文整理汇总了Python中tkinter.Tk.rect方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.rect方法的具体用法?Python Tk.rect怎么用?Python Tk.rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.rect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_board_canvas
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import rect [as 别名]
def create_board_canvas(board):
"""
Create a Tkinter Canvas for displaying a Nogogram solution.
Return an instance of Tk filled as a grid.
board: list of lists of {0, 1}
"""
canvas = Tk()
LARGER_SIZE = 600
# dynamically set the size of each square based on cols and rows
n_columns = len(board[0])
n_rows = len(board)
divide = max(n_columns, n_rows)
max_size = LARGER_SIZE / divide
canvas_width = max_size * n_columns
canvas_height = max_size * n_rows
# create the intiial canvas with rows and columns grid
canvas.canvas = Canvas(
canvas, width=canvas_width, height=canvas_height,
borderwidth=0, highlightthickness=0)
canvas.title("Nonogram Display")
canvas.canvas.pack(side="top", fill="both", expand="true")
canvas.rows = len(board)
canvas.columns = len(board[0])
canvas.cell_width = max_size
canvas.cell_height = max_size
canvas.rect = {}
canvas.oval = {}
insert_canvas_grid(canvas, board)
return canvas