I am designing a GUI for instrumentation control using wxPython. I am first setting up all the fields and controls I need. Among those controls are SpinCtrlDouble I use to define frequencies and amplitudes with 3 digits at least. I realised that the float in SpinCtrlDouble was not displayed properly when I have SetDigits() with any number above 2. See the screenshot : floats appear selected and also shifted so you cannot see the first few numbers. Here it should display 21.62100, but the text is shifted so you cannot see the 21. How could I sort this out ? I tried to align the text in the SpinCtrlDouble with wx.TE_RIGHT but it did not change anything. I also tried to span it even more but same problem again.
Edit : I run this program on Win10, with Python3.11.5, wxPython-4.2.3. I use Visual Studio Code IDE. Problem is identical with Python3.9.21 and Python3.13.4.
import wx
class Mywin(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title = 'Hello')
# main panel window
panel = wx.Panel(self)
# main vbox
vbox = wx.BoxSizer(wx.VERTICAL)
# vbox.SetMinSize(self,(600,800))
# StaticBoxSizer for Keithley controls
BoxKeithleySizer = wx.StaticBoxSizer(wx.VERTICAL, panel, 'Keithley :') # StaticBox with edge and title
BoxKeithleyGrid = wx.GridBagSizer(hgap=5, vgap=5) # add widgets to this
toto = BoxKeithleySizer.GetStaticBox()
toto.SetBackgroundColour((255, 201, 201)) # set background color of the StaticBox
# widgets to go in the StaticBoxSizer for Keithley controls
TextKeithleyFreq = wx.StaticText(BoxKeithleySizer.GetStaticBox(), -1, "Freq.")
BoxKeithleyFreq = wx.SpinCtrlDouble(BoxKeithleySizer.GetStaticBox(), -1)
UnitKeithleyFreq = wx.StaticText(BoxKeithleySizer.GetStaticBox(), -1, "MHz")
BoxKeithleyFreq.SetDigits(5)
BoxKeithleyFreq.SetIncrement(0.001)
BoxKeithleyFreq.SetMin(21.600)
BoxKeithleyFreq.SetMax(21.650)
BoxKeithleyFreq.SetValue(21.621)
# add widgets to the StaticBoxSizer for Keithley controls
BoxKeithleyGrid.Add(TextKeithleyFreq, pos=(0,0), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
BoxKeithleyGrid.Add(BoxKeithleyFreq, pos=(0,1), span=(1,5), flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
BoxKeithleyGrid.Add(UnitKeithleyFreq, pos=(0,6), flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
BoxKeithleySizer.Add(BoxKeithleyGrid)
# add Sizers to main vbox and panel
vbox.Add(BoxKeithleySizer,0, wx.ALL|wx.LEFT, 5)
panel.SetSizer(vbox)
class MyApp(wx.App):
def OnInit(self):
frame = Mywin()
frame.Show()
self.SetTopWindow(frame)
return True
def main():
app = MyApp(redirect=False)
app.MainLoop()
if __name__ == "__main__" :
main()
