473,587 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter and the re/sizing of columns in a grid


I'm using grid() to lay out a column of Labels and a column of Entries
in a frame. If the user changes an Entry so that it's bigger than its
allotted space, i'd like to widen that column to show the entire
string. I've tried <parentFrame>.c olumnconfigure( 1, minsize=newSize ),
but that doesn't change anything. I'm obviously missing something. How
should i go about this?

More generally, can anyone point me to info on how to do calculated
sizing and resizing of grids?

thanks,
Eric

--
A strong smell of turpentine prevails throughout.
-- Dr. Oliver Wendell Holmes
Nov 22 '05 #1
1 2093
Normally, an entry widget requests horizontal space equal to the value of the
width= option times the "average" character width of the font it displays.

Setting it to 0 makes the entry request exactly enough width to show the string
it contains.

Making them sticky to the east and west sides of their areas make them grow
to the size of the grid cell, if it is larger than their requested size.

Making the grid column have nonzero weight means that if the user resizes
the window to be wider, extra space will be given to the entry widgets.

Perhaps this program does what you're looking for:
#-----------------------------------------------------------------------
from Tkinter import *

t = Tk()
l1 = Label(t, text="String 1:")
l2 = Label(t, text="String 2:")
e1 = Entry(t, width=0); e1.insert("end" , "eggs"); e1.focus()
e2 = Entry(t, width=0); e2.insert("end" , "spam")

l1.grid(row=0, column=0, sticky="w")
l2.grid(row=1, column=0, sticky="w")
e1.grid(row=0, column=1, sticky="ew")
e2.grid(row=1, column=1, sticky="ew")

t.grid_columnco nfigure(1, weight=1, minsize=120)
t.wm_title("ent ry width demo")
t.mainloop()
#-----------------------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDdkcuJd0 1MZaTXX0RAttPAJ sEzGFoWyDnK5Hkv Mg7JW0FGK7I2gCf WFLq
zIg/aIfmtayOA3kD9xV QiDc=
=RIEO
-----END PGP SIGNATURE-----

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5964
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles filling the remainder of the window. Mind you, this is a contrived test application to help me understand Tkinter and Python, not an actual...
2
1712
by: Maboroshi | last post by:
Why when I use the sticky command with the grid layout manager won't my Listbox expand it stays in the center maybe I am missing something but from every tutorial I see it says to do it this way I am running Python2.3.4 on winxp I haven't tried it on linux yet Any Ideas are appreciated Let me know if I am not being clear enough
3
1687
by: Brian Mitchell | last post by:
I hate to ask this question because I'm sure it's been asked before, but how do you automatically resize the columns in a datagrid when the form is resized? Thanks!!
4
11475
by: D | last post by:
I'm sure this is a simple question to the Tkinter experts - I have a very basic Tkinter application that consists of 1 master window and buttons within that window. My problem is that, I need to be able to scroll (up and down) when I get to the point that the buttons go off the screen. What's the easiest way to do this? Thanks in advance.
3
1660
TMS
by: TMS | last post by:
Only a few weeks of school left. This assignment and then a project to go (GASP). I'm writing a spreadsheet. I am required to have each 'cell' do 2 things: Evaluate if it is an equation, or if its a string just print it. Also, it is supposed to print the cell number on a different event reuqest. Right now, I'm trying to get it to...
6
2019
TMS
by: TMS | last post by:
This spreadsheet is almost done, but there is some functionality that is driving me nuts. For instance: a cell, for instance 'a0' is to have 'a0' as a string, but if something is entered like '4+5', that is also there. So, at any time, one could see the cell number a0 or they could click on it and have the equation show as well. Right...
4
17256
by: beginner | last post by:
Hi All, I am really new to Tk and Tkinter. I googled the web but it was not mentioned how to build a data grid with Tkinter. Basically, I want to show an excel like data grid with fixed column and row headers and sortable columns. But the grids can be read-only. Can anyone give some hint on implementing this?
2
3517
by: skanemupp | last post by:
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons have the same distance and size between them as the other 3 columns? and how can i make the top entry end where the 2nd row entry ends(meaning the...
1
1690
by: Francesco Bochicchio | last post by:
Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto: Uhm, I don't think you should use the grid manager to obtain a window like that. The grid manager is for equally distributing widgets both horizontally and vertically. And I'm not sure that you can realize that window look with Tkinter. You could get close by horizontally...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.