简体   繁体   中英

Tkinter, seemingly random spacing?

I have the following code.

    Label(pop, text = "Timesheet does not exist.").grid(row = 0)

    Label(pop, text = "Create Time sheet?").grid(row = 2, column = 0)

    y = Button(pop, text = "Yes").grid(row = 3, column = 1)
    n = Button(pop, text = "No").grid(row = 3, column = 0)

There's an odd space before the second label. 截图

Anyone have an explanation/solution for this?

There is nothing strange in there: the second button is in column 1, as you ordered it - while the other button, and the first two labels are on column 0. Column 1 should be to the left of column 0.

Use colspan=2 as options to the construction of the Label objects, so that the phrases use both columns, and your second button does not show to the right of both.

Otherwise, just use the pack layout manager instead of grid - since you don't seen to want a table like structure in small dialogs like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM