[Tkinter-discuss] Getting an Entry field to stretch

Bob Greschke bob at greschke.com
Thu Jul 4 02:01:50 CEST 2013


Ooooo.  The REALLY Old Way. :)  I'll check it out on Friday.

Thanks!

On 2013-07-03, at 17:30, Lion Kimbro <lionkimbro at gmail.com> wrote:

> 
>   I, too, am a big fan of The Old Way:
> 
> 
> import Tkinter as tk
> 
> root = tk.Tk()
> 
> 
> root.tk.eval("""
> package require Tk
> 
> frame .f
> canvas .f.c -bg red -borderwidth 0 -highlightthickness 0 -yscrollcommand {.f.vert set}
> scrollbar .f.vert -orient vertical -command {.f.c yview}
> 
> pack .f.vert -side right -fill y    -expand 0
> pack .f.c    -side left  -fill both -expand 1
> 
> frame .f.inner -bg blue
> .f.c create window 0 0 -anchor nw -window .f.inner -tags {frame}
> bind .f.c <Configure> {
>   .f.c itemconfigure "frame" -width [ winfo width .f.c ]
>   .f.c config -scrollregion [.f.c bbox all]
> }
> 
> set bg [.f.inner cget -bg]
> grid columnconfigure .f.inner 2 -weight 1
> 
> for {set row 1} {$row < 20} {incr row} {
>   set w .f.inner.rb$row
>   set e1 .f.inner.e1$row
>   set e2 .f.inner.e2$row
>   set e3 .f.inner.e3$row
>   radiobutton $w -text "" -variable active -value $row -bg $bg
>   entry $e1 -bg "white"
>   entry $e2 -bg "white"
>   entry $e3 -bg "white"
>   grid $w -row $row -column 0 -pady 2
>   grid $e1 -row $row -column 1 -sticky ew -pady 2
>   grid $e2 -row $row -column 2 -sticky ew -pady 2
>   grid $e3 -row $row -column 3 -sticky ew -pady 2
> }
> 
> set active 1
> 
> pack .f -side top -fill both -expand 1
> """)
> 
> selection = lambda: int(root.tk.eval("expr {$active}"))
> 
> val = lambda r,c: root.tk.eval(".f.inner.e%s%s get" % (r, c))
> 
> 
>   ;D
> 



More information about the Tkinter-discuss mailing list