2
# -*- coding: iso-8859-15 -*-
5
__date__ ='$19/02/2012$'
8
# Copyright (C) 2011,2012 Lorenzo Carbonell
9
# lorenzo.carbonell.cerezo@gmail.com
11
# This program is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
14
# (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
21
# You should have received a copy of the GNU General Public License
22
# along with this program. If not, see <http://www.gnu.org/licenses/>.
27
from gi.repository import Gtk
30
class HourEntry(Gtk.HBox):
31
def __init__(self,value=None):
32
Gtk.HBox.__init__(self)
33
self.set_no_show_all(True)
34
self.hour = Gtk.SpinButton()
35
self.hour.set_width_chars(2)
36
self.hour.set_adjustment(Gtk.Adjustment(value=0, lower=0, upper=23, step_incr=1, page_incr=5))
37
self.hour.set_digits(0)
38
self.minute = Gtk.SpinButton()
39
self.minute.set_width_chars(2)
40
self.minute.set_adjustment(Gtk.Adjustment(value=0, lower=0, upper=59, step_incr=5, page_incr=10))
41
self.minute.set_digits(0)
42
self.pack_start(self.hour, 0, 0, 0)
43
self.label = Gtk.Label(':')
44
self.pack_start(self.label, 0, 0, 0)
45
self.pack_start(self.minute, 0, 0, 0)
47
def set_editable(self,editable):
48
self.hour.set_editable(editable)
49
self.minute.set_editable(editable)
51
def set_sensitive(self,sensitive):
52
self.hour.set_sensitive(sensitive)
53
self.minute.set_sensitive(sensitive)
55
def set_visible(self,visible):
59
self.minute.show_all()
65
h = self.hour.get_value_as_int()
66
m = self.minute.get_value_as_int()
67
return datetime.time(h,m)
69
def set_time(self,time):
70
self.hour.set_value(time.hour)
71
self.minute.set_value(time.minute)