gpt4 book ai didi

python - 更改 tkintertable 行的名称

转载 作者:行者123 更新时间:2023-11-28 18:38:05 25 4
gpt4 key购买 nike

所以我正在 tkinter 中开发一个嵌入式用户可编辑表。我想为 PlateLayout 类提供一组自定义行,而不是默认的 1,2,3...

import Tkinter as tk
from tkintertable.Tables import TableCanvas


class PlateLayout:
def __init__(self, parent):
self.parent = parent

def make_frame(self):
self.the_frame = tk.Frame(self.parent)
self.the_frame.pack()

def make_table(self):
self.the_table = TableCanvas(self.the_frame, rows=8, cols=12)
self.the_table.createTableFrame()

def make_all(self):
self.make_frame()
self.make_table()

root_win = tk.Tk()
app = PlateLayout(root_win)
app.make_all()
root_win.mainloop()

我看过重命名列的屏幕截图,但没有找到关于如何以编程方式执行此操作的引用。

最佳答案

这是从 https://code.google.com/p/tkintertable/wiki/Usage#Change_column_labels 引用的

快速更改代码即可设置自定义标签;

....
def make_table(self):
self.the_table = TableCanvas(self.the_frame, rows=8, cols=12)

# Lets peek at the current labels, delete in production
print self.the_table.model.columnlabels
self.the_table.model.columnlabels['1'] = "Custom Col"

self.the_table.createTableFrame()
....

关于python - 更改 tkintertable 行的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30472631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com