OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
831 stars 302 forks source link

[Bug] Menu icon shift #2078

Closed kikislater closed 2 years ago

kikislater commented 2 years ago

Describe the bug Icons are not in the right place making GUI unusable

To Reproduce Steps to reproduce the behavior:

  1. Install GRASS 7.8.7 under archlinux based distribution with the following parameters
# Maintainer: Sylvain POULAIN <sylvain dot poulain at giscan dot com>
# Contributor: Doug Newgard <scimmia at archlinux dot org>
# Contributor: Maciej Sieczka <msieczka at sieczka dot org>

pkgname=grass
pkgver=7.8.7B1
pkgrel=1
_shortver=${pkgver%.*}; _shortver=${_shortver/./}
pkgdesc='Geospatial data management and analysis, image processing, graphics/maps production, spatial modeling and visualization'
arch=('i686' 'x86_64')
url='http://grass.osgeo.org/'
license=('GPL')
depends=('bzip2' 'cairo' 'fftw' 'fontconfig' 'freetype2' 'gcc-libs' 'gdal' 'geos' 'glibc' 'glu'
         'libpng' 'libtiff' 'libx11' 'libgl' 'netcdf' 'pdal' 'proj' 'python-gdal' 'python-numpy'
         'python-pillow' 'python-wxpython41' 'readline' 'zlib' 'zstd')
makedepends=('libxt')
optdepends=('postgresql: PostgreSQL database interface'
            'sqlite: SQLite database interface')
#source=("http://grass.osgeo.org/grass$_shortver/source/$pkgname-$pkgver.tar.gz")
source=("https://github.com/OSGeo/grass/archive/refs/heads/releasebranch_7_8.zip")
md5sums=('SKIP')

build() {
  mv $pkgname-releasebranch_7_8 $pkgname-$pkgver
  cd $pkgname-$pkgver

  # Ancient autoconf used upstream can't handle CPPFLAGS correctly, so set CPP to ignore warnings
  CPP="gcc -E -w" \
  ./configure \
    --prefix=/opt/$pkgname \
    --with-freetype-includes=/usr/include/freetype2 \
    --with-wxwidgets \
    --with-readline \
    --with-pthread \
    --with-netcdf \
    --with-nls \
    --with-geos \
    --with-postgres \
    --with-pdal \
    --with-bzlib \
    --with-zstd

  LC_ALL=C
  make
}

package() {
  cd $pkgname-$pkgver

  make exec_prefix="$pkgdir/usr" INST_DIR="$pkgdir/opt/$pkgname" install

  # Install linker config file, needed for qgis to find grass
  install -d "$pkgdir/etc/ld.so.conf.d/"
  echo "/opt/$pkgname/lib" > "$pkgdir/etc/ld.so.conf.d/$pkgname.conf"

  cd "$pkgdir/opt/$pkgname"
  # Put freedesktop.org files in correct location
  mv share "$pkgdir/usr"

  # Fix some paths that get hard coded by make install
  sed -i "s|$pkgdir||g" demolocation/.grassrc$_shortver \
                        include/Make/{Platform,Grass}.make \
                        etc/fontcap \
                        "$pkgdir/usr/bin/grass$_shortver"
}
  1. Launch GRASS Sector/Region
  2. Watch strange icons arrangement => screenshot below

Expected behavior Icons fit the right place with right mouse hover

Screenshots If applicable, add screenshots to help explain your problem.

image

System description (please complete the following information):

g.version -rge
version=7.8.7dev
date=2022
revision=f08edf6
build_date=2022-01-10
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=2022-01-10T15:37:02+00:00
libgis_date=2022-01-10T09:00:00+01:00
proj=8.2.0
gdal=3.4.0
geos=3.9.1
sqlite=3.37.0
$ python3 -c "import sys, wx; print(sys.version); print(wx.version())"
3.10.1 (main, Dec 18 2021, 23:53:45) [GCC 11.1.0]
4.1.1 gtk3 (phoenix) wxWidgets 3.1.5

Additional context It doesn't happen with GRASS 8.0.0RC1 (screenshot below) image

veroandreo commented 2 years ago

See #2040 for reference. Seems the same issue. Maybe wxpython or wxwidgets didn't get the fixes yet (?)

kikislater commented 2 years ago

Hum ok, That's what I was looking for but I didn't find it unfortunately ...

tmszi commented 2 years ago

