Home > OS >  How do I place text in a button in multiple columns
How do I place text in a button in multiple columns

Time:09-23

I'm working on inserting a button that will span 6 columns with the labels being self-generating, but I want to split these labels into columns. In my head the code would look like this:

from tkinter import *
root = Tk()

Testbtn = Button(root, text="Column0".grid(column=0, row=1), text="Column1".grid(column=1,row=1), etc.)
Testbtn.grid(row=1, column=0, columnspan=6)

I know that's not the correct approach, but I think it illustrates my intent. I'm sure there's someway that this is possible, but I've struggled to find any resources on this particular issue.

CodePudding user response:

You can't split the text of a single button across multiple columns. You can add multiple labels inside the button, but then the button will not work like a proper button anymore, and the text won't align with columns outside of the button.

  • Related