Source code for enaml.qt.qt_time_selector
#------------------------------------------------------------------------------
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
from .qt.QtGui import QTimeEdit
from .qt_bounded_time import QtBoundedTime
[docs]class QtTimeSelector(QtBoundedTime):
""" A Qt implementation of an Enaml TimeSelector.
"""
#--------------------------------------------------------------------------
# Setup Methods
#--------------------------------------------------------------------------
[docs] def create(self, tree):
""" Create and initialize the underlying widget.
"""
super(QtTimeSelector, self).create(tree)
self.set_time_format(tree['time_format'])
self.widget().timeChanged.connect(self.on_time_changed)
#--------------------------------------------------------------------------
# Message Handling
#--------------------------------------------------------------------------
[docs] def get_time(self):
""" Return the current time in the control.
Returns
-------
result : QTime
The current control time as a QTime object.
"""
return self.widget().time()
[docs] def set_time(self, time):
""" Set the widget's current time.
Parameters
----------
time : QTime
The QTime object to use for setting the time.
"""
with self.loopback_guard('time'):
self.widget().setTime(time)
[docs] def set_max_time(self, time):
""" Set the widget's maximum time.
Parameters
----------
time : QTime
The QTime object to use for setting the maximum time.
"""
self.widget().setMaximumTime(time)
[docs] def set_min_time(self, time):
""" Set the widget's minimum time.
Parameters
----------
time : QTime
The QTime object to use for setting the minimum time.
"""
self.widget().setMinimumTime(time)