[chirp_devel] py3 File Open problem

Dan Smith
Wed Dec 14 15:35:08 PST 2022


> 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#MacOS

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


More information about the chirp_devel mailing list