Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

wx.StaticText doesn't autoresize under Linux when changing font (GTK3)

Open fhoech opened this issue 6 years ago • 3 comments

Operating system: Linux (Fedora 30, GNOME 3) wxPython version & source: 4.0.4 (Fedora repos) Python version & source: Python 2.7, 3.7 (Fedora repos)

Description of the problem: wx.StaticText fails to automatically adjust its size when the font is changed like on other platforms (Windows/macOS).

import wx

app = wx.App()
frame = wx.Frame(None, title='Hello World')
panel = wx.Panel(frame)
st = wx.StaticText(panel, label="Hello World!")
font = st.GetFont()
font.PointSize += 10
font = font.Bold()
st.Font = font
frame.Show()
app.MainLoop()

fhoech avatar May 19 '19 13:05 fhoech

Note that if a sizer is used, this issue wouldn't be a problem because the sizer uses the best size to calculate the layout.

import wx

app = wx.App()
frame = wx.Frame(None, title='Hello World')
panel = wx.Panel(frame)
st = wx.StaticText(panel, label="Hello World!")
font = st.GetFont()
font.PointSize += 20
font = font.Bold()
st.Font = font
sizer = wx.BoxSizer()
sizer.Add(st)
panel.SetSizer(sizer)
frame.Show()
app.MainLoop()

That said, this is an inconsistency that should probably be fixed. Please create a ticket for this at https://trac.wxwidgets.org/, if one doesn't already exist, and add a link to the ticket here so we can track it.

RobinD42 avatar May 20 '19 15:05 RobinD42

Thanks. After a bit of hunting, there indeed seems to be already a ticket for wxWidgets: https://trac.wxwidgets.org/ticket/16088

fhoech avatar May 20 '19 16:05 fhoech

This issue has been mentioned on Discuss wxPython. There might be relevant details there:

https://discuss.wxpython.org/t/an-on-off-button-alternative-to-checkbox/36304/20

RobinD42 avatar Apr 25 '23 17:04 RobinD42