Optionmenu.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thor

    Optionmenu.

    I have the following function (with some things removed):

    def add_stock():
    stockw=Tk()
    stockw.title("N ew stock solution")
    sofl=Frame(stoc kw)
    sofl.pack()
    u=StringVar()
    u.set("M")
    cw=OptionMenu(s ofl,u,"M","m"," u","v","w")
    cw.grid(row=1,c olumn=2)

    but the widget keeps not showing teh selected option. If I fo the same out
    of the function it works without problem (with stockw.mainloop ()). What am
    I missing? Anybody can point me out to the solution/the right webpage?
    --
    Thor -- Stockholm -- Sverige
  • Michael Peuser

    #2
    Re: Optionmenu.


    "Thor" <thor__00@yahoo .com> schrieb im Newsbeitrag
    news:bj7j47$g5r pn$1@ID-108351.news.uni-berlin.de...[color=blue]
    > I have the following function (with some things removed):
    >
    > def add_stock():
    > stockw=Tk()
    > stockw.title("N ew stock solution")
    > sofl=Frame(stoc kw)
    > sofl.pack()
    > u=StringVar()
    > u.set("M")
    > cw=OptionMenu(s ofl,u,"M","m"," u","v","w")
    > cw.grid(row=1,c olumn=2)
    >
    > but the widget keeps not showing teh selected option. If I fo the same out
    > of the function it works without problem (with stockw.mainloop ()). What am
    > I missing? Anybody can point me out to the solution/the right webpage?
    > --[/color]

    Works fine with Python 2.2 Tk8.3.
    Though it's looks a little bit funny that you initialize Tk inside the
    function and that you use a local variable u for your your interface...


    Kindly
    Michael P


    Comment

    • klappnase

      #3
      Re: Optionmenu.

      Thor <thor__00@yahoo .com> wrote in message news:<bj7j47$g5 rpn$1@ID-108351.news.uni-berlin.de>...[color=blue]
      > I have the following function (with some things removed):
      >
      > def add_stock():
      > stockw=Tk()
      > stockw.title("N ew stock solution")
      > sofl=Frame(stoc kw)
      > sofl.pack()
      > u=StringVar()
      > u.set("M")
      > cw=OptionMenu(s ofl,u,"M","m"," u","v","w")
      > cw.grid(row=1,c olumn=2)
      >
      > but the widget keeps not showing teh selected option. If I fo the same out
      > of the function it works without problem (with stockw.mainloop ()). What am
      > I missing? Anybody can point me out to the solution/the right webpage?[/color]

      Hi,

      I'm not sure if that is your problem here, but I think you should not use pack()
      and grid() inside the same window, otherwise strange things might happen.
      Maybe with sofl.grid() it will work.

      Michael

      Comment

      • Thor

        #4
        Re: Optionmenu.

        Michael Peuser wrote:[color=blue]
        > "klappnase" <klappnase@web. de> schrieb im Newsbeitrag[color=green]
        >> I'm not sure if that is your problem here, but I think you should not use[/color]
        > pack()[color=green]
        >> and grid() inside the same window, otherwise strange things might happen.
        >> Maybe with sofl.grid() it will work.[/color]
        > Yes of course that's it! I posted same advice some days ago. I overlooked
        > it because it - strangely - worked on my machine. But there seems to be
        > different behaviour with Tk 8.3 and 8.4
        >[/color]
        Thanks. I'll check it today. The purpose was to make a windowd with 2 packed
        frams, one qith 'things, and the other with the typical OK-Cancel buttons,
        and then into the first one, put the widgets in a grid. I'll try to redo it
        all using just one.

        About teh u var, actually it is a global one...:D
        --
        Thor -- Stockholm -- Sverige

        Comment

        • Michael Peuser

          #5
          Re: Optionmenu.


          "Thor" <thor__00@yahoo .com> s[color=blue]
          > Thanks. I'll check it today. The purpose was to make a windowd with 2[/color]
          packed[color=blue]
          > frams, one qith 'things, and the other with the typical OK-Cancel buttons,
          > and then into the first one, put the widgets in a grid. I'll try to redo[/color]
          it[color=blue]
          > all using just one.
          >[/color]
          You can use Frames. The rule is: Only one kind of geometry manager per
          frame.

          Kindly
          Michael P




          Comment

          Working...