PySimpleGUI / PySimpleGUI/PySimpleGUI
Question - how to pass input from one window to another
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.8k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Type of Issues (Enhancement, Error, Bug, Question)
Question (basic)
Operating System
Win10-64
Python version
3.7.6
PySimpleGUI Port and Version
tkinter
PySimpleGUI Version: 4.29.0
tkinter version: 8.6.9
You can get these by adding this to the top of your file and running it:
import PySimpleGUI as sg
print(sg) # Location of your PySimpleGUI.py file
print(sg.version) # PySimpleGUI version number
print(sg.tclversion_detailed) # tkinter detailed version number (in PySimpleGUI version 4.29.0+)
print(sg.sys.version) # Python version number
The tkinter version number can be obtained using above code in version 4.29.0+. If your code is prior:
print(sg.tkinter.Tcl().eval('info patchlevel'))
Your Experience Levels In Months or Years
6 mo__ Python programming experience
2 yrs__ Programming experience overall
n___ Have used another Python GUI Framework (tkinter, Qt, etc) previously (yes/no is fine)?
You have completed these steps:
- Read instructions on how to file an Issue
- Searched through main docs http://www.PySimpleGUI.org for your problem
- Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
- Note that there are also Demo Programs under each port on GitHub
- Run your program outside of your debugger (from a command line)
- Searched through Issues (open and closed) to see if already reported
- Try again by upgrading your PySimpleGUI.py file to use the current one on GitHub. Your problem may have already been fixed but is not yet on PyPI.
Description of Problem / Question / Details
How to pass input from one window into another in multi-window.
Details:
I copied the multi-window demo. Works great.
What I'm missing is how to move captured data from the 2nd window into the first.
Code To Duplicate
A short program that isolates and demonstrates the problem (i.e. please don't paste a link to your 400 line program.... instead paste your 10 line program in full).
Yes, it is a pain to narrow down problems, but it's part of the debugging process. Help me help you by providing something that can be executed so that work on getting you a fix or a workaround can immediately begin.
This pre-formatted code block is all set for you to paste in your bit of code:
import PySimpleGUI as sg
# Design pattern 2 - First window does remain active
layout = [[ sg.Text('Window 1'),],
[sg.Input(do_not_clear=True)], # I want the output of win2 to show up here, so value of "chosenWell" str
[sg.Text('', key='_OUTPUT_')],
[sg.Button('Launch 2'), sg.Button('Exit')]]
win1 = sg.Window('Window 1').Layout(layout)
win2_active=False
while True:
ev1, vals1 = win1.Read(timeout=100)
win1.FindElement('_OUTPUT_').Update(vals1[0])
if ev1 is None or ev1 == 'Exit':
break
if ev1 == 'Launch 2' and not win2_active:
cols=7
sg.theme('BluePurple')
win2_active = True
layout2 = [[sg.Text('Window 2 - for diagram/selection of spot on consumable')],
[sg.B('\u20DD',size=(6,2),button_color=('orange','#223344'),key=(1,f'{i+1}'),pad=(0,0)) for i in range(cols)]+[sg.T(' ')],
[sg.T(' ')]+[sg.B('\u20DD',size=(6,2),button_color=('orange','#223344'),key=(2,f'{i+1}'),pad=(0,0)) for i in range(cols)],
[sg.B('\u20DD',size=(6,2),button_color=('orange','#223344'),key=(3,f'{i+1}'),pad=(0,0)) for i in range(cols)]+[sg.T(' ')],
[sg.T(' ')]+[sg.B('\u20DD',size=(6,2),button_color=('orange','#223344'),key=(4,f'{i+1}'),pad=(0,0)) for i in range(cols)],
[sg.B('\u20DD',size=(6,2),button_color=('orange','#223344'),key=(5,f'{i+1}'),pad=(0,0)) for i in range(cols)]+[sg.T(' ')]
]
win2 = sg.Window('',no_titlebar=True,alpha_channel=.9,grab_anywhere=True,element_justification='c').Layout(layout2)
if win2_active:
ev2, vals2 = win2.Read()
if ev2 is None or ev2 == 'Exit':
win2.Close()
win2_active = False
chosenWell=ev2
print(chosenWell)
win2.close()
win1.close()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the multi-window demo referenced in the issue and trace the win1/win2 event loops, especially win2.Read and the chosenWell value. Compare that flow with the main documentation's multi-window guidance; done means a minimal example clearly shows the selected value appearing in Window 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100