Can a PySimpleGUI InputOptionMenu be updated?How can I represent an 'Enum' in Python?How can I do a line break (line continuation) in Python?How can I safely create a nested directory?How can I remove a trailing newline in Python?How can I make a time delay in Python?How can you profile a Python script?In what case would I use a tuple as a dictionary key?How can I count the occurrences of a list item?How can I reverse a list in Python?How can I print literal curly-brace characters in python string and also use .format on it?
Is the default 512 byte physical sector size appropriate for SSD disks under Linux?
DeleteCases using two lists but with partial match?
Department head said that group project may be rejected. How to mitigate?
Make the `diff` command look only for differences from a specified range of lines
Is there any mention of ghosts who live outside the Hogwarts castle?
Why is unzipped file smaller than zipped file
Are there historical examples of audiences drawn to a work that was "so bad it's good"?
What does it mean for something to be strictly less than epsilon for an arbitrary epsilon?
How to test if argument is a single space?
csname in newenviroment
Ribbon Cable Cross Talk - Is there a fix after the fact?
Ratings matrix plot
Which values for voltage divider
How could the B-29 bomber back up under its own power?
(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?
Why is this integration method not valid?
Computing elements of a 1000 x 60 matrix exhausts RAM
To exponential digit growth and beyond!
Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?
Why is this python script running in background consuming 100 % CPU?
How do you earn the reader's trust?
How to safely discharge oneself
How to eliminate gap at the start and at the end of a line when it's drawn along a side of a node's bounding box?
Team member is vehemently against code formatting
Can a PySimpleGUI InputOptionMenu be updated?
How can I represent an 'Enum' in Python?How can I do a line break (line continuation) in Python?How can I safely create a nested directory?How can I remove a trailing newline in Python?How can I make a time delay in Python?How can you profile a Python script?In what case would I use a tuple as a dictionary key?How can I count the occurrences of a list item?How can I reverse a list in Python?How can I print literal curly-brace characters in python string and also use .format on it?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I want to update values of a PySimpleGUI Input Option Menu. The following initially assigns contents of the 'names' list to the Listbox. This is overwritten when the 'new_values' list is assigned. So, there's no problem updating a Listbox, but the InputOptionMenu element is not updating.
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.InputOptionMenu(names, size=(20, 4), key='_LIST_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(new_values)
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
My expectation is both elements would be updated to Bill and Jeff. The Listbox is, but the InputOptionMenu shows Roberta and Kylie.
python pysimplegui
add a comment |
I want to update values of a PySimpleGUI Input Option Menu. The following initially assigns contents of the 'names' list to the Listbox. This is overwritten when the 'new_values' list is assigned. So, there's no problem updating a Listbox, but the InputOptionMenu element is not updating.
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.InputOptionMenu(names, size=(20, 4), key='_LIST_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(new_values)
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
My expectation is both elements would be updated to Bill and Jeff. The Listbox is, but the InputOptionMenu shows Roberta and Kylie.
python pysimplegui
add a comment |
I want to update values of a PySimpleGUI Input Option Menu. The following initially assigns contents of the 'names' list to the Listbox. This is overwritten when the 'new_values' list is assigned. So, there's no problem updating a Listbox, but the InputOptionMenu element is not updating.
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.InputOptionMenu(names, size=(20, 4), key='_LIST_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(new_values)
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
My expectation is both elements would be updated to Bill and Jeff. The Listbox is, but the InputOptionMenu shows Roberta and Kylie.
python pysimplegui
I want to update values of a PySimpleGUI Input Option Menu. The following initially assigns contents of the 'names' list to the Listbox. This is overwritten when the 'new_values' list is assigned. So, there's no problem updating a Listbox, but the InputOptionMenu element is not updating.
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.InputOptionMenu(names, size=(20, 4), key='_LIST_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(new_values)
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
My expectation is both elements would be updated to Bill and Jeff. The Listbox is, but the InputOptionMenu shows Roberta and Kylie.
python pysimplegui
python pysimplegui
asked Mar 23 at 21:07
Jeffrey Neil WillitsJeffrey Neil Willits
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can indeed update to new values. You've got a parameter in the update call out of order. The first parameter, value
sets the currently shown value. The second parameter, values
is the one you need.
The fix is to add the parameter name to your call:
window.Element('_LIST_').Update(values=new_values)
Additionally, you must not name 2 keys the same. They have to be unique among the layout. I would call the other one _OPTIONS_
or something along those lines.
There was a bug in the Update code for Option Menu that has now been fixed and checked into GitHub. The fix was uploaded to PyPI as version 3.27.
Here is your code reworked and tested with the latest PySimpleGUI code. I've included an extra parameter to the OptionMenu.Update call to show you how to explicitly set a
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.OptionMenu(names, size=(20, 4), key='_OPT_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(values=new_values)
window.Element('_OPT_').Update(values=new_values, value='Jeff')
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
This doesn't actually work!
– NSA
Mar 25 at 21:34
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
1
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
What's with the downvote?
– MikeyB
Mar 27 at 14:27
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318401%2fcan-a-pysimplegui-inputoptionmenu-be-updated%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can indeed update to new values. You've got a parameter in the update call out of order. The first parameter, value
sets the currently shown value. The second parameter, values
is the one you need.
The fix is to add the parameter name to your call:
window.Element('_LIST_').Update(values=new_values)
Additionally, you must not name 2 keys the same. They have to be unique among the layout. I would call the other one _OPTIONS_
or something along those lines.
There was a bug in the Update code for Option Menu that has now been fixed and checked into GitHub. The fix was uploaded to PyPI as version 3.27.
Here is your code reworked and tested with the latest PySimpleGUI code. I've included an extra parameter to the OptionMenu.Update call to show you how to explicitly set a
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.OptionMenu(names, size=(20, 4), key='_OPT_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(values=new_values)
window.Element('_OPT_').Update(values=new_values, value='Jeff')
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
This doesn't actually work!
– NSA
Mar 25 at 21:34
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
1
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
What's with the downvote?
– MikeyB
Mar 27 at 14:27
|
show 1 more comment
You can indeed update to new values. You've got a parameter in the update call out of order. The first parameter, value
sets the currently shown value. The second parameter, values
is the one you need.
The fix is to add the parameter name to your call:
window.Element('_LIST_').Update(values=new_values)
Additionally, you must not name 2 keys the same. They have to be unique among the layout. I would call the other one _OPTIONS_
or something along those lines.
There was a bug in the Update code for Option Menu that has now been fixed and checked into GitHub. The fix was uploaded to PyPI as version 3.27.
Here is your code reworked and tested with the latest PySimpleGUI code. I've included an extra parameter to the OptionMenu.Update call to show you how to explicitly set a
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.OptionMenu(names, size=(20, 4), key='_OPT_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(values=new_values)
window.Element('_OPT_').Update(values=new_values, value='Jeff')
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
This doesn't actually work!
– NSA
Mar 25 at 21:34
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
1
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
What's with the downvote?
– MikeyB
Mar 27 at 14:27
|
show 1 more comment
You can indeed update to new values. You've got a parameter in the update call out of order. The first parameter, value
sets the currently shown value. The second parameter, values
is the one you need.
The fix is to add the parameter name to your call:
window.Element('_LIST_').Update(values=new_values)
Additionally, you must not name 2 keys the same. They have to be unique among the layout. I would call the other one _OPTIONS_
or something along those lines.
There was a bug in the Update code for Option Menu that has now been fixed and checked into GitHub. The fix was uploaded to PyPI as version 3.27.
Here is your code reworked and tested with the latest PySimpleGUI code. I've included an extra parameter to the OptionMenu.Update call to show you how to explicitly set a
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.OptionMenu(names, size=(20, 4), key='_OPT_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(values=new_values)
window.Element('_OPT_').Update(values=new_values, value='Jeff')
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
You can indeed update to new values. You've got a parameter in the update call out of order. The first parameter, value
sets the currently shown value. The second parameter, values
is the one you need.
The fix is to add the parameter name to your call:
window.Element('_LIST_').Update(values=new_values)
Additionally, you must not name 2 keys the same. They have to be unique among the layout. I would call the other one _OPTIONS_
or something along those lines.
There was a bug in the Update code for Option Menu that has now been fixed and checked into GitHub. The fix was uploaded to PyPI as version 3.27.
Here is your code reworked and tested with the latest PySimpleGUI code. I've included an extra parameter to the OptionMenu.Update call to show you how to explicitly set a
import PySimpleGUI as sg
names = ['Roberta', 'Kylie']
layout = [[sg.Listbox(names, size=(20, 4), key='_LIST_')],
[sg.OptionMenu(names, size=(20, 4), key='_OPT_')]]
window = sg.Window('').Layout(layout).Finalize()
new_values = ['Bill', 'Jeff']
window.Element('_LIST_').Update(values=new_values)
window.Element('_OPT_').Update(values=new_values, value='Jeff')
while True:
event, values = window.Read()
if event is None or event == 'Exit':
break
window.Close()
edited Mar 31 at 22:12
answered Mar 24 at 13:32
MikeyBMikeyB
935514
935514
This doesn't actually work!
– NSA
Mar 25 at 21:34
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
1
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
What's with the downvote?
– MikeyB
Mar 27 at 14:27
|
show 1 more comment
This doesn't actually work!
– NSA
Mar 25 at 21:34
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
1
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
What's with the downvote?
– MikeyB
Mar 27 at 14:27
This doesn't actually work!
– NSA
Mar 25 at 21:34
This doesn't actually work!
– NSA
Mar 25 at 21:34
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
It works if you get the latest code from GitHub as described in the answer.
– MikeyB
Mar 25 at 23:15
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
When running with latest release user-images.githubusercontent.com/13696193/…
– MikeyB
Mar 25 at 23:25
1
1
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
Yes, it worked for me with the code update.
– Jeffrey Neil Willits
Mar 26 at 1:16
What's with the downvote?
– MikeyB
Mar 27 at 14:27
What's with the downvote?
– MikeyB
Mar 27 at 14:27
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318401%2fcan-a-pysimplegui-inputoptionmenu-be-updated%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown