Input for wx.adv.TimePickerCtrl

Hi, all
I input time in wx.adv.TimePickerCtrl with keyboard. Sometimes I get the input, use function GetValue(), the obtained value is not the last one, but the one before last.
How to get the last input with wxpython function?
Thanks for your attention!

This seems to work - as you have not shared a minimal reproducible example who knows what you’ve done

import wx
import wx.adv


class MainFrame(wx.Frame):
    """Create MainFrame class."""
    def __init__(self, *args, **kwargs):
        super(MainFrame, self).__init__(None, *args, **kwargs)
        self.Title = 'Time picker'
        self.panel = MainPanel(self, size=(200, 100))
        sizer = wx.BoxSizer()
        sizer.Add(self.panel)
        self.SetSizerAndFit(sizer)
        self.Centre()
        self.Show()

    def print_time(self, event):
        del event
        print(self.panel.timer.GetValue())


class MainPanel(wx.Panel):
    """Panel class to contain frame widgets."""
    def __init__(self, parent, *args, **kwargs):
        super(MainPanel, self).__init__(parent, *args, **kwargs)

        """Create and populate main sizer."""
        self.timer = wx.adv.TimePickerCtrl(self)
        cmd_show = wx.Button(self, label='print')
        cmd_show.Bind(wx.EVT_BUTTON, parent.print_time)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.timer)
        sizer.Add(cmd_show)
        self.SetSizer(sizer)


if __name__ == '__main__':
    screen_app = wx.App()
    MainFrame()
    screen_app.MainLoop()

For example,
first, I input 1 second, and do something else, then TimePickerCtrl doesn’t get forcus,
second, I input 2 second, and TimePickerCtrl gets forcus now. GetValue() would return 1.
I want to get the last input, 2 second. How to do this with wxpython function?

I find a feasible way.
Before invoking GetValue() for TimePickerCtrl, call Navigate() by another control. e.g. wx.TextCtrl.
Thanks!

well, if you use a spin control I imagine you want the user to use it :face_with_hand_over_mouth:
in @psionman example insert the two lines

        self.timer.Bind(wx.EVT_CHAR, lambda _: None)
        self.timer.Bind(wx.adv.EVT_TIME_CHANGED, lambda evt: print(evt.GetDate()))

after the definition of the picker instance

  • the first line blocks manual input

  • the second line will give the changed value