Yes it is related to Python 3.10 version and wxPython 4.1.1 (last official release is from 2020-11-21 00:00) in this case. The release of the new version will probably take some time.

I think it would be good to inform users what combination of Python and wxPython will allow the G7/G8 version to work through our website (not all users are able to apply wxPython patches).

kikislater commented 2 years ago

I think it would be good to inform users what combination of Python and wxPython will allow the G7/G8 version to work through our website (not all users are able to apply wxPython patches).

Agreed with that. IMO from user experience, these wx bugs are annoying

veroandreo commented 2 years ago

Yes it is related to Python 3.10 version and wxPython 4.1.1 (last official release is from 2020-11-21 00:00) in this case. The release of the new version will probably take some time.

I think it would be good to inform users what combination of Python and wxPython will allow the G7/G8 version to work through our website (not all users are able to apply wxPython patches).

Agreed! Would you mind helping out with a small text snippet regarding which python/wxpython versions work well with which GRASS versions? An advise for advanced users might be worth it as well.

petrasovaa commented 2 years ago

A simple advice is to use Python <= 3.9. If you need Python >= 3.10, you need latest GRASS and latest wxPython. WxPython daily snapshots for Mac and Windows are available here, for linux you need to compile wxPython yourself.

kikislater commented 2 years ago

So I rebuild python-wxpython 4.1.1 with this patch : https://github.com/wxWidgets/Phoenix/commit/aa3dca0e40bd0701e82ce40297a982b5b84844dc as suggested in other linked issue Then rebuild grass and ... it doesn't work ! Icons are still shifted whereas in 8 it works.

Grass 8.0.0RC1 doesn't work better in Archlinux based distributions :

veroandreo commented 2 years ago
* Problem with extensions :  `g.extension.all -f` is broken

Would you please open a separate bug report for this and set the 8.0.0 milestone

* GRASS scripts like v.triangle have a grass 7 check. They need to be updated. So no stable usage at this time

Which GRASS version is this module or add-on from? I do not find it in core or addons lists. In any case, the version checks for addons are a work in progress and ideally addon authors should take care of that. If this is not in GRASS official repo, you could report with the author.

* Building QGIS with GRASS 8 and QGIS will not find GRASS

Maybe this could be reported/requested in QGIS too. IIRC it was a hardcoded thing. For the GRASS plugin though, you can customize the GRASS version you want

* No single UI or I didn't find the option to enable it

This is only available in main branch, so you'd need to compile that one. It's planned for 8.2 release

petrasovaa commented 2 years ago

So I rebuild python-wxpython 4.1.1 with this patch : wxWidgets/Phoenix@aa3dca0 as suggested in other linked issue Then rebuild grass and ... it doesn't work ! Icons are still shifted whereas in 8 it works.

There are many more patches needed... I think this one is an important one as well.

tmszi commented 2 years ago
* Problem with extensions :  `g.extension.all -f` is broken

Reinstallation of composed addons such as wx.metadata (multiple modules) is problematic and doesn't work.

neteler commented 2 years ago

See #2040 for reference. Seems the same issue. Maybe wxpython or wxwidgets didn't get the fixes yet (?)

You can locally patch your wxpython installation with https://github.com/wxWidgets/Phoenix/commit/aa3dca0e40bd0701e82ce40297a982b5b84844dc

If it helps (very likely, as it did for me), then pls tell the wxpython maintainer in archlinux to patch the wxpython package accordingly. As @petrasovaa says, many more patches are needed. You may cherry-pick them from here: https://src.fedoraproject.org/rpms/python-wxpython4/commits/rawhide

neteler commented 2 years ago

So I rebuild python-wxpython 4.1.1 with this patch : wxWidgets/Phoenix@aa3dca0 as suggested in other linked issue Then rebuild grass and

BTW: AFAIK no need to recompile GRASS when fixing wxpython. It will run out of the box (or not).

kikislater commented 2 years ago

@veroandreo : Thank you, I will report g.extension bug but @tmszi already says it will not work. It was just an alert from grass 7 that we have to rebuild extensions so should it be ignored in 8's version ? For grass scripts, there are only fews and minor editing is needed : https://github.com/amuriy/GRASS-scripts Ok for the main Ui, it's a bit confusing as it seems to be the main feature users would like to test with 8

