Has wxpython SpinCtrl/SpinButton changed between C

2019-08-17 07:50发布

问题:

I have started to look at converting one of my projects from python2.7/wxpython 3.0.2.0 to python3.5.2/wxpython 4.0.0b2 and have immediately hit an issue with SpinCtrl/SpinButton.
I'm running on Linux Mint 18.2

Using this code:

import wx

class MainWindow(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        self.panel = wx.Panel(self)
        self.SetSize((200,200))
        sizer=wx.BoxSizer(wx.VERTICAL)
        text1 = wx.StaticText(self.panel,-1,"SpinCtrl")
        self.spin = wx.SpinCtrl(self.panel,-1, size=(100,25),style=wx.SP_VERTICAL)
        text2 = wx.StaticText(self.panel,-1,"SpinButton")
        self.spin2 = wx.SpinButton(self.panel,-1, size=(100,25),style=wx.SP_VERTICAL)
        sizer.Add(text1)
        sizer.Add(self.spin, 0, wx.LEFT, 15)
        sizer.Add((-1, -1), proportion=1)
        sizer.Add(text2)
        sizer.Add(self.spin2, 0, wx.LEFT, 15)
        self.SetSizer(sizer)
        self.Show()

app = wx.App()
win = MainWindow(None)
app.MainLoop()

When running with python2.7/wxpython 3.0.2.0, I get this result:

Whilst running the same code with python3.5.2/wxpython 4.0.0b2, I get this:

I am desperate to get the "old" vertical spin controls back, as they can be sized to take up significantly less space than this "new" version with the +/- controls.
Does anyone know how to get the vertical spin controls back in wxpython 4.0.0b2?

回答1:

As Robin pointed out, one install was using gtk2 and the other gtk3.
The issue was resolved using the following installation instruction.

sudo pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk2/ubuntu-16.04 wxPython