Wx.lib.agw.knobctrl on linux

Has anyone gotten wx.lib.agw.knobctrl to work on modern Linux systems? I tried it with linux Mint 20 and got this:


self.volume_ctrl=KC.KnobCtrl(self, -1, size=(100, 100))
self.volume_ctrl.SetAngularRange(-45, 225)

Running the code below on Python 3.8.10 + wxPython 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5 + Linux Mint 20.3, I don’t get the extra random tags shown in your example.

Screenshot at 2022-04-23 12-57-06

import wx
import wx.lib.agw.knobctrl as KC

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((200, 200))
        self.panel = wx.Panel(self, wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.volume_ctrl = KC.KnobCtrl(self.panel, wx.ID_ANY, size=(100, 100))
        sizer.Add(self.volume_ctrl, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)

        # Override the default max value
        self.volume_ctrl._maxvalue = 64
        self.volume_ctrl.SetAngularRange(-45, 225)

        self.Bind(KC.EVT_KC_ANGLE_CHANGED, self.OnAngleChanged, self.volume_ctrl)

    def OnAngleChanged(self, event):

class MyApp(wx.App):
    def OnInit(self):
        self.frame = MyFrame(None, wx.ID_ANY, "KnobCtrl")
        return True

if __name__ == "__main__":
    app = MyApp(0)

For some reason, the SetTags() method only overrides the max value if it’s greater than the default value of 100. However, explicitly setting the control’s _maxvalue attr seems to work.

I have a couple of other issues with the KnobCtrl:

  1. Some of the tags are drawn inside the shaded square, while other extend outside it.
  2. When you rotate the knob, the size of the circular position indicator fluctuates randomly.

I think the SetLabel() method is inherited from wx.Window, but it has no visible effect on the KnobCtrl.

I’ve got almost exactly the same configuration

  • 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5
  • Python 3.8.10
  • Linux mint 20.2 (instead of 20.3)

and still get the spurious tags with _maxvalue set. I tried some other scale values and still got extra tabs. I’ll use a better supported widget for now and come back to this when I have some time.

Thanks for the help!

Your screen dump looks as if you have 2 KnobCtrls, one on top of the other, but with different sets of tags.

Are you sure you aren’t creating more than one?

Do you get the same effect when you run my code?