This is what I want to do...almost:

-----
#! /usr/bin/env python                                                          

from Tkinter import *

Root = Tk()

RowActiveVar = StringVar()

LastWidth = 0
Count = 0
def iChanged(e = None):
    global LastWidth
    global Count
    Count += 1
    Geom = Root.geometry()
    Width = int(Geom[:Geom.index("x")])
    if Width == LastWidth:
        return
#    Root.geometry("%d%s"%((Width+ScrollWidth+2), Geom[Geom.index("x"):]))      
    LastWidth = Width+ScrollWidth+2
    return

RowSub = Frame(Root, bg = "blue")
RowCan = Canvas(RowSub, bg = "red")
RowCan.pack(side = LEFT, expand = YES, fill = BOTH)
Scroll = Scrollbar(RowSub, orient = VERTICAL, command = RowCan.yview, \
        width = 15)
Scroll.pack(side = RIGHT, fill = Y)
ScrollWidth = int(Scroll.cget("width"))+int(Scroll.cget("bd"))*2+ \
        int(Scroll.cget("highlightthickness"))*2
RowCan.configure(yscrollcommand = Scroll.set)
RowSub.pack(side = TOP, expand = YES, fill = BOTH)

Y = 0
for I in xrange(1, 20):
    SSub = Frame()
    LRb = Radiobutton(SSub, text = "", variable = RowActiveVar, \
            value = str(I), bg = Frame().cget("bg"))
    LRb.pack(side = LEFT)
    LEnt = Entry(SSub, width = 15, bg = "white")
    LEnt.pack(side = LEFT)
# This one...                                                                   
    LEnt = Entry(SSub, width = 40, bg = "white")
    LEnt.pack(side = LEFT, expand = YES, fill = X)
    LEnt = Entry(SSub, width = 10, bg = "white")
    LEnt.pack(side = LEFT)
    SSub.pack(expand = YES, fill = X)
    RowCan.create_window(0, Y, anchor = "nw", window = SSub)
    RowCan.update()
    L,T,R,B = RowCan.bbox(ALL)
    Y = B
RowCan.configure(scrollregion = (0, 0, R, B))
Geom = Root.geometry()
LastWidth = R+ScrollWidth+2
Root.geometry("%d%s"%(LastWidth, Geom[Geom.index("x"):]))
Root.bind("<Configure>", iChanged)

Root.mainloop()
-----

I'd like the center column of Entry fields to get longer as the window width is 
changed.  I have a static non-scrollbar version of this that works fine (Entry 
fields in a Frame that is packed TOP into another Frame -- everyone set to 
expand and fill as needed), but throwing the Canvas and the scrolling in there 
seems to be a problem.  I have another version that uses a Text() to hold all 
of the rows, but I can't get that to work either.  The iChanged() stuff really 
doesn't do anything at this point.  I was thinking that might be where a 
solution goes.  Can it be done?

Thanks!

Bob

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to