@petrasovaa : it works now ! Thanks @neteler : Thanks, it works with more patches like said above without rebuilding grass. BTW, building GRASS is not that long nowaday (we have more powerfull laptops/desktops) ...

kikislater commented 2 years ago

But there is something disturbing :
wxPython is released as 4.1.1 ... no new version since this one, so advising about wxPython not released is more than confusing. All distribution will be break for GRASS and not be able to run GRASS GIS ...

neteler commented 2 years ago

If you refer to https://github.com/wxWidgets/Phoenix/releases then I don't know. You find the current releases actually here: https://pypi.org/project/wxPython/#history

Check the commit history, there are plenty of recent improvements (and some even came from @petrasovaa!): https://github.com/wxWidgets/Phoenix/commits/master

All distribution will be break for GRASS and not be able to run GRASS GIS ...

Not exactly: e.g. in Fedora the shipped version is wxPython 4.0.7, with plenty of backports. It works quite nicely and reported issues have been quickly fixed. See here that many distros still stick to wxPython 4.0.7: https://repology.org/project/python:wxpython/versions

kikislater commented 2 years ago

I was referring to https://wxpython.org/ WxWidgets is too confusing for me ^^ I never understood this break between 4.0.7 and newer version as some consider 4.1.1 to be a development version

nilason commented 2 years ago

It is changes in Python 3.10 that triggers these problems, independent of wxPython version. Please see https://github.com/wxWidgets/Phoenix/issues/2038 for discussion.

tmszi commented 2 years ago

Agreed! Would you mind helping out with a small text snippet regarding which python/wxpython versions work well with which GRASS versions? An advise for advanced users might be worth it as well.

Supported Python / wxPython versions

Python / wxPython version GRASS GIS 7.8.6 GRASS GIS 8.0.0 RC1
Python <= 3.9 / wxPython = 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5 1 work work
Python <= 3.9 / wxPython = 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5 1 work work
Python = 3.10 / wxPython = 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5 1 doesn't work doesn't work
Python = 3.10 / wxPython = 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5 1 doesn't work doesn't work
Python = 3.10 / wxPython = last code from master git branch 2 doesn't work 3 work

1 offcial wxPython release without patches 2 require self compilation 3 require self compiled last code from releasebranch_7_8 git branch

How to detect the Python / wxPython version?

tomas@gentoo-gnu-linux:~$ python -c "import sys, wx; print(sys.version, wx.version())"
3.9.9 (main, Dec  5 2021, 18:02:20) 
[GCC 11.2.0] 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5

Python 3.9.9 version wxPython 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5 version

wxPython self compilation (universal way)

wxPython self compilation (OS GNU/Linux) require compiler collection (gcc, gcc-c+...) to be installed and last wxPython code from master git branch. After the compilation process is complete, Python binary wheel file wxPython-4.1.2a1-cp310-cp310-linux_x86_64.whl is created for installation in an isolated virtual Python environment.

tomas@gentoo-gnu-linux:~/src/wxpython-master-branch$ git clone https://github.com/wxWidgets/Phoenix.git 

tomas@gentoo-gnu-linux:~/src/wxpython-master-branch$ cd Phoenix/

tomas@gentoo-gnu-linux:~/src/wxpython-master-branch$ git submodule update --init --recursive

tomas@gentoo-gnu-linux:~/src/wxpython-master-branch/Phoenix$ python3.10 -m venv ../venv 

tomas@gentoo-gnu-linux:~/src/wxpython-master-branch/Phoenix$ source ../venv/bin/activate && pip install sip==5.5.0

(venv) tomas@gentoo-gnu-linux:~/src/wxpython-master-branch/Phoenix$ python build.py dox etg --nodoc sip build

(venv) tomas@gentoo-gnu-linux:~/src/wxpython-master-branch/Phoenix$ python setup.py bdist_wheel --universal

(venv) tomas@gentoo-gnu-linux:~/src/wxpython-master-branch/Phoenix$ pip install dist/wxPython-4.1.2a1-cp310-cp310-linux_x86_64.whl

(venv) tomas@gentoo-gnu-linux:~/src/wxpython-master-branch/Phoenix$ python -c "import wx; print(wx.version())"
4.1.2a1 gtk3 (phoenix) wxWidgets 3.1.5
kikislater commented 2 years ago

Python <= 3.9 / wxPython = 4.0.7.post2 gtk3 (phoenix) wxWidgets 3.0.5 1

