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

Spin controls missing all or part of spin buttons under GTK3. #1086

Closed
mickp opened this issue Nov 21, 2018 · 16 comments

Comments

Projects
None yet
3 participants
@mickp
Copy link
Contributor

commented Nov 21, 2018

Operating system: manjaro linux
wxPython version & source: pypi 4.0.3 gtk3 (phoenix) wxWidgets 3.0.4
Python version & source: Python 3.7.1 (default, Oct 22 2018, 10:41:28), manjaro/arch pkg

Description of the problem:
Size calculation appears to be wrong for spin buttons and spin controls. Size is fine for the SpinCtrl, but too small to accommodate both the +/- buttons in SpinButton and SpinCtrlDouble.

I see the same results with any theme.

Reproduce by running wxdemo and examining 'Spin*' elements under 'Core Windows/Controls'.
image

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

See #1090

@RobinD42

This comment has been minimized.

Copy link
Member

commented Dec 31, 2018

Did #1090 solve this?

@mickp

This comment has been minimized.

Copy link
Contributor Author

commented Dec 31, 2018

@RobinD42

This comment has been minimized.

Copy link
Member

commented Dec 31, 2018

Please provide a small runnable sample that shows your problem.

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Jan 2, 2019

And do you use hard-coded widget sizes in your own app?

@mickp

This comment has been minimized.

Copy link
Contributor Author

commented Jan 2, 2019

I was determining the size from the maximum string length the control will contain. It looks like that calculation is only leaving enough space for (not quite) one of the two spin buttons.

import wx

class TestFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        kwargs['style'] = wx.DEFAULT_FRAME_STYLE
        super(TestFrame, self).__init__(*args, **kwargs)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        lsizer = wx.BoxSizer(wx.VERTICAL)
        rsizer = wx.BoxSizer(wx.VERTICAL)
        panel = wx.Panel(self)

        lwidgets = []
        rwidgets = []
        for i in range(1,11):
            sc = wx.SpinCtrl(self)
            sc.SetMinSize(sc.GetSizeFromTextSize(sc.GetTextExtent("0" * i)))
            lwidgets.append(sc)

            scd = wx.SpinCtrlDouble(self)
            scd.SetMinSize(scd.GetSizeFromTextSize(scd.GetTextExtent("0" * i)))
            rwidgets.append(scd)

        lsizer.AddMany(lwidgets)
        rsizer.AddMany(rwidgets)
        sizer.AddMany((lsizer,rsizer))
        panel.SetSizerAndFit(sizer)


if __name__ == "__main__":
    app = wx.App(False)
    TestFrame(None).Show()
    app.MainLoop()

image

@RobinD42

This comment has been minimized.

Copy link
Member

commented Jan 2, 2019

I suspect that the issue is a combination of the native eidget behavor having a min size of the text portion (and not sliding the buttons over beyond that) and wxGTK's implementation of wxSpinCtrl::DoGetSizeFromTextSize not taking that into account. 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.

In the meantime the best I can suggest is to not set the minsize on these widgets and let their default best size be used by the sizers, or add some extra fixed size to the value you get back from GetSizeFromTextSize.

@RobinD42 RobinD42 added the wxWidgets label Jan 2, 2019

@RobinD42

This comment has been minimized.

Copy link
Member

commented Jan 2, 2019

OTOH, it looks like this has either already been fixed or perhaps it has something to do with the version of GTK or the theme used. It seems to be working correctly for me on a GTK3 build in my current Phoenix workspace.

snap001

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2019

Robin, what version of GTK3 are you using? I do see this as well with mickp's reproducer. I'm using GTK 3.24.1.

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2019

I think I found the problem, this has been fixed in wx master but not in WX_3_0_BRANCH. I opened a PR to get the fix backported: wxWidgets/wxWidgets#1109

@mickp

This comment has been minimized.

Copy link
Contributor Author

commented Jan 3, 2019

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2019

You can see it in the wxWidgets demos if you change the min and max values for SpinCtrl.

@RobinD42

This comment has been minimized.

Copy link
Member

commented Jan 3, 2019

The VM I tried it on is rather old. It has GTK 3.10.8.

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2019

Yes, that is old enough that it doesn't have the problem. Seems to be in 3.12+ :-)

@swt2c

This comment has been minimized.

Copy link
Contributor

commented Jan 5, 2019

Okay, the fix has been merged to WX_3_0_BRANCH so Robin you can update the subproject commit and this should be fixed.

swt2c added a commit to swt2c/Phoenix that referenced this issue Jan 28, 2019

swt2c added a commit to swt2c/Phoenix that referenced this issue Jan 30, 2019

@RobinD42

This comment has been minimized.

Copy link
Member

commented Feb 3, 2019

Fixed by #1150

@RobinD42 RobinD42 closed this Feb 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.