Reputation: 31
I am trying to get up and running with PySimpleGUI. I tried running the following code (from https://pysimplegui.readthedocs.io/en/latest/#the-quick-tour):
import PySimpleGUI as sg
event, values = sg.Window('Get filename example', [[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]).Read()
This is on a Windows 7 box, with Python 3.7.1, and PySimpleGUI version 4.18.0.
BTW, those two lines should work from a python command line, I think. But, even if I save them as a file (with no other python lines, just newlines and comments), I get
(Traceback (most recent call last):
File "C:\Users\blorfmorlfle\bin\MoveStagedFiles.py", line 15, in <module>
event, values = sg.Window('Get filename example', [[sg.Text('Filename')], [sg.Input(), sg.FileBrowse()], [sg.OK(), sg.Cancel()] ]).Read()
AttributeError: module 'PySimpleGUI' has no attribute 'Window'
Searching stack overflow for similar errors, all the results threads were different.
FWIW, I have uninstalled and reinstalled PySimpleGUI.
FWIW2, the following works fine.
sg.Popup('Hello From PySimpleGUI!', 'This is the shortest GUI program ever!')
Any thoughts? I have heard some python releases are problematic for PySimpleGUI because of tkinter issues. Is there a recommended release?
Upvotes: 1
Views: 5288
Reputation: 1
I hope your file it's not named PySimpleGUI.py
, if it's your case, rename it to something different than the library name.
Upvotes: 0
Reputation: 31
I first installed PySimpleGUI a couple years ago, just to play with it. Having heard that it was just one python file, I just dropped it in a folder I was using for testing code.
That older version of PySimpleGUI isn't fully functional now, as it's missing things like Window
, theme
, etc. I installed the latest using pip. But, I have still been running test code from the same folder. So, when I imported PySimpleGUI, the old version was ahead of the newer PySimpleGUI's install path. Basically, I was importing an older version that I didn't remember was installed in the current working directory. Since the old version didn't have a version variable, it took a while to realize that I wasn't importing the version that pip show PySimpleGUI
was reporting as installed from the OS command line. Embarrassing. But, lesson learned.
Thank you to everyone who responded in this thread. Eventually, @acw1668's suggestion made me realize what was going on.
Upvotes: 1
Reputation: 105
I tried it with python 3.6.8 and PySimpleGUI 4.18.0 with the same two lines of code that you provided and it did not work for me, too (Kernel died).
However, running the other example from the quick tour (https://pysimplegui.readthedocs.io/en/latest/#the-quick-tour), which simply provides the code in a more readable way, worked for me:
import PySimpleGUI as sg
sg.theme('Dark Blue 3') # please make your creations colorful
layout = [ [sg.Text('Filename')],
[sg.Input(), sg.FileBrowse()],
[sg.OK(), sg.Cancel()]]
window = sg.Window('Get filename example', layout)
event, values = window.Read()
window.close()
I hope that this might help
Upvotes: 1