Tkinter, repaint?, keep size?

S

skanemupp

so my calculator is almost done for u that have read my previous
posts.
i have some minor problems i have to fix though.

*one is i need to repaint once i have performed a calculation so that
the old results are not left on the screen.
cant find a method for that.

*another is now when i write the expression to be evaluated it resizes
the window as the text grows.
i want the windowsize and all the buttonplacements stay constant, how
do i achieve this?
 
J

jim-on-linux

On Sunday 06 April 2008 13:24,
so my calculator is almost done for u that
have read my previous posts.
i have some minor problems i have to fix
though.

*one is i need to repaint once i have
performed a calculation so that the old
results are not left on the screen. cant
find a method for that.

you can use "wigit".update().
The update method update will redraw wigits
as necessary. If you have the state of the
wigit set to DISABLE then set it to ACTIVE
before using .update().
*another is now when i write the
expression to be evaluated it resizes the
window as the text grows.
i want the windowsize and all the
buttonplacements stay constant, how do i
achieve this?

I like to make a separate frame for buttons.

master = Tk()
master.title =('My Project')

buttonFrame = Frame(master)
buttonFrame.grid(row = 0 column = 1)

you could use a dictionary that contains the
the text and the command and loop the key to
build the buttons. Make x = x+1, y = y+1
for row and column or otherwise as you need.

button = Button(buttonframe, text = key,
width = 2)
button1.grid(row = x, column = y, sticky =
NSEW)

put other stuff into the master using another
frame and grid it in some other column and
or row.

If you make all buttons the same size inside
the frame they will keep their size even if
you have more text then the button will
hold.

There is a lot more but this is the way I
would proceed.


jim-on-linux
http://www.inqvista.com
 
J

jim-on-linux

On Sunday 06 April 2008 13:24,



you can use "wigit".update().
The update method update will redraw
wigits as necessary. If you have the
state of the wigit set to DISABLE then set
it to ACTIVE before using .update().


I like to make a separate frame for
buttons.

master = Tk()
master.title =('My Project')

buttonFrame = Frame(master)
buttonFrame.grid(row = 0 column = 1)

you could use a dictionary that contains
the the text and the command and loop the
key to build the buttons. Make x = x+1, y
= y+1 for row and column or otherwise as
you need.
If you loop the button you should provide a
unique name for each button such as name =
name+str(x)

button = Button(buttonframe, text = key,
width = 2)
button1.grid(row = x, column = y, sticky =
NSEW)

put other stuff into the master using
another frame and grid it in some other
column and or row.

If you make all buttons the same size
inside the frame they will keep their size
even if you have more text then the button
will hold.

There is a lot more but this is the way I
would proceed.
jim-on-linux
http://www.inqvista.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top