Пример #1
0
    def show(self, orientation, togglebutton, entry):
        """orientation = SE = south east
                         SW = south west
                         NE = north east
                         NW = north west
           togglebutton = bound gtk.ToggleButton
           entry = bound gtk.Entry"""

        self.entry = entry
        self.button_widget = togglebutton
        date = entry.get_text()

        if self.parent == None:
            self.parent = Window(get_window(self.entry))
        self.parent.remove_focus()

        self.window = gtk.Window()
        self.window.set_decorated(0)
        self.calendar = gtk.Calendar()
        self.window.add(self.calendar)
        self.window.show_all()
        
        self.window.connect('focus-out-event', self.on_window_focus_out)
        self.window.connect("destroy", self.on_window_destroy)
        self.calendar.connect("day-selected-double-click", self.on_calendar_day_selected_double_click)
        self.calendar.connect("day-selected", self.on_calendar_day_selected)

        togglebutton_allocation = togglebutton.get_allocation()
        togglebutton_x_pos = togglebutton_allocation.x
        togglebutton_y_pos = togglebutton_allocation.y
        togglebutton_width = togglebutton_allocation.width
        togglebutton_height = togglebutton_allocation.height

        window_x_pos, window_y_pos = togglebutton.window.get_origin()
        calendar_width, calendar_height = self.window.get_size()

        if orientation[0:1] == "n":
            calendar_y_pos = window_y_pos + togglebutton_y_pos - calendar_height
        else:
            calendar_y_pos = window_y_pos + togglebutton_y_pos + togglebutton_height

        if orientation[1:2] == "w":
            calendar_x_pos = window_x_pos + togglebutton_x_pos - calendar_width + togglebutton_width
        else:
            calendar_x_pos = window_x_pos + togglebutton_x_pos

        self.window.move(calendar_x_pos, calendar_y_pos)
        self.window.show()

        try:
            # This can be made better (with dateformat)
            self.day = int(date[0:2])
            self.month = int(date[3:5]) - 1
            self.year = int(date[6:10])
            self.calendar.select_month(self.month, self.year)
            self.calendar.select_day(self.day)
        except:
            pass

        self.entry = entry
Пример #2
0
    def __init__(self, parent=None):
        ''' parent = Parent window. '''

        if parent <> None:
            self.icon = parent.get_icon()
        else:
            self.icon = None

        self.parent = Window(parent)
Пример #3
0
 def set_parent(self, parent):
     self.parent = Window(parent)