Package iceprod :: Package client :: Package gtk :: Module gtkcal
[hide private]
[frames] | no frames]

Source Code for Module iceprod.client.gtk.gtkcal

 1  import pygtk 
 2  pygtk.require('2.0') 
 3  import gtk, pango 
 4  import time 
 5   
 6   
7 -class Cal:
8
9 - def calendar_date_to_string(self):
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
14 - def calendar_day_selected_double_click(self, widget):
15 buffer = self.calendar_date_to_string() 16 # year, month, day = self.calendar.get_date() 17 self.text_field.set_text(buffer) 18 self.window.destroy()
19 20
21 - def __init__(self,text_field):
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 # The top part of the window, Calendar, flags and fontsel. 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 # Calendar widget 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