1 import pygtk
2 pygtk.require('2.0')
3 import gtk, pango
4 import time
5
6
8
10 year, month, day = self.calendar.get_date()
11 mytime = time.mktime((year, month+1, day, 0, 0, 0, 0, 0, -1))
12 return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(mytime))
13
19
20
22 self.text_field = text_field
23 self.calendar = None
24
25 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
26 self.window = window
27 window.set_title("Calendar Example")
28 window.set_resizable(False)
29
30 vbox = gtk.VBox(False)
31 window.add(vbox)
32
33
34 hbox = gtk.HBox(False)
35 vbox.pack_start(hbox, True, True)
36 hbbox = gtk.HButtonBox()
37 hbox.pack_start(hbbox, False, False)
38 hbbox.set_layout(gtk.BUTTONBOX_SPREAD)
39 hbbox.set_spacing(5)
40
41
42 frame = gtk.Frame("Calendar")
43 hbbox.pack_start(frame, False, True)
44 calendar = gtk.Calendar()
45 calendar.connect('day_selected_double_click', self.calendar_day_selected_double_click)
46 self.calendar = calendar
47 frame.add(calendar)
48
49 separator = gtk.VSeparator()
50 hbox.pack_start(separator, False, True, 0)
51
52 window.show_all()
53