Tkinter pack bug in Python 2.3

Discussion in 'Python' started by Frank Stajano, Nov 2, 2003.

  1. The compact form of pack behaves differently (and I believe incorrectly)
    compared to the long form. The following two scripts demonstrate it, at
    least on this interpreter:
    Python 2.3.2 (#1, Oct 9 2003, 12:03:29)
    [GCC 3.3.1 (cygming special)] on cygwin


    # First script, no bug

    # I want a canvas inside a frame inside a toplevel, with the canvas
    # filling the toplevel even as I resize the window. This does it.

    from Tkinter import *

    root = Tk()
    frame = Frame(root, bg="lightBlue")
    frame.pack(side=TOP, expand=1, fill=BOTH)
    canvas = Canvas(frame, bg="lightGreen")
    canvas.pack(side=TOP, expand=1, fill=BOTH)

    mainloop()





    # Second script, bug

    # I want a canvas inside a frame inside a toplevel, with the canvas
    # filling the toplevel even as I resize the window. This doesn't do
    # it, and instead makes the canvas a sibling of the frame, instead of
    # a child. (Try resizing the toplevel and you'll see.) Why?

    from Tkinter import *

    root = Tk()
    frame = Frame(root, bg="lightBlue").pack(side=TOP, expand=1, fill=BOTH)
    canvas = Canvas(frame, bg="lightGreen").pack(side=TOP, expand=1, fill=BOTH)

    mainloop()



    Frank (filologo disneyano) http://www-lce.eng.cam.ac.uk/~fms27/
    Frank Stajano, Nov 2, 2003
    #1
    1. Advertising

  2. Frank Stajano

    Peter Otten Guest

    Frank Stajano wrote:

    >
    > The compact form of pack behaves differently (and I believe incorrectly)
    > compared to the long form. The following two scripts demonstrate it, at


    There is no "compact form", see below.

    [...]

    > # Second script, bug
    >
    > # I want a canvas inside a frame inside a toplevel, with the canvas
    > # filling the toplevel even as I resize the window. This doesn't do
    > # it, and instead makes the canvas a sibling of the frame, instead of
    > # a child. (Try resizing the toplevel and you'll see.) Why?
    >
    > from Tkinter import *
    >
    > root = Tk()
    > frame = Frame(root, bg="lightBlue").pack(side=TOP, expand=1, fill=BOTH)


    You are assigning the result of the pack() method, i. e. None, to frame
    here, and consequently Canvas is constructed with None instead of a Frame
    instance as the first argument.

    > canvas = Canvas(frame, bg="lightGreen").pack(side=TOP, expand=1,
    > fill=BOTH)
    >
    > mainloop()


    Peter
    Peter Otten, Nov 2, 2003
    #2
    1. Advertising

  3. "Frank Stajano" <

    Old Perl programmer, hmm... ;-)

    Kindly
    MichaelP
    Michael Peuser, Nov 2, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Josh
    Replies:
    1
    Views:
    2,258
    furliz
    Jul 31, 2003
  2. Fuzzyman
    Replies:
    4
    Views:
    627
    Eric Brunel
    Jan 19, 2004
  3. Tim Jones
    Replies:
    0
    Views:
    364
    Tim Jones
    Jan 31, 2004
  4. H J van Rooyen

    Tkinter pack Problem

    H J van Rooyen, Jul 26, 2006, in forum: Python
    Replies:
    5
    Views:
    357
    H J van Rooyen
    Jul 27, 2006
  5. Alexander Farber

    pack 'C3U*' not same as pack 'C3(xC)*'

    Alexander Farber, Jun 23, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    119
    Ilmari Karonen
    Jun 23, 2005
Loading...

Share This Page