本文整理汇总了Python中Tkinter.Frame.grid_slaves方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid_slaves方法的具体用法?Python Frame.grid_slaves怎么用?Python Frame.grid_slaves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Frame
的用法示例。
在下文中一共展示了Frame.grid_slaves方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Table
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_slaves [as 别名]
class Table(Frame):
def __init__(self, master, columns, column_weights=None, column_minwidths=None, height=500, minwidth=20, minheight=20, padx=5, pady=5, cell_font=None, cell_foreground="black", cell_background="white", cell_anchor=W, header_font=None, header_background="white", header_foreground="black", header_anchor=CENTER, bordercolor = "#999999", innerborder=True, outerborder=True, stripped_rows=("#EEEEEE", "white"), on_change_data=None, mousewheel_speed = 2, scroll_horizontally=False, scroll_vertically=True):
outerborder_width = 1 if outerborder else 0
Frame.__init__(self,master, bd= 0)
self._cell_background = cell_background
self._cell_foreground = cell_foreground
self._cell_font = cell_font
self._cell_anchor = cell_anchor
self._stripped_rows = stripped_rows
self._padx = padx
self._pady = pady
self._bordercolor = bordercolor
self._innerborder_width = 1 if innerborder else 0
self._data_vars = []
self._columns = columns
self._number_of_rows = 0
self._number_of_columns = len(columns)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(1, weight=1)
self._head = Frame(self, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd= 0)
self._head.grid(row=0, column=0, sticky=E+W)
header_separator = False if outerborder else True
for j in range(len(columns)):
column_name = columns[j]
header_cell = Header_Cell(self._head, text=column_name, borderwidth=self._innerborder_width, font=header_font, background=header_background, foreground=header_foreground, padx=padx, pady=pady, bordercolor=bordercolor, anchor=header_anchor, separator=header_separator)
header_cell.grid(row=0, column=j, sticky=N+E+W+S)
add_scrollbars = scroll_horizontally or scroll_vertically
if add_scrollbars:
if scroll_horizontally:
xscrollbar = Scrollbar(self, orient=HORIZONTAL)
xscrollbar.grid(row=2, column=0, sticky=E+W)
else:
xscrollbar = None
if scroll_vertically:
yscrollbar = Scrollbar(self, orient=VERTICAL)
yscrollbar.grid(row=1, column=1, sticky=N+S)
else:
yscrollbar = None
scrolling_area = Scrolling_Area(self, width=self._head.winfo_reqwidth(), height=height, scroll_horizontally=scroll_horizontally, xscrollbar=xscrollbar, scroll_vertically=scroll_vertically, yscrollbar=yscrollbar)
scrolling_area.grid(row=1, column=0, sticky=E+W)
self._body = Frame(scrolling_area.innerframe, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd= 0)
self._body.pack()
def on_change_data():
scrolling_area.update_viewport()
else:
self._body = Frame(self, height=height, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd= 0)
self._body.grid(row=1, column=0, sticky=N+E+W+S)
if column_weights is None:
for j in range(len(columns)):
self._body.grid_columnconfigure(j, weight=1)
else:
for j, weight in enumerate(column_weights):
self._body.grid_columnconfigure(j, weight=weight)
if column_minwidths is not None:
for j, minwidth in enumerate(column_minwidths):
if minwidth is None:
header_cell = self._head.grid_slaves(row=0, column=j)[0]
minwidth = header_cell.winfo_reqwidth()
self._body.grid_columnconfigure(j, minsize=minwidth)
else:
for j in range(len(columns)):
header_cell = self._head.grid_slaves(row=0, column=j)[0]
minwidth = header_cell.winfo_reqwidth()
self._body.grid_columnconfigure(j, minsize=minwidth)
self._on_change_data = on_change_data
def _append_n_rows(self, n):
number_of_rows = self._number_of_rows
number_of_columns = self._number_of_columns
for i in range(number_of_rows, number_of_rows+n):
list_of_vars = []
for j in range(number_of_columns):
var = StringVar()
list_of_vars.append(var)
#.........这里部分代码省略.........