I make my program with tkinter. Program stores some information in array([[aaa, bbb, ccc],[ddd, eee, fff]]) and I want to display it in 3 text boxes. The first box will contain aaa and ddd, other 2 will contain data in same way. But I don't know how to display it in same level, because if one of the variables contains long text, then it will be displayed in several lines, while variables from other columns will be displayed under each other without empty lines to maintain the same level.
As you can see, the text "cccc" is opposite the text "bbbbb" when it needs to be spaced across blank lines to maintain the same level. I tried to add blank lines to the first and second columns, counting the number of displayed lines in the third column, but couldn't figure out how to do it. Here some code of text boxes and displaying the data.
for item in array:
entry_ip.insert(tk.END, item[0] + "\n")
entry_id.insert(tk.END, item[1] + "\n")
entry_comment.insert(tk.END, item[2] + "\n")
entry_comment = Text(
bd=0,
bg="#FFFFFF",
fg="#000716",
highlightthickness=0
)
entry_comment.place(
x=564.0,
y=167.0,
width=198.0,
height=432.0
)
entry_ip = Text(
bd=0,
bg="#FFFFFF",
fg="#000716",
highlightthickness=0
)
entry_ip.place(
x=207.0,
y=167.0,
width=177.0,
height=432.0
)
entry_id = Text(
bd=0,
bg="#FFFFFF",
fg="#000716",
highlightthickness=0
)
entry_id.place(
x=386.0,
y=167.0,
width=176.0,
height=432.0
)
There's no simple solution when using a text widget, for the very reasons you include in your post. I think a simpler solution would be to use a grid of labels. The only real trick is that you need to add a binding that sets the
wraplengthattribute of each label so that text on the label wraps when it is too long to fit.Here's an example of creating a small grid of labels:
If you need to be able to scroll the list, you can put this frame inside a canvas since the canvas supports scrolling. The following example shows how to do that, based on a technique seen here: Adding a scrollbar to a group of widgets in Tkinter