2015-05-27 140 views
3

因此,我正在使用tkinter中的嵌入式用户可编辑表。我想给PlateLayout类的自定义设置的行,而不是默认1,2,3 ......更改tkintertable行的名称

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() 

我见过改名列的屏幕截图,但还没有找到一个参考至于如何以编程方式做到这一点。

回答

1

这是从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() 
.... 
+0

这让我足够接近。我特别寻找的部分是'showkeynamesinheader = True',这样我就可以重命名这些行。 – Kyrubas