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

[Bug]: wxGUI crash at launch: TypeError: ToolBar.AddTool(): arguments did not match any overloaded call #2019

Closed
neteler opened this issue Dec 15, 2021 · 22 comments
Labels
bug Something isn't working GUI wxGUI related
Milestone

Comments

@neteler
Copy link
Member

neteler commented Dec 15, 2021

I have upgraded my system to F35 today (moved here from #1971) and get a wxGUI crash at launch:

# G78
Traceback (most recent call last):
  File "/usr/lib64/python3.10/site-packages/wx/core.py", line 3285, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/wxgui.py", line 83, in show_main_gui
    mainframe = GMFrame(parent=None, id=wx.ID_ANY, workspace=self.workspaceFile)
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 143, in __init__
    self.notebook = self._createNoteBook()
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 365, in _createNoteBook
    self.datacatalog = DataCatalog(
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/datacatalog/catalog.py", line 45, in __init__
    self.toolbar = DataCatalogToolbar(parent=self)
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/datacatalog/toolbars.py", line 47, in __init__
    self.InitToolbar(self._toolbarData())
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/toolbars.py", line 123, in InitToolbar
    self.CreateTool(*tool)
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/toolbars.py", line 145, in CreateTool
    toolWin = self.AddLabelTool(tool, label, bitmap,
  File "/home/mneteler/software/grass78/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/wrap.py", line 434, in AddLabelTool
    return wx.ToolBar.AddTool(self, toolId=toolId, label=label, bitmap=bitmap, bmpDisabled=bmpDisabled,
TypeError: ToolBar.AddTool(): arguments did not match any overloaded call:
  overload 1: 'toolId' is not a valid keyword argument
  overload 2: argument 'toolId' has unexpected type 'WindowIDRef'
  overload 3: argument 'toolId' has unexpected type 'WindowIDRef'

and

G8:
Traceback (most recent call last):
  File "/usr/lib64/python3.10/site-packages/wx/core.py", line 3285, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/wxgui.py", line 88, in show_main_gui
    mainframe = GMFrame(parent=None, id=wx.ID_ANY, workspace=self.workspaceFile)
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 153, in __init__
    self._createDataCatalog(self.notebook)
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/lmgr/frame.py", line 337, in _createDataCatalog
    self.datacatalog = DataCatalog(parent=parent, giface=self._giface)
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/datacatalog/catalog.py", line 67, in __init__
    self.toolbar = DataCatalogToolbar(parent=self)
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/datacatalog/toolbars.py", line 64, in __init__
    self.InitToolbar(self._toolbarData())
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/toolbars.py", line 119, in InitToolbar
    self.CreateTool(*tool)
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/toolbars.py", line 141, in CreateTool
    toolWin = self.AddLabelTool(
  File "/home/mneteler/software/grass_main/dist.x86_64-pc-linux-gnu/gui/wxpython/gui_core/wrap.py", line 504, in AddLabelTool
    return wx.ToolBar.AddTool(
TypeError: ToolBar.AddTool(): arguments did not match any overloaded call:
  overload 1: 'toolId' is not a valid keyword argument
  overload 2: argument 'toolId' has unexpected type 'WindowIDRef'
  overload 3: argument 'toolId' has unexpected type 'WindowIDRef'

Originally posted by @neteler in #1971 (comment)

@neteler neteler modified the milestones: 7.8.7, 8.0.0 Dec 15, 2021
@neteler neteler added backport_needed bug Something isn't working GUI wxGUI related labels Dec 15, 2021
@petrasovaa
Copy link
Contributor

See my reply in #1971 (comment), you need newer wx. I just tested gui with Python 3.10 and wxPython 4.1 and it works.

@neteler
Copy link
Member Author

neteler commented Dec 15, 2021

Well, then I need to tell the wxPython maintainer in Fedora to cherry-pick the needed fix(es). For the time being it will remain wxPython 4.0: https://koji.fedoraproject.org/koji/packageinfo?packageID=26351

However, searching for the error messages above in the internet does not return any result. So I'm a bit lost here...
I also don't see any deprecate warning above.

@petrasovaa
Copy link
Contributor

I believe it's this one:
wxWidgets/Phoenix#1533

But in general, there are pretty big changes in 4.1, mainly due to using newer wxWidgets, so I recommend using 4.1 when possible. There are some wheels for (older) fedora here https://extras.wxpython.org/wxPython4/extras/linux/gtk3/.

@neteler
Copy link
Member Author

neteler commented Dec 15, 2021

(cross-linking a related Fedora ticket here: https://bugzilla.redhat.com/show_bug.cgi?id=1827788)

@wenzeslaus
Copy link
Member

The piece of information which is missing in the Fedora ticket is that Fedora has latest Python release (3.10), but has old wxPython release. Either you need old Python and then wxPython 4.0 is fine, or you have Python 3.10, but then you need wxPython 4.1. Notably, the issue is not in how GRASS GIS uses wxPython.

@tmszi
Copy link
Member

tmszi commented Dec 16, 2021

Actually under Fedora 35 with Python 3.10 version it possible build own wxPython 4.1.1 (whl doesn't exist yet for Python 3.10)

[fedora@fedora35 ~]$ sudo dnf install -y gcc gcc-c++ gtk+-devel pipenv

[fedora@fedora35 ~]$ mkdir wxpy-4_1_1 && cd wxpy-4_1_1 && pipenv install wxPython

[fedora@fedora35 wx-4_1_1]$ pipenv shell

(wxpy-4_1_1) [fedora@fedora35 wxpy-4_1_1]$ python -c "import wx; print(wx.version())"
4.1.1 gtk3 (phoenix) wxWidgets 3.1.5

But launch GRASS GIS 7.8.6 (installed from the official repository ) crash during wxGUI initialization (it seem bug related with Python 3.10 version and wxPython 4.1.1, same issue as #1971)

(wxpy-4_1_1) [fedora@fedora35 wxpy-4_1_1]$ grass78

Launching <wxpython> GUI in the background, please wait...
GRASS 7.8.6 (fire_grass6data):~/wx-4_1_1 > Traceback (most recent call last):
  File "/usr/lib64/grass78/gui/wxpython/wxgui.py", line 73, in OnInit
    splash = SC.AdvancedSplash(bitmap=introBmp,
  File "/home/fedora/.local/share/virtualenvs/wx-4_1_1-JAhJbCMk/lib64/python3.10/site-packages/wx/lib/agw/advancedsplash.py", line 251, in __init__
    self.SetTextFont()
  File "/home/fedora/.local/share/virtualenvs/wx-4_1_1-JAhJbCMk/lib64/python3.10/site-packages/wx/lib/agw/advancedsplash.py", line 442, in SetTextFont
    self._textfont.SetPointSize(self._textsize)
TypeError: Font.SetPointSize(): argument 1 has unexpected type 'float'
OnInit returned false, exiting...
GRASS 7.8.6 (fire_grass6data):~/wxpy-4_1_1 > g.version -g
version=7.8.6
date=2021
revision=exported
build_date=2021-11-07
build_platform=x86_64-redhat-linux-gnu
build_off_t_size=8

@petrasovaa
Copy link
Contributor

petrasovaa commented Dec 16, 2021

But launch GRASS GIS 7.8.6 (installed from the official repository ) crash during wxGUI initialization (it seem bug related with Python 3.10 version and wxPython 4.1.1, same issue as #1971)

(wxpy-4_1_1) [fedora@fedora35 wxpy-4_1_1]$ grass78

Launching <wxpython> GUI in the background, please wait...
GRASS 7.8.6 (fire_grass6data):~/wx-4_1_1 > Traceback (most recent call last):
  File "/usr/lib64/grass78/gui/wxpython/wxgui.py", line 73, in OnInit
    splash = SC.AdvancedSplash(bitmap=introBmp,
  File "/home/fedora/.local/share/virtualenvs/wx-4_1_1-JAhJbCMk/lib64/python3.10/site-packages/wx/lib/agw/advancedsplash.py", line 251, in __init__
    self.SetTextFont()
  File "/home/fedora/.local/share/virtualenvs/wx-4_1_1-JAhJbCMk/lib64/python3.10/site-packages/wx/lib/agw/advancedsplash.py", line 442, in SetTextFont
    self._textfont.SetPointSize(self._textsize)
TypeError: Font.SetPointSize(): argument 1 has unexpected type 'float'
OnInit returned false, exiting...

Right, it looks like that one was fixed 2 days ago:
https://github.com/wxWidgets/Phoenix/pull/2039/files#diff-2537211974747ccfd5758e02d7775fe899ab7e1b8e47ce5a6caf9275713d66b5

I backported a change to 7.8, that uses a different widget so the problem doesn't come up. Ultimately we need a new 7.8 release to get it working with Python 3.10.

@neteler I suggest closing this

@neteler neteler modified the milestones: 8.0.0, 7.8.7 Dec 16, 2021
@neteler
Copy link
Member Author

neteler commented Dec 16, 2021

Actually under Fedora 35 with Python 3.10 version it possible build own wxPython 4.1.1 (whl doesn't exist yet for Python 3.10)

This is really cool, thanks for having posted the wxPython 4.1.1 installation instructions!
Now the wxGUI starts.

@neteler neteler closed this as completed Dec 16, 2021
@danhox
Copy link

danhox commented Dec 21, 2021

the build of wxpython don't work. I launch it many time but without result

@tmszi
Copy link
Member

tmszi commented Dec 21, 2021

the build of wxpython don't work. I launch it many time but without result

The compilation doesn't seem to be successful. Could you provide more information (compilation error message)?

@danhox
Copy link

danhox commented Dec 21, 2021

There is not any compilation. The compilation does not finish.
file:///home/danhoneuba/Images/Capture%20d%E2%80%99%C3%A9cran%20du%202021-12-21%2013-17-19.png

@danhox
Copy link

danhox commented Dec 21, 2021

I use pip install -U wxpython

@tmszi
Copy link
Member

tmszi commented Dec 21, 2021

There is not any compilation. The compilation does not finish. file:///home/danhoneuba/Images/Capture%20d%E2%80%99%C3%A9cran%20du%202021-12-21%2013-17-19.png

The installation process pip install -U wxpython first compile (compilation output is not visible to the user terminal in this case) the wxPython source code and then install it. Compiling wxPython takes quite a long time, depending on the performance of your computer, the number of processor cores.

@tmszi
Copy link
Member

tmszi commented Dec 21, 2021

I'm build binary wxPython 4.1.1 whl file (easy installation, which doesn't require compile wxPython from source code) for Python 3.10.

Size of binary wxPython-4.1.1-cp310-cp310-linux_x86_64.whl file is 135M. @neteler Where I could upload this binary file for downloading, please?

  1. Donwload binary wxPython-4.1.1-cp310-cp310-linux_x86_64.whl file
[fedora@fedora35 ~]$ curl https://transfer.sh/get/6GS4hU/wxPython-4.1.1-cp310-cp310-linux_x86_64.whl --output wxPython-4.1.1-cp310-cp310-linux_x86_64.whl 
  1. Check downloaded whl file hash (compare 2cd17438b679c47e1bb1c63183ff43de5452220904ecc799bb0bc4fdbaa2bb67 with your donwloaded whl file hash):
[fedora@fedora35 ~]$ pip hash wxPython-4.1.1-cp310-cp310-linux_x86_64.whl 
wxPython-4.1.1-cp310-cp310-linux_x86_64.whl:
--hash=sha256:2cd17438b679c47e1bb1c63183ff43de5452220904ecc799bb0bc4fdbaa2bb67
  1. I recommended use virtual environment for installation custom wxPython package:
[fedora@fedora35 ~]$ python -m venv /home/fedora/grass_gis_wxpython
[fedora@fedora35 ~]$ source /home/fedora/grass_gis_wxpython/bin/activate
  1. Install whl package:

(grass_gis_wxpython) [fedora@fedora35 ~]$ pip install wxPython-4.1.1-cp310-cp310-linux_x86_64.whl

@neteler
Copy link
Member Author

neteler commented Dec 21, 2021

This is cool: https://transfer.sh/

@tmszi
Copy link
Member

tmszi commented Dec 21, 2021

This is cool: https://transfer.sh/

Thanks Markus for great tip!

@tmszi
Copy link
Member

tmszi commented Dec 21, 2021

@danhox I prepare easy wxPython 4.1.1 installation manual (without time-consuming compilation wxPython from source code), check comment above, please.

@danhox
Copy link

danhox commented Dec 22, 2021

@danhox I prepare easy wxPython 4.1.1 installation manual (without time-consuming compilation wxPython from source code), check comment above, please.

Thank you

@danhox
Copy link

danhox commented Dec 22, 2021

This is cool: https://transfer.sh/

GUI in the background, please wait...
Traceback (most recent call last):
File "/usr/local/grass78/gui/wxpython/wxgui.py", line 73, in OnInit
splash = SC.AdvancedSplash(bitmap=introBmp,
File "/home/danhoneuba/grass_gis_wxpython/lib64/python3.10/site-packages/wx/lib/agw/advancedsplash.py", line 251, in init
self.SetTextFont()
File "/home/danhoneuba/grass_gis_wxpython/lib64/python3.10/site-packages/wx/lib/agw/advancedsplash.py", line 442, in SetTextFont
self._textfont.SetPointSize(self._textsize)
TypeError: Font.SetPointSize(): argument 1 has unexpected type 'float'
OnInit returned false, exiting...

the installation of wxpython 4.11 in virtual env did not solve the problem

@petrasovaa
Copy link
Contributor

the installation of wxpython 4.11 in virtual env did not solve the problem

That's expected, the error was solved in wxPython only a week ago. I backported a workaround to 7.8 branch, but 7.8.7 is not released yet.

@tmszi
Copy link
Member

tmszi commented Dec 23, 2021

It seems combination wxPython 4.1.1 (self compiled master git branch with last commit) is much more problematic (tested on Gentoo and Fedora 35 distribution). I tried launch GRAS GIS 7.8.7 dev version, and wxGUI start without error, but main window has wrong rendered Notebook widget layout.

Screenshot

wxgui_notebook_widget_layout

Additional context

If I comment out these lines code, I get error message:

self._gconsole = GConsole(
guiparent=self, giface=self._giface,
ignoredCmdPattern='^d\..*|^r[3]?\.mapcalc$|^i.group$|^r.import$|'
'^r.external$|^r.external.out$|'
'^v.import$|^v.external$|^v.external.out$|'
'^cd$|^cd .*')
self.goutput = GConsoleWindow(
parent=self.notebook,
gconsole=self._gconsole,
menuModel=self._moduleTreeBuilder.GetModel(),
gcstyle=GC_PROMPT)
self.notebook.AddPage(
page=self.goutput,
text=_("Console"),
name='output')
self.goutput.showNotification.connect(
lambda message: self.SetStatusText(message))
self._gconsole.mapCreated.connect(self.OnMapCreated)
self.goutput.contentChanged.connect(
lambda notification: self._switchPage(notification))
self._gconsole.Bind(EVT_IGNORED_CMD_RUN,
lambda event: self.RunSpecialCmd(event.cmd))
self._setCopyingOfSelectedText()
# create 'search module' notebook page
if not UserSettings.Get(
group='manager', key='hideTabs', subkey='search'):
self.search = SearchModuleWindow(
parent=self.notebook, handlerObj=self,
giface=self._giface,
model=self._moduleTreeBuilder.GetModel())
self.search.showNotification.connect(
lambda message: self.SetStatusText(message))
self.notebook.AddPage(
page=self.search,
text=_("Modules"),
name='search')
else:
self.search = None
# create 'data catalog' notebook page
self.datacatalog = DataCatalog(
parent=self.notebook, giface=self._giface)
self.datacatalog.showNotification.connect(
lambda message: self.SetStatusText(message))
self.datacatalog.changeMapset.connect(lambda mapset: self.ChangeMapset(mapset))
self.datacatalog.changeLocation.connect(lambda mapset, location: self.ChangeLocation(location, mapset))
self.notebook.AddPage(
page=self.datacatalog,
text=_("Data"),
name='catalog')
# create 'python shell' notebook page
if not UserSettings.Get(
group='manager', key='hideTabs', subkey='pyshell'):
self.pyshell = PyShellWindow(
parent=self.notebook, giface=self._giface, simpleEditorHandler=self.OnSimpleEditor)
self.notebook.AddPage(
page=self.pyshell,
text=_("Python"),
name='pyshell')
else:
self.pyshell = None
# bindings
if sys.platform == 'win32':
self.notebook.Bind(
FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,
self.OnPageChanged)
else:
self.notebook.Bind(
wx.EVT_NOTEBOOK_PAGE_CHANGED,
self.OnPageChanged)
self.notebookLayers.Bind(
FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,
self.OnCBPageChanged)
self.notebookLayers.Bind(
FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,
self.OnCBPageClosing)

Error mesage:

Traceback (most recent call last):
  File "/home/fedora/venv/lib64/python3.10/site-packages/wx/lib/agw/flatnotebook.py", line 5202, in OnPaint
    renderer.DrawTabs(self, dc)
  File "/home/fedora/venv/lib64/python3.10/site-packages/wx/lib/agw/flatnotebook.py", line 2357, in DrawTabs
    self.DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc._nTabXButtonStatus)
  File "/home/fedora/venv/lib64/python3.10/site-packages/wx/lib/agw/flatnotebook.py", line 2729, in DrawTab
    DrawButton(dc, rr, pc.GetSelection() == tabIdx , not pc.HasAGWFlag(FNB_BOTTOM))
  File "/home/fedora/venv/lib64/python3.10/site-packages/wx/lib/agw/flatnotebook.py", line 928, in DrawButton
    leftPt = wx.Point(rect.x, rect.y + (rect.height / 10)*8)
TypeError: Point(): arguments did not match any overloaded call:
  overload 1: too many arguments
  overload 2: argument 2 has unexpected type 'float'
  overload 3: argument 1 has unexpected type 'int'
  overload 4: argument 1 has unexpected type 'int'

It seems this wxPython bug wasn't fixed via this PR https://github.com/wxWidgets/Phoenix/pull/2039/files.

For testing purpose self compiled wxPython master git branch, here is binary whl file wxPython-4.1.2a1-cp310-cp310-linux_x86_64.whl (for Fedora 35 distribution).

(venv) [fedora@fedora35 Phoenix]$ pip hash dist/wxPython-4.1.2a1-cp310-cp310-linux_x86_64.whl 
dist/wxPython-4.1.2a1-cp310-cp310-linux_x86_64.whl:
--hash=sha256:020d26d39467ad56aeece2fb759cae26ce8ad8287b6c8e5d9688217c486f48ee

@petrasovaa
Copy link
Contributor

petrasovaa commented Dec 27, 2021


It seems this wxPython bug wasn't fixed via this PR https://github.com/wxWidgets/Phoenix/pull/2039/files.

Right, we may need to create a PR for wxPython. Unfortunately there is not much we can do on our side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GUI wxGUI related
Projects
None yet
Development

No branches or pull requests

5 participants