Ejemplo n.º 1
0
def today_calendar():
    fullimg = Image.new('1', (640, 384), color=255)
    fullimg2 = Image.new('1', (640, 384), color=255)
    weather = WeatherWidget(owm_api_key)
    fullimg.paste(weather.get_weather(owm_location), box=(0, 0))
    timewidget = TimeWidget()
    fullimg.paste(timewidget.get_time(), box=(128, 0))
    calendar = CalendarWidget(family_names)
    event_getter = CalDavProvider(calendar_username, calendar_password)
    test_event_list = []

    today_start = datetime.now().replace(hour=8, minute=0, second=0, microsecond=0)
    today_end = today_start.replace(hour=21, minute=0, second=0, microsecond=0)

    for url in calendar_list:
        test_event_list.append(event_getter.get_calendar(url, today_start, today_end))
    img1, img2 = calendar.get_calendar(test_event_list)
    fullimg.paste(img1, box=(0, 80))
    fullimg2.paste(img2, box=(0, 80))
    return fullimg, fullimg2
Ejemplo n.º 2
0
def week_calendar(calid, name):
    fullimg = Image.new('1', (640, 384), color=255)
    fullimg2 = Image.new('1', (640, 384), color=255)
    weather = WeatherWidget(owm_api_key)
    fullimg.paste(weather.get_weather(owm_location), box=(0, 0))
    timewidget = TimeWidget()
    fullimg.paste(timewidget.get_time(), box=(128, 0))
    event_getter = CalDavProvider(calendar_username, calendar_password)
    test_event_list = []

    today = datetime.today()
    curdate = today + timedelta(days=-today.weekday(), weeks=0)
    curdate = curdate.replace(hour=8, minute=0, second=0, microsecond=0)

    for day in range(7, 12):
        test_event_list.append(event_getter.get_calendar(calendar_list[calid], curdate, curdate.replace(hour=21)))
        curdate = curdate + timedelta(days=1)

    calendar = CalendarWidget(['L', 'M', 'X', 'J', 'V'])
   
    img1, img2 = calendar.get_calendar(test_event_list, title=name)
    fullimg.paste(img1, box=(0, 80))
    fullimg2.paste(img2, box=(0, 80))
    return fullimg, fullimg2
