How to imitate this table using Tkinter?

前端 未结 2 1849
闹比i
闹比i 2020-12-28 22:13

\"image\"

How to get started with creating a similar table using Tkinter?

2条回答
  •  悲哀的现实
    2020-12-28 23:09

    You have to create an array of ext entries, and lay then out with the "grid" layout manager in a parent frame.

    Developing a Python's class to allow managing the grid and cell contents as a single table, implementing things like __getindex__ to get cell contents, and even some bits of reactive programing, allowing certain cols to change with values changing elsewhere would be the fun part in such a project.

    To create the grid, it is just a matter of:

    import tkinter
    window = tkinter.Tk()
    frame = Tkinter.Frame(window)
    frame.pack()
    
    entries = {} # this 'entries'is what you might want to specify a custom class to manage
                 # for now,a dictionary will do
    
    for j in range(10):
        for i in range(10):
            e = tkinter.Entry(f)
            e.grid(column=i,row=j, borderwidth=0)
            es[i,j] = e
    

    And there you are.

提交回复
热议问题