Ejemplo n.º 1
0
    def _button_clicked(self, button):
        self._calendar_window = ga_Gtk.Window(ga_Gtk.WindowType.TOPLEVEL)
        self._calendar_window.set_type_hint(ga_Gdk.WindowTypeHint.DIALOG)
        self._calendar_window.set_modal(True)
        self._calendar_window.set_title(_("Date Selection"))

        self._calendar.select_month(self._date.month - 1, self._date.year)
        self._calendar.select_day(self._date.day)

        vbox = ga_Gtk.VBox(spacing=3)
        vbox.set_border_width(2)
        vbox.pack_start(self._calendar, True, True, 0)

        button_box = ga_Gtk.HButtonBox()
        button_box.set_layout(ga_Gtk.ButtonBoxStyle.END)
        vbox.pack_start(button_box, True, True, 0)

        button = ga_Gtk.Button(_("Today"))
        button.connect("clicked", self._today_clicked)
        button_box.pack_start(button, True, True, 0)

        frame = ga_Gtk.Frame()
        frame.add(vbox)
        self._calendar_window.add(frame)
        self._calendar_window.set_position(ga_Gtk.WindowPosition.MOUSE)
        self._calendar_window.show_all()

        self._calendar.connect("day-selected-double-click",
                               self._calendar_clicked)
Ejemplo n.º 2
0
    def __init__(self, date):
        """
        Initialize the DatePicker. date is a python datetime.date object.
        """
        super(DatePicker, self).__init__()
        #GObject.GObject.__init__(self)

        image = ga_Gtk.Image.new_from_icon_name('x-office-calendar',
                                                ga_Gtk.IconSize.MENU)
        image.show()

        # set the timezone so we can sent it to the server
        self._date = datetime.datetime(date.year,
                                       date.month,
                                       date.day,
                                       tzinfo=tzlocal())
        self._date_entry = ga_Gtk.Entry()
        self._date_entry.set_width_chars(10)

        self._date_entry.set_text(self._date.date().isoformat())

        atk_entry = self._date_entry.get_accessible()
        atk_entry.set_name('date-entry')

        self._cal_button = ga_Gtk.Button()
        self._cal_button.set_image(image)
        atk_entry = self._cal_button.get_accessible()
        atk_entry.set_name("Calendar")

        self.pack_start(self._date_entry, True, True, 0)
        self.pack_start(self._cal_button, True, True, 0)
        self._cal_button.connect("clicked", self._button_clicked)
        self.connect('date-picked-cal', self._date_update_cal)
        self.connect('date-picked-text', self._date_update_text)

        self._calendar = ga_Gtk.Calendar()
        atk_entry = self._calendar.get_accessible()
        atk_entry.set_name("Calendar")

        self.show()
        self._date_entry.show()
        self._cal_button.show()