Reputation: 599
I am trying to get a wxPython TimeCtrl
widget to toggle it's value 12hr (AM/PM) format to 24 hour format at the click of a button.
Now I know the TimeCtrl
widget 12/24hr formatting is set at initialization by setting the attribute fmt24hr = False/True depending on if you want to display 24hr format or not.
Here's the API for TimeCtrl::
from wx.lib.masked import TimeCtrl
TimeCtrl(
parent, id = -1,
value = '00:00:00',
pos = wx.DefaultPosition,
size = wx.DefaultSize,
style = wxTE_PROCESS_TAB,
validator = wx.DefaultValidator,
name = "time",
format = 'HHMMSS',
fmt24hr = False,
displaySeconds = True,
spinButton = None,
min = None,
max = None,
limited = None,
oob_color = "Yellow"
)
Now I want to toggle fmt24hr from True to False when a button is clicked but I cannot find a way! As far as I can see in the docs there is no setter for it.
Any help will be appreciated.
Upvotes: 0
Views: 456
Reputation: 33071
I am guessing that that is an attribute you cannot change after the widget is created. You have two options:
Either way, you'll almost certainly want to use Sizer methods to make it appear and disappear in the right location. If you're destroying it, then you'll want Sizer.Remove and Sizer.Insert. If you're just showing and hiding, then you can use the Sizer's Show and Hide methods. You may also want to look into the panel's Freeze and Thaw methods to reduce the amount of flicker.
Upvotes: 1