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

HyperLinkCtrl break layout of panel containing multiple sizers #2686

Open
arigit opened this issue Feb 2, 2025 · 8 comments
Open

HyperLinkCtrl break layout of panel containing multiple sizers #2686

arigit opened this issue Feb 2, 2025 · 8 comments

Comments

@arigit
Copy link

arigit commented Feb 2, 2025

In this simple scenario,

import wx
import wx.lib.agw.hyperlink as hl

class MyFrame(wx.Frame):
    def __init__(self):
        super().__init__(None, title="wxPython Layout Example", size=(400, 200))

        # Main panel
        panel = wx.Panel(self)

        # Vertical BoxSizer
        vbox = wx.BoxSizer(wx.VERTICAL)

        # Horizontal BoxSizer inside the VBox
        hbox = wx.BoxSizer(wx.HORIZONTAL)

        # HyperLinkCtrl inside the HBox
        hyperlink = hl.HyperLinkCtrl(panel, id=wx.ID_ANY, label="Visit wxPython", 
                                     URL="https://www.wxpython.org/")

        # Add HyperLink to HBox
        hbox.Add(hyperlink, flag=wx.ALL, border=10)

        # Add HBox to VBox
        vbox.Add(hbox, flag=wx.ALIGN_CENTER)

        # Set sizer for the panel
        panel.SetSizer(vbox)

        self.Centre()

if __name__ == "__main__":
    app = wx.App(False)
    frame = MyFrame()
    frame.Show()
    app.MainLoop()

the resulting window shows:

Image

which is totally broken (the window border shows transparent, window controls disappear, the window title shows below the hyperlink.

When using any other widget, for example a StaticText,

import wx
import wx.lib.agw.hyperlink as hl

class MyFrame(wx.Frame):
    def __init__(self):
        super().__init__(None, title="wxPython Layout Example", size=(400, 200))

        # Main panel
        panel = wx.Panel(self)

        # Vertical BoxSizer
        vbox = wx.BoxSizer(wx.VERTICAL)

        # Horizontal BoxSizer inside the VBox
        hbox = wx.BoxSizer(wx.HORIZONTAL)

        # HyperLinkCtrl inside the HBox
        #hyperlink = hl.HyperLinkCtrl(panel, id=wx.ID_ANY, label="Visit wxPython", 
        #                             URL="https://www.wxpython.org/")

        hyperlink = wx.StaticText(panel, label="Visit wxPython")

        # Add HyperLink to HBox
        hbox.Add(hyperlink, flag=wx.ALL, border=10)

        # Add HBox to VBox
        vbox.Add(hbox, flag=wx.ALIGN_CENTER)

        # Set sizer for the panel
        panel.SetSizer(vbox)

        self.Centre()

if __name__ == "__main__":
    app = wx.App(False)
    frame = MyFrame()
    frame.Show()
    app.MainLoop()

then the layout is as correct, as expected:

Image

I ran into this while trying to use HyperLinkCtrl in an complex GUI and it completely broke it.

Environment:
Ubuntu 24.01.1 / LTS using Wayland

apt show python3-wxgtk4.0
Package: python3-wxgtk4.0
Version: 4.2.1+dfsg-3build2

python3 --version
Python 3.12.3

gtk-launch --version
3.24.41

@reticulatus
Copy link
Contributor

Your example looks OK using wxPython 4.2.2 gtk3 (phoenix) wxWidgets 3.2.6 + Python 3.12.3 + Linux Mint 22.1

Image

Mint 22.1 uses X11 by default, not Wayland.

@da-dada
Copy link

da-dada commented Feb 3, 2025

@arigit look ok on Windows as well

@arigit
Copy link
Author

arigit commented Feb 4, 2025

I tested in a Fedora 41 VM, with the same wxpython version.

python3-wxpython4-0:4.2.1-9.fc41.x86_64
Also on wayland,

loginctl show-session $(awk '/tty/ {print $1}' <(loginctl)) -p Type | awk -F= '{print $2}'
wayland

python3 --version
Python 3.13.1

gtk-launch --version
3.24.43

And here it works well:

Image

It's gtk 3.24 in both (minor versions differ) , slightly newer python in fedora (3.13, vs 3.12 in ubuntu)

@arigit
Copy link
Author

arigit commented Feb 4, 2025

I tested also in a ubuntu VM, 24.04LTS running wayland, same as my main PC minus the Nvidia proprietary driver, and it works well there too.

Same versions of everything, in this case.

So the problem only manifests on Wayland with the Nvidia proprietary driver (I use for OpenCL/CUDA acceleration mainly).

Weirdly enough, it only impacts this particular widget. When this widget is present in the window (it doesn't matter what other widgets are in the same window), they layout breaks, the border becomes transparent etc.

@swt2c swt2c changed the title HyperLilnkCtrl break layout of panel containing multiple sizers HyperLinkCtrl break layout of panel containing multiple sizers Feb 4, 2025
@infinity77
Copy link
Contributor

Out of curiosity, does it happen also with the C++ version of HyperLinkCtrl (under wx.adv)?

@reticulatus
Copy link
Contributor

The test I ran previously was on an all AMD PC.

I have just run the example code on a PC that has an NVIDIA GeForce RTX 3060 Ti graphics card and is using NVIDIA driver 550.120. The display from the example looks identical to what I got on the AMD PC. The PC with NVIDIA is running the same versions of Python, wxPython and Mint as the AMD PC.

Both PCs have GTK 3.24.41

@arigit
Copy link
Author

arigit commented Feb 5, 2025

@infinity77 the wx.adv version works!

with

        hyperlinkPlusPlus = wx.adv.HyperlinkCtrl(panel, id=wx.ID_ANY, label="Visit wxPython", 
                                     url="https://www.wxpython.org/")     

Image

it works well.

With import wx.lib.agw.hyperlink as hl

Image

it breaks.

This is in my original setup with the nvidia proprietary driver:

Image

It's a desktop card and the 565 has been working really well. Prior drivers had some basic issues with wayland.

Next I will downgrade the driver to 550 and retest.

@arigit
Copy link
Author

arigit commented Feb 5, 2025

@reticulatus I tested with:

NVIDIA-SMI 550.144.03 Driver Version: 550.144.03 CUDA Version: 12.4

the version that installs when I do apt install nvidia-driver-550, seems to be a bit newer vs. yours.

The result is the same as above,

  • wx.lib.agw.hyperlink: broken
  • wx.adv.HyperlinkCtrl: works

Same GTK version:

gtk-launch --version
3.24.41
gtk4-launch --version
4.14.2

So no difference vs. nvidia version 565

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

4 participants