7.8.6 runs as well with Python <= 3.9 / wxPython = 4.1.1 / wxWidgets 3.0.5 1 I know it's not common but we had no issue with it !

kikislater commented 2 years ago

And >= 7.8.5 needs wxPython 4.1.1 otherwise you fall into this issue : https://github.com/OSGeo/grass/issues/1261

neteler commented 2 years ago

And >= 7.8.5 needs wxPython 4.1.1 otherwise you fall into this issue : #1261

Did you already try with the current release_branch_7_8 (upcoming 7.8.7)? Several GUI fixes have been done, for me it works fine with the enhanced wxpython 4.0.7 (Fedora 35).

kikislater commented 2 years ago

yes it was mentionned in post 1 of this thread inside quoted PKGBUILD (bash script to build package on archlinux). But we don't have backports of patches you have in fedora 35 for wxpython 4.0.7

source=("https://github.com/OSGeo/grass/archive/refs/heads/releasebranch_7_8.zip")

But now everything (7.8.7 from yesterday) is ok since I patched wxpython 4.1.1 as mention above. I will stay with this version at this time as :

tmszi commented 2 years ago
* 8.0.0RC1 don't have single window and it still confuse with g.extension in this version,

If you want try experimental single window mode, you have to compile GRASS GIS dev main git branch (this functionality is not planned for version 8.0.0) as mentioned above.

Could you specify exactly what you have a problem with the g.extension module?

kikislater commented 2 years ago

Hi All,

Finally, WxPython 4.1 wasn't a solution ... Grass works well with it but it breaks others softwares like filezilla. Filezilla even dev branch doesn't build with wxgtk > 3.0.5. Filezilla consider (as well for Archlinux) that WxWidgets 3.1.5 and WxPython 4.1.1 is a development version ... So Grass works but it breaks other software, not only filezilla ! (mediainfo, gnuplot, poedit, audacity among others.

Edit :

And I tried backporting patch to 4.0.7 but fail with same issue : https://github.com/OSGeo/grass/issues/2019 as @petrasovaa said, it needs 4.1 ... Finally no solution !

kikislater commented 2 years ago

Still happen in grass 8.0.1 on layer tab with WxWidgets 3.1.5 and WxPthon 4.1.1 :

image

neteler commented 2 years ago

@kikislater can you please try with 8.2.0RC2?

kikislater commented 2 years ago

Do you mean RC1 ? I couldn't find RC2

kikislater commented 2 years ago

problem still occur but now I found the culprit, problem is in wxpython flatnotebook.py, some values are still float. Errors could be shown in console output. I will a push a PR and will report here

Example with grass 8.0.2

Before :

image

image

After :

image

image

neteler commented 2 years ago

Perhaps the offending line in your version of flatnotebook.py needs to be

dc.DrawText(pc.GetPageText(tabIdx), int(posx + textOffset), imageYCoord)

Here are patches applied in the Fedora version which are AFAIK also merged in upstream: https://src.fedoraproject.org/rpms/python-wxpython4/blob/b8b9030f9a6d1ee1ac443280e578cfac782df451/f/587f3418f2b772cfd24686f4448a29f340791e6b.patch

kikislater commented 2 years ago

Mine was also be patched with this commit => https://github.com/wxWidgets/Phoenix/commit/aa3dca0e40bd0701e82ce40297a982b5b84844dc

Others lines needs to be modified :

$ cat flatnotebook.py | grep dc.DrawText
        mem_dc.DrawText("Opened tabs:", txtPt.x, txtPt.y)
        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
        dc.DrawText(pc.GetPageText(tabIdx), int(posx + textOffset), imageYCoord)
        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
        dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, int(imageYCoord))
kikislater commented 2 years ago

So finally, I got it !

In Manjaro / Archlinux, we have the release of wxpython 4.1.1 in AUR (Arch User Repository) but these patches need to be added :

https://github.com/wxWidgets/Phoenix/commit/aa3dca0e40bd0701e82ce40297a982b5b84844dc https://github.com/wxWidgets/Phoenix/commit/f5a55e6bf38ab5a0e7b7161477d2d523d057ec29 https://github.com/wxWidgets/Phoenix/commit/d9725119d742ff25e815d0824c62abd8953a61df

Usable PKGBUILD available here : https://github.com/giscan/AUR/tree/main/python-wxpython-dev