python - Remove space between buttons in tkinter -




i'm making calculator in tkinter , i'm trying buttons right next each other this:

calculator

this code buttons far:

entry(root).grid(row=0, column=0, columnspan=5)  button(root, text='c').grid(row=1, column=0, sticky='w') button(root, text='ce').grid(row=1, column=1, sticky='w')  button(root, text='0').grid(row=5, column=0)  columncount = 0  x in range(1, 4):     button(root, text=str()).grid(row=4, column=columncount)     columncount += 1  columncount = 0  x in range(4, 7):     button(root, text=str(x)).grid(row=3, column=columncount)     columncount += 1  columncount = 0  x in range(7, 10):     button(root, text=str(x)).grid(row=2, column=columncount)     columncount += 1 

how remove space?

you need request widgets expand fill space given them. grid geometry manager can control sticky attribute. give string containing 1 or more of "n", "s", "e", , "w", representing points of compass (north, south, east, west)

for example:

button(root, text=str()).grid(row=4, column=columncount, sticky="nsew") 

you need every button.

if literally want no space between buttons, may need turn of highlight ring used show button has keyboard focus. controlled highlightthickness attribute, defaults 1 pixel.

button(..., highlightthickness=0) 

it's recommended not that, since ring important being able use app without mouse.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -