Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75558

Re: Tkinter grid autosize help

Newsgroups comp.lang.python
Date 2014-08-02 15:53 -0700
References <60f53f24-7ce7-48e5-9fed-7d9ac8841b7f@googlegroups.com>
Message-ID <bfd8ce20-b31f-4b32-a286-5efece366b73@googlegroups.com> (permalink)
Subject Re: Tkinter grid autosize help
From Nicholas Cannon <nicholascannon1@gmail.com>

Show all headers | View raw


On Saturday, August 2, 2014 10:38:28 PM UTC+8, Nicholas Cannon wrote:
> So i have a basic calculator program and i have a label that i want to go across the top to show the numbers and stuff like on a normal calculator. The only way i can make the buttons look neat and then when i keep pressing one the label gets larger and then half the buttons move out of the screen. I cant seem to fix this i have tried columnspan, columnconfigure and heaps of other stuff and non works it always expands. is there a way i can stop the grid from expanding?



ok here is the code:

#window setup
main = Tk()
main.title('Calculator')
main.geometry('300x350')
main.resizable()

app = Frame(main)
app.grid()
app.columnconfigure(0, weight=500)
app.columnconfigure(1, weight=500)


#number view label
number = ' '
numberView = Label(app, text= number)
numberView.grid(row=0, column=0, columnspan=100)

#Num Pad Buttons below
num1 = '1'
button1 = Button(app, text='1', command= lambda: add(num1), width=5)
button1.grid(row=1, column=0)

num2 = '2'
button1 = Button(app, text='2', command= lambda: add(num2), width=5)
button1.grid(row=1, column=1)

num3 = '3'
button1 = Button(app, text='3', command= lambda: add(num3), width=5)
button1.grid(row=1, column=2)

num4 = '4'
button1 = Button(app, text='4', command= lambda: add(num4), width=5)
button1.grid(row=2, column=0)

num5 = '5'
button1 = Button(app, text='5', command= lambda: add(num5), width=5)
button1.grid(row=2, column=1)

num6 = '6'
button1 = Button(app, text='6', command= lambda: add(num6), width=5)
button1.grid(row=2, column=2)

num7 = '7'
button1 = Button(app, text='7', command= lambda: add(num7), width=5)
button1.grid(row=3, column=0)

num8 = '8'
button1 = Button(app, text='8', command= lambda: add(num8), width=5)
button1.grid(row=3, column=1)

num9 = '9'
button1 = Button(app, text='9', command= lambda: add(num9), width=5)
button1.grid(row=3, column=2)

num0 = '0'
button1 = Button(app, text='0', command= lambda: add(num0), width=5)
button1.grid(row=4, column=1)

main.mainloop()

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Tkinter grid autosize help Nicholas Cannon <nicholascannon1@gmail.com> - 2014-08-02 07:38 -0700
  Re: Tkinter grid autosize help MRAB <python@mrabarnett.plus.com> - 2014-08-02 16:33 +0100
  Re: Tkinter grid autosize help Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-02 17:14 +0100
  Re: Tkinter grid autosize help Nicholas Cannon <nicholascannon1@gmail.com> - 2014-08-02 15:53 -0700
    Re: Tkinter grid autosize help Terry Reedy <tjreedy@udel.edu> - 2014-08-02 22:16 -0400
    Re: Tkinter grid autosize help Rick Johnson <rantingrickjohnson@gmail.com> - 2014-08-02 19:24 -0700
    Re: Tkinter grid autosize help Terry Reedy <tjreedy@udel.edu> - 2014-08-02 23:22 -0400
  Re: Tkinter grid autosize help Nicholas Cannon <nicholascannon1@gmail.com> - 2014-08-02 19:36 -0700

csiph-web