optionmenu

Tkinter OptionMenu DisplayOptions and Assignment Values

こ雲淡風輕ζ 提交于 2019-12-05 01:27:27
问题 In Python's Tkinter OptionMenu, is it possible to have a list of display options, but on selection, it sets a value to be some other value? Suppose I had variable = tk.IntVar(master) OptionMenu(master, variable, 1, 2).pack() options = {1:"one",2:"two"} and wanted to display the values but assign the key to variable. Is this even possible? Or is there a way to link the OptionMenu to call a function on selection to convert it? My real problem is more involved than the example, so the issue is

How to make a OptionMenu maintain the same width?

北城余情 提交于 2019-12-04 00:34:44
问题 I have a snippet which creates an OptionMenu widget. ... options = ('White', 'Grey', 'Black', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Cyan', 'Purple') var = StringVar() optionmenu = OptionMenu(par, var, *options) optionmenu.grid(column=column, row=row) ... One problem I've encountered is every time a new option is selected, the width of the widget changes. I believe this is due to the text within the widget changing widths. How do I make the widget hold a consistent width? 回答1: When you

How to hide option menu?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 12:02:35
问题 I am using option selected menu item, attached three item (share, login, logout) am select login item, go login activity login social sign (Facebook or google) any one, if login hide login item at same time show logout item, this same type if logout the social sign show login item menu, please help me... 回答1: step:1) menu.xml define all three menu item. login ,logout and share after that make logout visibility to false by default android:visible="false" and make remaining two items visible

Getting the choice of optionmenu right after selection Python

做~自己de王妃 提交于 2019-12-03 08:56:55
I was wondering if there is any way for me to see what the User has selected among the list displaying, let's say: ["Apple","Orange","Grapes"] right after they select either one of them? Like when user clicks the optionbox, and clicks Apple, Tkinter will return something then if he switches his selection to, let's say, Orange, then that will also return something on the spot. Thanks! How to put parameter correctly? from Tkinter import * def option_changed(a): print "the user chose the value {}".format(variable.get()) print a master = Tk() a = "Foo" variable = StringVar(master) variable.set(

How to hide option menu?

a 夏天 提交于 2019-12-03 01:30:43
I am using option selected menu item, attached three item (share, login, logout) am select login item, go login activity login social sign (Facebook or google) any one, if login hide login item at same time show logout item, this same type if logout the social sign show login item menu, please help me... step:1) menu.xml define all three menu item. login ,logout and share after that make logout visibility to false by default android:visible="false" and make remaining two items visible.its optional because by default all items are visible in android Step:2)when you are in login Activity inflate

ttk.OptionMenu() displaying check mark on all menus

我的梦境 提交于 2019-12-02 09:49:37
问题 In this example, if a user selects any option in any of the drop downs, then clicks on another drop down, the previously selected item displayed a check mark beside it. Even though that choice was picked in a different menu. from Tkinter import * from ttk import * choices = ['1st Choice', '2nd Choice', '3rd Choice', '4th Choice'] root = Tk() for each in range(10): OptionMenu(root, StringVar(), choices[0], *choices).pack() root.mainloop() This happens on both Python 2.7 and 3.5. I've even

More on Python TKinter Dynamic OptionMenu

笑着哭i 提交于 2019-12-02 05:59:28
I'm trying to modify the code here to have the user confirm the items selected from the optionmenus . If the user clicks on the Submit button, a message box should open prompting confirmation. Finally, I want the selected items to be returned to the program as variables so they can be used in other functions for further processing. However, my modification is not working; it just returns an empty window. Thoughts on what I am missing? Many thanks. from tkinter import * import tkinter.messagebox class App(Frame): def __init__(self, master): Frame.__init__(self, master) self.dict = {'Asia': [

ttk.OptionMenu() displaying check mark on all menus

牧云@^-^@ 提交于 2019-12-02 05:15:32
In this example, if a user selects any option in any of the drop downs, then clicks on another drop down, the previously selected item displayed a check mark beside it. Even though that choice was picked in a different menu. from Tkinter import * from ttk import * choices = ['1st Choice', '2nd Choice', '3rd Choice', '4th Choice'] root = Tk() for each in range(10): OptionMenu(root, StringVar(), choices[0], *choices).pack() root.mainloop() This happens on both Python 2.7 and 3.5. I've even moved the choices list into the loop so it generates on each iteration and the problem still occurs. I'm

Unable to hide the virtual keyboard of SearchView iconfiedbydefault(false)

我只是一个虾纸丫 提交于 2019-12-01 18:21:40
问题 I have a search view which is set as expanded by default with default search query but i don't want the virtual keyboard.In below code i tried to hide keyboard in onCreateOptionsMenu but still keyboard is visible. imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); MenuItem item = menu.findItem(R.id.menu_search); item.expandActionView(); mSearchView = (SearchView) item.getActionView(); mSearchView.setIconifiedByDefault(false); mSearchView.setQuery(query, true); imm

Unable to hide the virtual keyboard of SearchView iconfiedbydefault(false)

≯℡__Kan透↙ 提交于 2019-12-01 18:08:41
I have a search view which is set as expanded by default with default search query but i don't want the virtual keyboard.In below code i tried to hide keyboard in onCreateOptionsMenu but still keyboard is visible. imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); MenuItem item = menu.findItem(R.id.menu_search); item.expandActionView(); mSearchView = (SearchView) item.getActionView(); mSearchView.setIconifiedByDefault(false); mSearchView.setQuery(query, true); imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0); I am using sherlock search view widget. any