Пример #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
class Progress:
    ''' This is a simple progress dialog. '''
    
    def __init__(self, parent=None):
        ''' parent = Parent window. '''

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

        self.parent = Window(parent)


    def on_window_destroy(self, widget=None, data=None):
        self.parent.restore_focus()


    def show(self, dialog_type='simple', title="Bitte warten...", text="Bitte warten..."):
        ''' dialog type is a string with following possible values:
            simple = Just a self destroying window with progress bar.
            cancel = A progress window with cancel-button. '''

        window = gtk.Window()
        # window.set_keep_above(True)
        window.set_property("skip-taskbar-hint", True)
        window.set_property("skip-pager-hint", True)
        window.connect("destroy", self.on_window_destroy)

        self.parent.remove_focus()

        image = gtk.Image()
        image.set_padding(4, 4)
        image.set_from_file(PATH + "/res/clock_32.png")

        if self.icon <> None:
            window.set_icon(self.icon)
        window.set_position("center")

        vbox = gtk.VBox()
        hbox = gtk.HBox()
        hbox.pack_start(image, True, True, 0)

        label = gtk.Label("\n" + unicode(text, "latin-1") + "\n")
        label.set_use_markup(True)
        label.set_line_wrap(1)
        label.set_padding(4, 4)
        hbox.pack_start(label, True, True, 0)
        vbox.pack_start(hbox, True, True, 0)

        self.progressbar = ProgressBar().create()
        vbox.pack_start(self.progressbar.widget, True, True, 0)
        window.add(vbox)
        window.show_all()


    def update(self, fraction=0):
        self.progressbar.update(fraction)
Пример #3
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)
Пример #4
0
class Progress:
    ''' This is a simple progress dialog. '''
    def __init__(self, parent=None):
        ''' parent = Parent window. '''

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

        self.parent = Window(parent)

    def on_window_destroy(self, widget=None, data=None):
        self.parent.restore_focus()

    def show(self,
             dialog_type='simple',
             title="Bitte warten...",
             text="Bitte warten..."):
        ''' dialog type is a string with following possible values:
            simple = Just a self destroying window with progress bar.
            cancel = A progress window with cancel-button. '''

        window = gtk.Window()
        # window.set_keep_above(True)
        window.set_property("skip-taskbar-hint", True)
        window.set_property("skip-pager-hint", True)
        window.connect("destroy", self.on_window_destroy)

        self.parent.remove_focus()

        image = gtk.Image()
        image.set_padding(4, 4)
        image.set_from_file(PATH + "/res/clock_32.png")

        if self.icon <> None:
            window.set_icon(self.icon)
        window.set_position("center")

        vbox = gtk.VBox()
        hbox = gtk.HBox()
        hbox.pack_start(image, True, True, 0)

        label = gtk.Label("\n" + unicode(text, "latin-1") + "\n")
        label.set_use_markup(True)
        label.set_line_wrap(1)
        label.set_padding(4, 4)
        hbox.pack_start(label, True, True, 0)
        vbox.pack_start(hbox, True, True, 0)

        self.progressbar = ProgressBar().create()
        vbox.pack_start(self.progressbar.widget, True, True, 0)
        window.add(vbox)
        window.show_all()

    def update(self, fraction=0):
        self.progressbar.update(fraction)
Пример #5
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)
Пример #6
0
class Calendar:
    ''' Entry with date validation and togglebutton that pops up a calendar '''

    def __init__(self, togglebutton=None,
                       entry=None,
                       orientation='SW'):
        ''' togglebutton_calendar = Togglebutton to wrap into this class
            entry                 = Entry to wrap into this class
            orientation           = Orientation of Calendar widget around the togglebutton:
                                    SE = south east
                                    SW = south west
                                    NE = north east
                                    NW = north west '''

        self.entry = entry
        self.orientation = orientation.lower()
        self.parent = None

        # If no togglebutton given, search it!
        if togglebutton <> None:
            self.togglebutton = togglebutton
        else:
            table = self.entry.get_parent()
            list_of_children = table.get_children()

            for widget_object in list_of_children:
                widget_name = widget_object.get_name()
                if widget_name.startswith('fixed'):
                    fixed = widget_object
                    self.togglebutton = fixed.get_children()[0]

        self.togglebutton.connect('toggled', self.on_togglebutton_toggled)


    def on_togglebutton_toggled(self, widget=None, data = None):
        if widget.get_active() == 0:
            self.window.destroy()
        else:
            self.show(self.orientation, self.togglebutton, self.entry)


    def on_window_destroy(self, widget, data = None):
        self.togglebutton.set_active(0)
        self.parent.restore_focus()


    def on_calendar_day_selected(self, widget):
        """ Better take one-click-mode in that application """
        return


    def on_calendar_day_selected_double_click(self, widget):
        year, month, day = self.calendar.get_date()
        date_str = ""

        if len(str(day)) == 1:
            date_str = date_str + "0"
        date_str = date_str + str(day)+"."
        if len(str(month + 1)) == 1:
            date_str = date_str + "0"
        date_str = date_str + str(month+1)+"."+str(year)

        self.entry.set_text(date_str)
        self.window.destroy()


    def on_window_focus_out(self, widget, event):
        self.window.destroy()
        
        
    def create(self):
        return self


    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


    def set_text(self, text):
        self.entry.set_text(text)


    def get_text(self):
        return self.entry.get_text()
Пример #7
0
 def set_parent(self, parent):
     self.parent = Window(parent)