Changing tkintertable row names
So I am working on an embedded user editable table in tkinter. I would like to give the PlateLayout class its own rowset instead of the standard 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()
I've seen screenshots of the renamed columns, but couldn't find a link on how to do it programmatically.
+3
source to share
1 answer
This is stated in https://code.google.com/p/tkintertable/wiki/Usage#Change_column_labels
A quick change to your code will allow you to set custom shortcuts;
....
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()
....
+1
source to share