Ejemplo n.º 3
0
    def _initialize_dialog_widgets(self):
        self.topcontainer = gtk.VBox(homogeneous=False, spacing=18)
        self.topcontainer.set_border_width(6)

        # Alert Group
        alertFrame = gtk.VBox(homogeneous=False, spacing=6)
        alertAlignment = gtk.Alignment()
        alertAlignment.set_padding(0, 0, 12, 0)
        title = gtk.Label()
        title.set_markup(_("<b>Alarms</b>"))
        title.set_alignment(0.00, 0.50)
        alertFrame.pack_start(title)
        alertFrame.pack_start(alertAlignment)

        alertContainer = gtk.VBox(homogeneous=False, spacing=6)
        self.alertCheckbox = gtk.CheckButton(_('_Alert before due date:'),
                                             use_underline=True)
        self.alertSpinButton = gtk.SpinButton()
        self.alertSpinButton.set_range(0, 360)
        self.alertSpinButton.spin(gtk.SPIN_STEP_FORWARD)
        self.alertSpinButton.set_increments(1, 7)
        alertDays = gtk.Label("%s" % _('day(s).'))
        self.notificationTime = TimeWidget()
        alertPreferredTime = gtk.Label()
        alertPreferredTime.set_markup_with_mnemonic(_('_Preferred time:'))
        alertPreferredTime.set_mnemonic_widget(
            self.notificationTime.hourSpinner)
        alertPreferredTime.set_alignment(0.00, 0.50)
        alertDefinition = gtk.Label(
            _('Get alerted when individual bills are due.'))
        alertDefinition.set_alignment(0.00, 0.90)

        # Add label defining what an alarm means.
        alertContainer.pack_start(alertDefinition,
                                  expand=False,
                                  fill=True,
                                  padding=0)

        # Container for alert checkbox and spin button for day selection.
        hbox = gtk.HBox(homogeneous=False, spacing=4)
        hbox.pack_start(self.alertCheckbox, expand=False, fill=True, padding=0)
        hbox.pack_start(self.alertSpinButton,
                        expand=False,
                        fill=False,
                        padding=0)
        hbox.pack_start(alertDays, expand=False, fill=False, padding=0)
        alertContainer.pack_start(hbox, expand=False, fill=True, padding=0)

        # Container for preferred time for alerts.
        hbox = gtk.HBox(homogeneous=False, spacing=12)
        hbox.pack_start(alertPreferredTime, expand=False, fill=True, padding=0)
        hbox.pack_start(self.notificationTime,
                        expand=True,
                        fill=True,
                        padding=0)
        alertContainer.pack_start(hbox, expand=False, fill=True, padding=0)

        alertAlignment.add(alertContainer)

        # Notification Group
        notifyFrame = gtk.VBox(homogeneous=False, spacing=6)
        title = gtk.Label()
        title.set_markup(_("<b>Notifications</b>"))
        title.set_alignment(0.00, 0.50)
        notifyAlignment = gtk.Alignment()
        notifyAlignment.set_padding(0, 0, 12, 0)
        notifyFrame.pack_start(title)
        notifyFrame.pack_start(notifyAlignment)
        notificationDefinition = gtk.Label(
            _('Define when to be notified of upcoming bills.'))
        notificationDefinition.set_alignment(0.00, 0.90)

        notificationsContainer = gtk.VBox(homogeneous=False, spacing=6)

        # Add label defining what a definition means.
        notificationsContainer.pack_start(notificationDefinition,
                                          expand=False,
                                          fill=False,
                                          padding=0)

        self.notifyCheckbox = gtk.CheckButton(_('_Notify before due date:'),
                                              use_underline=True)
        self.notifySpinButton = gtk.SpinButton()
        self.notifySpinButton.set_range(0, 360)
        self.notifySpinButton.spin(gtk.SPIN_STEP_FORWARD)
        self.notifySpinButton.set_increments(1, 7)
        notifyDays = gtk.Label("%s" % _('day(s).'))

        # Container for notification checkbox and spin button for day selection.
        hbox = gtk.HBox(homogeneous=False, spacing=4)
        hbox.pack_start(self.notifyCheckbox,
                        expand=False,
                        fill=True,
                        padding=0)
        hbox.pack_start(self.notifySpinButton,
                        expand=False,
                        fill=False,
                        padding=0)
        hbox.pack_start(notifyDays, expand=False, fill=False, padding=0)

        notificationsContainer.pack_start(hbox,
                                          expand=False,
                                          fill=True,
                                          padding=0)

        notifyAlignment.add(notificationsContainer)

        # Alert Type Group
        alertTypeFrame = gtk.VBox(homogeneous=False, spacing=6)
        title = gtk.Label()
        title.set_markup(_("<b>Alert Type</b>"))
        title.set_alignment(0.00, 0.50)
        alertTypeAlignment = gtk.Alignment()
        alertTypeAlignment.set_padding(0, 0, 12, 0)
        alertTypeFrame.pack_start(title)
        alertTypeFrame.pack_start(alertTypeAlignment)

        vbox = gtk.VBox(homogeneous=False, spacing=6)

        hbox = gtk.HBox(homogeneous=False, spacing=12)
        self.alertBubble = gtk.RadioButton(label=_("Notification _Bubble"))
        self.alertDialog = gtk.RadioButton(group=self.alertBubble,
                                           label=_("Alert _Dialog"))

        hbox.pack_start(self.alertBubble, expand=False, fill=False, padding=0)
        hbox.pack_start(self.alertDialog, expand=False, fill=False, padding=0)

        vbox.pack_start(hbox, expand=False, fill=False, padding=0)

        alertTypeAlignment.add(vbox)

        # Daemon Warning
        daemonContainer = gtk.VBox(homogeneous=False, spacing=6)
        self.daemonLabel = gtk.Label(
            _("<b>Warning:</b> BillReminder Notifier is \n" \
            "not running! You need to start it in order \n" \
            " to receive notifications."))
        self.daemonLabel.set_justify(gtk.JUSTIFY_CENTER)
        self.daemonLabel.set_use_markup(True)
        daemonImage = gtk.Image()
        daemonImage.set_from_stock('gtk-execute', 2)
        self.daemonButton = gtk.Button(label=_("_Start BillReminder Notifier"))
        self.daemonButton.set_relief(gtk.RELIEF_NONE)
        self.daemonButton.set_image(daemonImage)

        daemonContainer.pack_start(self.daemonLabel,
                                   expand=False,
                                   fill=True,
                                   padding=0)
        daemonContainer.pack_start(self.daemonButton,
                                   expand=False,
                                   fill=True,
                                   padding=0)

        # Everything
        self.topcontainer.pack_start(alertFrame,
                                     expand=False,
                                     fill=True,
                                     padding=0)
        self.topcontainer.pack_start(notifyFrame,
                                     expand=False,
                                     fill=True,
                                     padding=0)
        self.topcontainer.pack_start(alertTypeFrame,
                                     expand=False,
                                     fill=True,
                                     padding=0)

        if not utils.verify_dbus_service(common.DBUS_INTERFACE):
            self.topcontainer.pack_start(daemonContainer,
                                         expand=False,
                                         fill=True,
                                         padding=0)

        self.vbox.pack_start(self.topcontainer, expand=False, fill=True)

        self.show_all()