[chirp_devel] py3 File Open problem
I finally (FINALLY) figured out what my problem was with py3 on macintosh MacOSX. I must have XQuartz running (an X windows application.) Whew!
It looks as if the Yaesu FT2D is at least partially working with GUI (I know it works with the CLI options.) Thanks. I’ll be trying it out RSN.
I can use the menus to get to recent files (File -> Open Recent). But I’ve run into a problem when I ask to open a file (File -> Open…) An error message shows up in my console indicating
File "/Users/declan/chirp/chirp/wxui/main.py", line 814, in _menu_open with wx.FileDialog(self, _('Open a file'), TypeError: FileDialog(): argument 3 has unexpected type ‘PosixPath’
and no dialog box ensues.
The code in question is
806 def _menu_open(self, event): 807 formats = [_('Chirp Image Files') + ' (*.img)|*.img', 808 _('All Files') + ' (*.*)|*.*'] 809 for name, pattern, readonly in directory.AUX_FORMATS: 810 formats.insert(1, '%s %s (%s)|%s' % ( 811 name, _('Files'), pattern, pattern)) 812 813 wildcard = '|'.join(formats) 814 with wx.FileDialog(self, _('Open a file'), 815 chirp_platform.get_platform().get_last_dir(), 816 wildcard=wildcard, 817 style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fd: 818 if fd.ShowModal() == wx.ID_CANCEL: 819 return 820 filename = fd.GetPath() 821 d = fd.GetDirectory() 822 chirp_platform.get_platform().set_last_dir(d) 823 CONF.set('last_dir', d, 'state') 824 config._CONFIG.save() 825 self.open_file(str(filename))
I’ve no clue where or how “PosixPath” shows up in here, so I’m supposing there’s something wrong with Python or chirp that I’ve caused to get things running. Has anybody any ideas to fix the File Open dialog on MacOS, please?
I finally (FINALLY) figured out what my problem was with py3 on macintosh MacOSX. I must have XQuartz running (an X windows application.) Whew!
You shouldn't need (nor be using) XQuartz for this. If you have wxWidgets installed, then it uses native Cocoa widgetry. So, maybe first: how are you installing wx? Can you try one of the .app builds to see if they behave differently for you?
It looks as if the Yaesu FT2D is at least partially working with GUI (I know it works with the CLI options.) Thanks. I’ll be trying it out RSN.
Cool!
I can use the menus to get to recent files (File -> Open Recent). But I’ve run into a problem when I ask to open a file (File -> Open…) An error message shows up in my console indicating
File "/Users/declan/chirp/chirp/wxui/main.py", line 814, in _menu_open with wx.FileDialog(self, _('Open a file'), TypeError: FileDialog(): argument 3 has unexpected type ‘PosixPath’
and no dialog box ensues.
No such problem here, FWIW. MacOS 12.6.1, python 3.10.8 from brew. Also no problem with the build .app, which bundles 3.8 from Apple themselves.
The code in question is
806 def _menu_open(self, event): 807 formats = [_('Chirp Image Files') + ' (*.img)|*.img', 808 _('All Files') + ' (*.*)|*.*'] 809 for name, pattern, readonly in directory.AUX_FORMATS: 810 formats.insert(1, '%s %s (%s)|%s' % ( 811 name, _('Files'), pattern, pattern)) 812 813 wildcard = '|'.join(formats) 814 with wx.FileDialog(self, _('Open a file'), 815 chirp_platform.get_platform().get_last_dir(), 816 wildcard=wildcard, 817 style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fd: 818 if fd.ShowModal() == wx.ID_CANCEL: 819 return 820 filename = fd.GetPath() 821 d = fd.GetDirectory() 822 chirp_platform.get_platform().set_last_dir(d) 823 CONF.set('last_dir', d, 'state') 824 config._CONFIG.save() 825 self.open_file(str(filename))
I’ve no clue where or how “PosixPath” shows up in here, so I’m supposing there’s something wrong with Python or chirp that I’ve caused to get things running. Has anybody any ideas to fix the File Open dialog on MacOS, please?
PosixPath comes from pathlib:
import pathlib pathlib.PosixPath
<class 'pathlib.PosixPath'>
But I don't think you should be seeing it in this section of code, unless there's some confusion between chirp's platform module and the python one. Not sure how or why you're seeing that though.
Because of the XQuartz requirement, I'm suspecting that maybe you have some very weird combination of things going on.
I think this should really be all you need:
https://chirp.danplanet.com/projects/chirp/wiki/DevelopersPython3Environment...
Maybe consider what differs in your environment from that? The build system that generates the .app (which requires no XQuartz) pretty much just does that and then creates the bundle.
--Dan
PosixPath comes from pathlib:
import pathlib pathlib.PosixPath
<class 'pathlib.PosixPath'>
But I don't think you should be seeing it in this section of code, unless there's some confusion between chirp's platform module and the python one. Not sure how or why you're seeing that though.
Gah, sorry, I forgot @vishwin introduced Path to our platform module here:
https://github.com/kk7ds/chirp/pull/196
I'll need to go dig into that to see if we should be doing something else. Perhaps you're on an older python and importlib_resources behaves differently than my native one in python 3.10. So yeah, let me know which macos you're on and where you got python (and which version) so I can try to narrow it down.
PosixPath can be str()'d to get just a path string, so perhaps that's all we need to do there.
--Dan
Hi Dan.
FYI, I followed the instructions https://chirp.danplanet.com/projects/chirp/wiki/DevelopersPython3Environment... and I'm getting a similar error.
The Linux instructions fail at first, so I checked out the py3 branch like the Windows instructions on the same page give. Then I can run the chirpwx.py file.
then i get the following error.
[boucha@esqueleto chirp (py3 u=)]$ ./chirpwx.py Gtk-Message: 16:55:54.177: Failed to load module "xapp-gtk3-module" Traceback (most recent call last): File "/home/boucha/repos/chirp/chirp/wxui/main.py", line 812, in _menu_open with wx.FileDialog(self, _('Open a file'), TypeError: FileDialog(): argument 3 has unexpected type 'PosixPath'
I'm on Python 3.10.6 on Ubuntu 22.04
[boucha@esqueleto chirp (py3 u=)]$ python3 -V Python 3.10.6
[boucha@esqueleto chirp (py3 u=)]$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy
On Wed, Dec 14, 2022 at 4:56 PM Dan Smith via chirp_devel < chirp_devel@intrepid.danplanet.com> wrote:
PosixPath comes from pathlib:
import pathlib pathlib.PosixPath
<class 'pathlib.PosixPath'>
But I don't think you should be seeing it in this section of code,
unless there's some confusion between chirp's platform module and the python one. Not sure how or why you're seeing that though.
Gah, sorry, I forgot @vishwin introduced Path to our platform module here:
https://github.com/kk7ds/chirp/pull/196
I'll need to go dig into that to see if we should be doing something else. Perhaps you're on an older python and importlib_resources behaves differently than my native one in python 3.10. So yeah, let me know which macos you're on and where you got python (and which version) so I can try to narrow it down.
PosixPath can be str()'d to get just a path string, so perhaps that's all we need to do there.
--Dan _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
[boucha@esqueleto chirp (py3 u=)]$ ./chirpwx.py Gtk-Message: 16:55:54.177: Failed to load module "xapp-gtk3-module" Traceback (most recent call last): File "/home/boucha/repos/chirp/chirp/wxui/main.py", line 812, in _menu_open with wx.FileDialog(self, _('Open a file'), TypeError: FileDialog(): argument 3 has unexpected type 'PosixPath'
Yep, turned out to be broken for all the systems that use UnixPlatform. This should fix it:
https://github.com/kk7ds/chirp/pull/251
If you guys can test that real quick that'd be great, else I'll just put it in.
Good catch, I hadn't seen this because I have an existing config and only fresh users would hit it. Thanks!
--Dan
Your fix in https://github.com/kk7ds/chirp/pull/251 works for me.
On Wed, Dec 14, 2022 at 5:06 PM Dan Smith via chirp_devel < chirp_devel@intrepid.danplanet.com> wrote:
[boucha@esqueleto chirp (py3 u=)]$ ./chirpwx.py Gtk-Message: 16:55:54.177: Failed to load module "xapp-gtk3-module" Traceback (most recent call last): File "/home/boucha/repos/chirp/chirp/wxui/main.py", line 812, in
_menu_open
with wx.FileDialog(self, _('Open a file'),
TypeError: FileDialog(): argument 3 has unexpected type 'PosixPath'
Yep, turned out to be broken for all the systems that use UnixPlatform. This should fix it:
https://github.com/kk7ds/chirp/pull/251
If you guys can test that real quick that'd be great, else I'll just put it in.
Good catch, I hadn't seen this because I have an existing config and only fresh users would hit it. Thanks!
--Dan _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
Dan Smith via chirp_devel wrote:
I'll need to go dig into that to see if we should be doing something else. Perhaps you're on an older python and importlib_resources behaves differently than my native one in python 3.10. So yeah, let me know which macos you're on and where you got python (and which version) so I can try to narrow it down.
I specifically conditional imported importlib_resources to use the package if the Python used is < 3.10, since certain constructs used only appeared in time for 3.10; they are backported into the package. Doing this conditional import ensures consistent behaviour (at least in theory).
PosixPath can be str()'d to get just a path string, so perhaps that's all we need to do there.
Correct.
in chirp/wxui/main.py line 813 I removed "chirp_platform.get_platform().get_last_dir()," and I was able to get a usable file dialog to pop up.
812 with wx.FileDialog(self, _('Open a file'),
813 chirp_platform.get_platform().get_last_dir(), 814 wildcard=wildcard,
815 style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fd: 816 if fd.ShowModal() == wx.ID_CANCEL:
817 return
Changed to
812 with wx.FileDialog(self, _('Open a file'),
813 wildcard=wildcard,
814 style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fd: 815 if fd.ShowModal() == wx.ID_CANCEL:
816 return
On Wed, Dec 14, 2022 at 5:03 PM Charlie Li via chirp_devel < chirp_devel@intrepid.danplanet.com> wrote:
Dan Smith via chirp_devel wrote:
I'll need to go dig into that to see if we should be doing something
else. Perhaps you're on an older python and importlib_resources behaves differently than my native one in python 3.10. So yeah, let me know which macos you're on and where you got python (and which version) so I can try to narrow it down.
I specifically conditional imported importlib_resources to use the package if the Python used is < 3.10, since certain constructs used only appeared in time for 3.10; they are backported into the package. Doing this conditional import ensures consistent behaviour (at least in theory).
PosixPath can be str()'d to get just a path string, so perhaps that's
all we need to do there.
Correct.
-- Charlie Li …nope, still don't have an exit line.
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
FYI, I'm using Python 3.7.0 on MacOS 10.13.6 and not running into any issues running chirpwx.py from the command line.
Martin. KD6YAM
On Wed, Dec 14, 2022 at 3:56 PM Dan Smith via chirp_devel < chirp_devel@intrepid.danplanet.com> wrote:
PosixPath comes from pathlib:
import pathlib pathlib.PosixPath
<class 'pathlib.PosixPath'>
But I don't think you should be seeing it in this section of code,
unless there's some confusion between chirp's platform module and the python one. Not sure how or why you're seeing that though.
Gah, sorry, I forgot @vishwin introduced Path to our platform module here:
https://github.com/kk7ds/chirp/pull/196
I'll need to go dig into that to see if we should be doing something else. Perhaps you're on an older python and importlib_resources behaves differently than my native one in python 3.10. So yeah, let me know which macos you're on and where you got python (and which version) so I can try to narrow it down.
PosixPath can be str()'d to get just a path string, so perhaps that's all we need to do there.
--Dan _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
participants (5)
-
Charlie Li
-
Dan Smith
-
David Boucha
-
Declan Rieb
-
Martin Cooper