473,796 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 18 '05 #1
4 2085

"Thor" <th******@yahoo .com> schrieb im Newsbeitrag
news:bj******** ****@ID-108351.news.uni-berlin.de...
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?
--


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
Jul 18 '05 #2
Thor <th******@yahoo .com> wrote in message news:<bj******* *****@ID-108351.news.uni-berlin.de>...
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?


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
Jul 18 '05 #3
Michael Peuser wrote:
"klappnase" <kl*******@web. de> schrieb im Newsbeitrag
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.

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

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
Jul 18 '05 #4

"Thor" <th******@yahoo .com> s
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.

You can use Frames. The rule is: Only one kind of geometry manager per
frame.

Kindly
Michael P


Jul 18 '05 #5

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

Similar topics

1
2115
by: stewart | last post by:
I'm writing an app that requires a 3-level optionMenu display. Basically I'm showing the contents of a 3-dimensional matrix. You choose the first level in the first optionMenu, the 2nd level in the next level, and the 3rd level in the last optionMenu. Let's call them Continent,country,state. continentList = countryList = ,,] stateList = ,,],] When I open the window, all is well. I can display the following as default
2
4638
by: Stewart Midwinter | last post by:
I would like to link the contents of three OptionMenu lists. When I select an item from the first list (call it continents), the contents of the 2nd list (call it countries) would update. And in turn the contents of the 3rd list (call it states would be updated by a change in the 2nd list. If anyone can share a recipe or some ideas, I'd be grateful! Here's some sample code that displays three OptionMenus, but doesn't update the list...
2
11350
by: Jeffrey Barish | last post by:
Is there a way to fill the values in an OptionMenu dynamically? I need something like the add_command method from Menu. Is there a better way to implement a pull-down list? -- Jeffrey Barish
0
1127
by: Martin | last post by:
I'd like to change the way the button that appears in an OptionMenu instance, but have been umable to figure out how to do this. The default constructor won't allow you to pass an 'image=" keyword. The standard visual I am talking about is displayed as basically a small rectangle drawn in relief inside a larger one. I'd like to replace that with something like a downward pointing arrowhead. I tried creating a OptionMenu-like class of...
0
1952
by: mariox19 | last post by:
Hello, The Tkinter OptionMenu widget has me a bit confused. I have set up an OptionMenu to expand along the X axis as the window expands. What I find though is that the width of the submenu displaying the list of items in the menu does not expand. This is the object I'm talking about: <code>
6
1568
by: Peter Moscatt | last post by:
I have a rather odd question: Is there a way Python can execute a command within a string ? For example if I had something like: _str = "fm=OptionMenu(root,xx,'string1','string2','string3')" And the execute _str. The reason why I am trying to do this that as I am aware the OptionMenu
1
2885
by: erikober | last post by:
I'm creating a OptionMenu button for a gui and I'm having a problem where the drop down list is so long that most of the options are off screen. The correct behavior would be that another drop down menu list would be created next to it with the continued options. Here is the small code snippet that I have now: myOptionList = ....... OMcreate = "OptionMenu(frame, myVar, \"%s\", command=myOMCB)"%(myOptionList)
5
3017
by: Roger Leigh | last post by:
Although I've got over most of my template-related problems, I'm having trouble when I started to use default template parameters. For template type T, I've typedef'd this as object_type and then typedef'd std::vector<T> menu_list. This doesn't seem to work though: 40 template<typename W> 41 class ObjectOptionMenuDescribeObject 42 { 43 public:
4
13770
by: Alex Hunsley | last post by:
Can anyone recommend some code for creating drop-down menus in tkinter? To be absolutely clear, here's an example of a drop-down: http://www.google.co.uk/preferences?hl=en (see the language selection widget) I've found the odd bit of code here and there, such as: http://infohost.nmt.edu/tcc/cgi/pre.cgi?file=/u/www/docs/tcc/help/lang/python/mapping/dropdown.py alex
0
9684
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7552
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4120
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

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.