Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxWidgets version?? #52

Open
tester0077 opened this issue Feb 7, 2022 · 3 comments
Open

wxWidgets version?? #52

tester0077 opened this issue Feb 7, 2022 · 3 comments

Comments

@tester0077
Copy link

tester0077 commented Feb 7, 2022

Just purchased the book and am working my way through the examples.
In chapter 2, with the image viewer, I have run into one problem and one warning.
FWIW, I am new to wxPython & Python, but not wxWidgets and my goal - partially achieved already - is to use wxFormBuilder as a front-end for designing the GUI itself.

In order to sort out the problems I am running into, I am now running the file image_viewer_working.py from the github repo in the current Visual Stdio Code 1.64.0 (user setup) - running Win 10-64-bit
The problem message when running the code:
_PS D:\pkg\python\wxFB\wxPython\ImageViewer> d:; cd 'd:\pkg\python\wxFB\wxPython\ImageViewer'; & 'C:\Users\arnold\AppData\Local\Programs\PythonCodingPack\python.exe' 'c:\Users\arnold.vscode\extensions\ms-python.python-2022.0.1786462952\pythonFiles\lib\python\debugpy\launcher' '59120' '--' 'd:\pkg\python\wxPython\applications_with_wxpython-master\chapter2_image_viewer\image_viewer_working.py'
Traceback (most recent call last):
File "d:\pkg\python\wxPython\applications_with_wxpython-master\chapter2_image_viewer\image_viewer_working.py", line 43, in on_browse
self.photo_txt.SetValue(dialog.GetPath())
wx.core.wxAssertionError: C++ assertion ""!HasFlag(wxFD_MULTIPLE)"" failed at C:\PROJECTS\bb2\dist-win64-py38\build\ext\wxWidgets\include\wx/filedlg.h(109) in
wxFileDialogBase::GetPath(): When using wxFD_MULTIPLE, must call GetPaths() instead

and the image is never displayed because of this exception.
replacing line 40 : style=wx.ID_OPEN) as dialog:
with : style=wx.FD_OPEN) as dialog:

gives me the warning
d:; cd 'd:\pkg\python\wxFB\wxPython\ImageViewer'; & 'C:\Users\arnold\AppData\Local\Programs\PythonCodingPack\python.exe' 'c:\Users\arnold.vscode\extensions\ms-python.python-2022.0.1786462952\pythonFiles\lib\python\debugpy\launcher' '59190' '--' 'd:\pkg\python\wxPython\applications_with_wxpython-master\chapter2_image_viewer\image_viewer_working.py'
d:\pkg\python\wxPython\applications_with_wxpython-master\chapter2_image_viewer\image_viewer_working.py:62: DeprecationWarning: an integer is required (got type
float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.
img = img.Scale(NewW,NewH)

though the image is displayed as I would expect, though, at this stage I am unsure about what to expect.

Questions:

  1. is there a way to easily tell which version of wxPython is being used, version which version(s) might be installed?
  2. is there a way to easily tell which version of wxWidgets wxPython is using? Again, as opposed to which version(s) of wsWidgets might be installed on the PC

The first problem is seemingly caused by a mismatch of the wxWidgets versions expected by your code and what is installed on my system - the PC I am running this one has ONLY wxWidgets 3.1.4

@driscollis
Copy link
Owner

I installed the latest wxPython version when I wrote that book, which was wxPython 4. I think 4.1.1 is out now, but that version should work the same way with this book's code.

But yes, the example you mentioned should definitely be style=wx.FD_OPEN. I think I had tried that example using an earlier version of wxPython on accident and left that in there.

You can get the version info by doing this:

import wx

print(wx.version())

@tester0077
Copy link
Author

tester0077 commented Feb 8, 2022 via email

@abcdenis
Copy link

When using wxFD_MULTIPLE, must call GetPaths() instead

Can be fixed by using dialog.GetPaths()[0] instead of dialog.GetPath()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants