Esempio n. 1
0
    def __init__(self, parent, *args, **kwargs):
        """
        Initialize widget.

        Args:
            parent (OverviewScreen): Parent window for this dialog.
        """
        super(DateRangeSelectDialog, self).__init__(*args, **kwargs)
        self.set_transient_for(parent)
        self._mainbox = Gtk.Grid()
        self._mainbox.set_hexpand(True)
        self._mainbox.set_vexpand(True)

        self._start_calendar = Gtk.Calendar()
        self._end_calendar = Gtk.Calendar()

        self._mainbox.attach(self._get_today_widget(), 0, 0, 4, 1)
        self._mainbox.attach(self._get_week_widget(), 0, 1, 4, 1)
        self._mainbox.attach(self._get_month_widget(), 0, 2, 4, 1)
        self._mainbox.attach(self._get_custom_range_label(), 0, 3, 1, 1)
        self._mainbox.attach(self._get_custom_range_connection_label(), 2, 3,
                             1, 1)
        self._mainbox.attach(self._start_calendar, 1, 3, 1, 1)
        self._mainbox.attach(self._end_calendar, 3, 3, 1, 1)

        self.get_content_area().add(self._mainbox)
        self.add_action_widget(self._get_apply_button(),
                               Gtk.ResponseType.APPLY)
        self.show_all()
Esempio n. 2
0
    def init_search_prop_popover(self):
        self.search_prop_popover = Gtk.Popover()

        self.date_switch = Gtk.Switch(hexpand=False,
                                      hexpand_set=True,
                                      margin=5)
        self.date_switch.connect("notify::active",
                                 lambda w, p: self.on_search_changed())

        self.date_from = Gtk.Calendar(margin=5, sensitive=False)
        self.date_to = Gtk.Calendar(margin=5, sensitive=False)
        for cal in [self.date_from, self.date_to]:
            cal.connect('day-selected', lambda w: self.on_search_changed())
            cal.set_display_options(
                Gtk.CalendarDisplayOptions.SHOW_DAY_NAMES
                | Gtk.CalendarDisplayOptions.SHOW_HEADING
                | Gtk.CalendarDisplayOptions.SHOW_WEEK_NUMBERS)
            cal.set_property('width-request', 240)

        popover_box = Gtk.Grid()
        popover_box.attach(Gtk.Separator(), 0, 0, 2, 1)
        popover_box.attach(self.date_switch, 0, 1, 2, 1)
        popover_box.attach(Gtk.Label(label="From", margin=5, xalign=0), 0, 2,
                           1, 1)
        popover_box.attach(Gtk.Label(label="To", margin=5, xalign=0), 1, 2, 1,
                           1)
        popover_box.attach(self.date_from, 0, 3, 1, 1)
        popover_box.attach(self.date_to, 1, 3, 1, 1)
        popover_box.show_all()

        self.search_prop_popover.add(popover_box)
Esempio n. 3
0
    def __init__(self, model):
        super().__init__()

        self.model = model
        self.filter_set = None

        self.date_selector_from = Gtk.Calendar()
        self.date_selector_to = Gtk.Calendar()

        for cal in [self.date_selector_from, self.date_selector_to]:
            cal.connect('day-selected', lambda w: self.on_search_changed())
            cal.set_display_options(
                Gtk.CalendarDisplayOptions.SHOW_DAY_NAMES
                | Gtk.CalendarDisplayOptions.SHOW_HEADING
                | Gtk.CalendarDisplayOptions.SHOW_WEEK_NUMBERS)
            cal.set_property('width-request', 240)

        self.select_date_stack = Gtk.Stack()
        self.select_date_button = Gtk.Button(label='Select Dates...',
                                             tooltip_text=_('Select a date'),
                                             hexpand=True)
        self.select_date_button.connect('clicked', self.select_date_clicked)
        self.select_date_entry = Gtk.Entry(
            secondary_icon_name='x-office-calendar-symbolic',
            secondary_icon_tooltip_text=_(
                'Show a calendar to select the date'))
        self.clear_date_button = Gtk.Button(image=Gtk.Image.new_from_icon_name(
            "edit-clear-symbolic", Gtk.IconSize.MENU))
        self.clear_date_button.connect('clicked', self.clear_date_clicked)

        btn_box = Gtk.ButtonBox(layout_style=Gtk.ButtonBoxStyle.EXPAND)
        btn_box.set_homogeneous(False)
        btn_box.pack_start(self.select_date_button, True, True, 0)
        btn_box.pack_start(self.clear_date_button, False, True, 0)

        self.select_date_stack.add_named(btn_box, 'date-select')
        self.select_date_stack.add_named(self.select_date_entry, 'date-entry')

        self.select_date_revealer = Gtk.Revealer(
            transition_type=Gtk.StackTransitionType.SLIDE_DOWN)
        revealer_box = Gtk.Grid(row_spacing=9, column_spacing=18)
        revealer_box.attach(Gtk.Label(label="Since...", xalign=0), 0, 0, 1, 1)
        revealer_box.attach(self.date_selector_from, 0, 1, 1, 1)
        revealer_box.attach(Gtk.Label(label="Until...", xalign=0), 0, 2, 1, 1)
        revealer_box.attach(self.date_selector_to, 0, 3, 1, 1)
        self.select_date_revealer.add(revealer_box)

        grid = Gtk.Grid(row_spacing=9, column_spacing=18, margin=18)
        grid.attach(Gtk.CheckButton(label='Girokonto'), 0, 0, 1, 1)
        grid.attach(Gtk.CheckButton(label='Gemeinschaftkonto'), 0, 1, 1, 1)
        grid.attach(Gtk.CheckButton(label='Sparkonto'), 0, 2, 1, 1)
        grid.attach(Gtk.Separator(), 0, 3, 1, 1)
        grid.attach(Gtk.Label(label="When", xalign=0), 0, 4, 1, 1)
        grid.attach(self.select_date_stack, 0, 5, 1, 1)
        grid.attach(self.select_date_revealer, 0, 6, 1, 1)
        grid.show_all()

        self.add(grid)
Esempio n. 4
0
    def __init__(self):
        Gtk.Grid.__init__(self)

        # Create main container:
        box = Gtk.Grid(column_spacing=20, row_spacing=10, border_width=5)
        self.add(box)

        label1 = Gtk.Label("Tâche")
        box.add(label1)
        self.task_entry = Gtk.Entry()
        self.task_entry.set_text("Nouvelle tâche")
        self.task_entry.set_property("editable", True)
        box.attach(self.task_entry, 1, 0, 2, 1)
        # Create the task as subtask of selected row ?
        self.checkbox_create_subtask = Gtk.CheckButton.new_with_label(
            "Créer en tant que sous-tâche")
        # If we create a subtask, we don't need date (will use parent date) :
        #~ self.checkbox_create_subtask.connect("toggled",
        #~ self.disable_calendar)
        box.attach(self.checkbox_create_subtask, 0, 4, 3, 1)
        label2 = Gtk.Label("Échéance")
        box.attach(label2, 0, 1, 1, 1)
        self.cal_entry = Gtk.Entry()
        self.cal_entry.set_property("editable", False)
        self.cal_entry.set_sensitive(False)
        box.attach(self.cal_entry, 1, 1, 2, 1)
        # Create a calendar to select due date by double click :
        self.calendar = Gtk.Calendar()
        box.attach(self.calendar, 0, 2, 3, 1)
        self.calendar.connect("day-selected", self.get_cal_date, self.calendar)
        self.calendar.select_day(int(date.today().strftime("%d")))

        self.show_all()
Esempio n. 5
0
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("Calendar")
        self.connect("destroy", Gtk.main_quit)

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=2)
        self.add(hbox)

        self.calendar = Gtk.Calendar()
        self.calendar.connect("day-selected-double-click",
                              self.on_date_selected)
        hbox.pack_start(self.calendar, True, True, 0)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        hbox.pack_start(vbox, False, False, 0)

        checkbuttonHeading = Gtk.CheckButton(label="Show Heading")
        checkbuttonHeading.set_active(True)
        checkbuttonHeading.connect("toggled", self.on_show_heading_change)
        vbox.pack_start(checkbuttonHeading, False, False, 0)

        checkbuttonDayNames = Gtk.CheckButton(label="Show Day Names")
        checkbuttonDayNames.set_active(True)
        checkbuttonDayNames.connect("toggled", self.on_show_days_change)
        vbox.pack_start(checkbuttonDayNames, False, False, 0)

        checkbuttonPreventChange = Gtk.CheckButton(
            label="Prevent Month/Year Change")
        checkbuttonPreventChange.connect("toggled",
                                         self.on_prevent_month_change)
        vbox.pack_start(checkbuttonPreventChange, False, False, 0)

        checkbuttonShowWeeks = Gtk.CheckButton(label="Show Week Numbers")
        checkbuttonShowWeeks.connect("toggled", self.on_show_weeks_change)
        vbox.pack_start(checkbuttonShowWeeks, False, False, 0)
    def __init__(self,title,parent = None,googlecalendar = None,calendar_id = None):
        self.ok = False
        self.googlecalendar = googlecalendar
        self.calendar_id = calendar_id
        self.selecteds = {}
        #
        title = comun.APP + ' | '+_('Preferences')
        Gtk.Dialog.__init__(self,title,parent,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT,Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL))
        self.set_default_size(50, 450)
        self.set_resizable(False)
        #self.set_icon_from_file(comun.ICON)
        self.connect('destroy', self.close_application)
        #
        vbox0 = Gtk.VBox(spacing = 5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        #
        self.calendar = Gtk.Calendar()
        self.calendar.set_property('show-day-names',True)
        self.calendar.set_property('show-heading',True)
        self.calendar.set_property('show-week-numbers',True)
        self.calendar.connect('month-changed',self.on_month_changed)
        self.calendar.connect('day-selected',self.on_day_selected)
        vbox0.add(self.calendar)
        self.on_month_changed(self)

        self.init_headerbar()
        #
        self.show_all()
Esempio n. 7
0
    def __init__(self, relativetowgt, onchange):
        """ relativetowgt   - экземпляр Gtk.Widget,
                              относительно которого вываливается Popover;
            onchange        - None или метод, вызываемый при изменении
                              даты и/или нажатии кнопки 'ОК'."""

        self.date = datetime.datetime.now().date()
        self.onchange = onchange

        self.popover = Gtk.Popover.new(relativetowgt)
        self.popover.set_position(Gtk.PositionType.RIGHT)

        box = Gtk.Box.new(Gtk.Orientation.VERTICAL, WIDGET_SPACING)
        box.set_border_width(WIDGET_SPACING)
        self.popover.add(box)

        self.calendar = Gtk.Calendar()
        self.calendar.connect('day-selected-double-click', self.btnOk_clicked)
        self.calendar.connect('key-release-event', self.calendar_key_released)
        box.pack_start(self.calendar, True, True, 0)

        btnbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, WIDGET_SPACING)
        box.pack_end(btnbox, False, False, 0)

        btnCancel = Gtk.Button.new_with_label('Отмена')
        btnCancel.connect('clicked', self.btnCancel_clicked)
        btnbox.pack_start(btnCancel, False, False, 0)

        btnOk = Gtk.Button.new_with_label('OK')
        btnOk.connect('clicked', self.btnOk_clicked)
        btnbox.pack_end(btnOk, False, False, 0)
Esempio n. 8
0
    def on_button(self, button):
        win_position = self._window.get_position()
        x_win = win_position[0] + self.entry.get_allocation().x + 3
        y_win = win_position[1] + self.entry.get_allocation(
        ).y + 2 * self.entry.get_allocation().height + 3
        self.dialog = Gtk.Dialog()  #None, None, Gtk.DialogFlags.MODAL)
        self.dialog.set_modal(True)
        self.dialog.set_decorated(False)
        self.dialog.move(x_win, y_win)

        self.calendar = Gtk.Calendar()
        #
        self.calendar.select_month(self.date.month - 1, self.date.year)
        self.calendar.select_day(self.date.day)
        #
        self.calendar.show()
        self.dialog.vbox.pack_start(self.calendar, 0, 0, 0)
        self.dialog.connect('focus-out-event', self.on_focus_out)
        self.calendar.connect('day-selected', self.on_select)
        self.calendar.connect('month-changed', self.on_month_select)
        #
        self.dialog.run()
        value = self.calendar.get_date()
        value = datetime.date(value[0], value[1] + 1, value[2])
        self.set_date(value)
        self.dialog.destroy()
Esempio n. 9
0
    def get_main_widget(self):
        vbox = Gtk.VBox()
        vbox.show()
        self._vbox = vbox

        self.calendar = Gtk.Calendar()
        self.calendar.connect('day-selected-double-click',
                              self._on_calendar__day_selected_double_click)
        vbox.pack_start(self.calendar, False, False, 0)
        self.calendar.show()

        buttonbox = Gtk.HButtonBox()
        buttonbox.set_border_width(6)
        buttonbox.set_layout(Gtk.ButtonBoxStyle.SPREAD)
        vbox.pack_start(buttonbox, False, False, 0)
        buttonbox.show()

        for label, callback in [(_('_Today'), self._on_today__clicked),
                                (_('_Cancel'), self._on_cancel__clicked),
                                (_('_Select'), self._on_select__clicked)]:
            button = Gtk.Button(label, use_underline=True)
            button.connect('clicked', callback)
            buttonbox.pack_start(button, True, True, 0)
            button.show()

        return self._vbox
Esempio n. 10
0
    def __init__(self, parent, title, label, day=None, month=None, year=None):
        """Create the dialog."""

        Gtk.Dialog.__init__(self, title, parent, Gtk.DialogFlags.MODAL)
        self.add_button("Cancel", Gtk.ResponseType.CANCEL)
        self.add_button("OK", Gtk.ResponseType.OK)

        # Create the grid and widgets.
        info_box = self.get_content_area()
        info_grid = Gtk.Grid()
        info_box.add(info_grid)
        info_lbl = Gtk.Label(label)
        info_lbl.set_alignment(0, 0.5)
        info_grid.add(info_lbl)
        self.info_cal = Gtk.Calendar()
        info_grid.attach_next_to(self.info_cal, info_lbl,
                                 Gtk.PositionType.BOTTOM, 1, 1)

        # Set the default date.
        if day != None:
            self.info_cal.select_month(month, year)
            self.info_cal.select_day(day)

        # Connect 'Enter' key to the OK button.
        ok_btn = self.get_widget_for_response(response_id=Gtk.ResponseType.OK)
        ok_btn.set_can_default(True)
        ok_btn.grab_default()

        # Show the dialog.
        self.show_all()
Esempio n. 11
0
def on_pick_date(button, date_entry):
    # Parse the existing date
    date = date_entry.get_text()
    year, month, day = parseDateTag(date)

    # Prepare the date of the picker
    calendar = Gtk.Calendar()
    curyear, curmonth, curday = calendar.get_date()
    year = curyear if year is None else year
    month = curmonth if month is None else month - 1
    day = curday if day is None else day
    calendar.select_month(month, year)
    calendar.select_day(day)

    # Show the dialog
    dialog = Gtk.Dialog(
        _("Pick a date"), None,
        Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK,
         Gtk.ResponseType.ACCEPT))

    sw = Gtk.ScrolledWindow()
    sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    sw.add(calendar)

    dialog.get_content_area().pack_start(sw, True, True, 0)
    dialog.resize(300, 200)
    dialog.show_all()

    response = dialog.run()
    dialog.destroy()

    if response == Gtk.ResponseType.ACCEPT:
        year, month, day = calendar.get_date()
        date_entry.set_text("%04d.%02d.%02d" % (year, month + 1, day))
Esempio n. 12
0
    def __init__(self, log,callback, **kw):
        self.callback = callback
        self.logger = log
        Gtk.Window.__init__(self, title="Main Menu")
        self.grid = Gtk.Grid()
        self.grid.set_column_spacing(5)
        self.grid.set_row_spacing(5)
        self.grid.set_margin_end(15)
        self.grid.set_margin_start(15)
        self.grid.set_margin_top(10)

        self.add(self.grid)
        self.date_picker = Gtk.Calendar()
        self.date_picker.select_day(1)
        self.date_picker.select_month(0,2000)


        self.button_cancel = Gtk.Button(label="Annuler")
        self.button_cancel.connect('clicked', self._cancel_on_clicked)

        self.button_ok = Gtk.Button(label="OK")
        self.button_ok.connect('clicked', self._ok_on_clicked)

        self.grid.attach(self.date_picker,0,0,2,1)
        self.grid.attach(self.button_ok, 0, 1, 1, 1)
        self.grid.attach(self.button_cancel, 1, 1, 1, 1)
        self.show_all()
Esempio n. 13
0
    def on_button_clicked(self, *args):
        self.dialog = Gtk.Dialog(transient_for=self.get_toplevel(),
                                 title=_("Select a date"),
                                 flags=Gtk.DialogFlags.MODAL,
                                 buttons=(Gtk.STOCK_CANCEL,
                                          Gtk.ResponseType.CANCEL,
                                          Gtk.STOCK_OK, Gtk.ResponseType.OK))

        content = self.dialog.get_content_area()

        calendar = Gtk.Calendar()
        content.pack_start(calendar, True, True, 0)
        calendar.select_month(self.month - 1, self.year)
        calendar.select_day(self.day)

        def select_today(*args):
            date = GLib.DateTime.new_now_local().get_ymd()
            calendar.select_month(date[1] - 1, date[0])
            calendar.select_day(date[2])

        today = Gtk.Button(label=_("Today"))
        today.connect("clicked", select_today)
        content.pack_start(today, False, False, 0)

        content.show_all()

        response = self.dialog.run()

        if response == Gtk.ResponseType.OK:
            date = calendar.get_date()
            self.set_date(date[0], date[1] + 1,
                          date[2])  #calendar uses 0 based month
            self.emit("date-changed", self.year, self.month, self.day)

        self.dialog.destroy()
Esempio n. 14
0
    def __init__(self):
        Gtk.Window.__init__(self)

        # Initialize the notification system
        Notify.init(APPLICATION_NAME)
        self.notification = None

        self.set_size_request(320, 320)
        self.set_icon_name("application-x-executable")
        self.set_wmclass(APPLICATION_NAME, APPLICATION_NAME)
        self.set_title(APPLICATION_NAME)

        # Define the calendar here
        self.calendar = Gtk.Calendar()

        # Create and set a Gtk.HeaderBar as the windows' titlebar
        self.buildHeaderbar()

        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(self.box)

        # Create the calendar
        self.buildCalendar()

        # Create the actionbar
        self.buildActionbar()

        self.connect("destroy", Gtk.main_quit)
        self.show_all()
Esempio n. 15
0
    def __init__(self, prop, account):
        VCardProperty.__init__(self, prop)

        self._box = Gtk.Box(spacing=6)
        self._value_entry = ValueEntry(prop)
        self._value_entry.set_placeholder_text(_('YYYY-MM-DD'))
        self._value_entry.connect('notify::text', self._on_text_changed)

        self._calendar_button = Gtk.MenuButton()
        image = Gtk.Image.new_from_icon_name('x-office-calendar-symbolic',
                                             Gtk.IconSize.BUTTON)
        self._calendar_button.set_image(image)
        self._calendar_button.connect('clicked',
                                      self._on_calendar_button_clicked)
        self._box.add(self._value_entry)
        self._box.add(self._calendar_button)
        self._box.show_all()

        self.calendar = Gtk.Calendar(year=1980, month=5, day=15)
        self.calendar.set_visible(True)
        self.calendar.connect('day-selected', self._on_calendar_day_selected)

        popover = Gtk.Popover()
        popover.add(self.calendar)
        self._calendar_button.set_popover(popover)

        self._value_label = ValueLabel(prop, account)

        self._edit_widgets.append(self._box)
        self._read_widgets.append(self._value_label)

        self._third_column = [self._box, self._value_label]
Esempio n. 16
0
 def __init__(self, parent, last_value):
     self.calendar = Gtk.Calendar()
     super(DialogDateTime, self).__init__(parent,
                                          last_value,
                                          label="Fecha y Hora",
                                          calendar=self.calendar)
     self.hbox.set_orientation(Gtk.Orientation.HORIZONTAL)
Esempio n. 17
0
    def __init__(self, parent, title, label, day=None, month=None, year=None):
        """Create the dialog."""

        Gtk.Dialog.__init__(self, title, parent, Gtk.DialogFlags.MODAL, use_header_bar=True)
        self.add_button("Cancel", Gtk.ResponseType.CANCEL)
        self.add_button("OK", Gtk.ResponseType.OK)

        # Create the header bar.
        header = self.get_header_bar()
        header.set_title(title)
        header.set_subtitle(label)

        # Create the grid and widgets.
        info_box = self.get_content_area()
        self.info_cal = Gtk.Calendar()
        info_box.add(self.info_cal)

        # Set the default date.
        if day is not None:
            self.info_cal.select_month(month, year)
            self.info_cal.select_day(day)

        # Connect 'Enter' key to the OK button.
        ok_btn = self.get_widget_for_response(response_id=Gtk.ResponseType.OK)
        ok_btn.set_can_default(True)
        ok_btn.grab_default()

        # Show the dialog.
        self.show_all()
Esempio n. 18
0
    def __init__(self, parent, title, subtitle, day_start=(), day_end=()):
        """Create the dialog."""

        Gtk.Dialog.__init__(self, title, parent, Gtk.DialogFlags.MODAL, use_header_bar=True)
        self.add_button("Cancel", Gtk.ResponseType.CANCEL)
        self.add_button("View", DialogResponse.VIEW_INFO)

        # Create the header bar.
        header = self.get_header_bar()
        header.set_title(title)
        header.set_subtitle(subtitle)

        # Create the grid and frames.
        cal_box = self.get_content_area()
        cal_grid = Gtk.Grid()
        cal_grid.set_column_spacing(5)
        cal_grid.set_border_width(5)
        cal_box.add(cal_grid)
        cal_start_frame = Gtk.Frame()
        cal_start_frame.set_label("Starting date")
        cal_end_frame = Gtk.Frame()
        cal_end_frame.set_label("Ending date")
        cal_grid.add(cal_start_frame)
        cal_grid.attach_next_to(cal_end_frame, cal_start_frame, Gtk.PositionType.RIGHT, 1, 1)

        # Create the calendars.
        self.start_cal = Gtk.Calendar()
        self.end_cal = Gtk.Calendar()
        cal_start_frame.add(self.start_cal)
        cal_end_frame.add(self.end_cal)

        # Set the default dates.
        if len(day_start) != 0:
            self.start_cal.select_month(day_start[1], day_start[2])
            self.start_cal.select_day(day_start[0])
        if len(day_end) != 0:
            self.end_cal.select_month(day_end[1], day_end[2])
            self.end_cal.select_day(day_end[0])

        # Connect 'Enter' key to the OK button.
        ok_btn = self.get_widget_for_response(response_id=DialogResponse.VIEW_INFO)
        ok_btn.set_can_default(True)
        ok_btn.grab_default()

        # Show the dialog.
        self.show_all()
Esempio n. 19
0
 def show( s, fd, v ):
     r = Gtk.Calendar()
     fd.rw( r )
     r.connect( 'day-selected', fd.calendar_edited )
     r.connect( 'month-changed', fd.calendar_edited )
     r.connect( 'day-selected-double-click', fd.activated )
     r.select_day( dv[2] )
     r.select_month( dv[1], dv[0] )
Esempio n. 20
0
    def __init__(self):

        calendario = Gtk.Calendar()

        PopupMenuButton.__init__(self, '', calendario)

        self.set_time()
        GObject.timeout_add(1000, self.set_time, ())
Esempio n. 21
0
 def __init__(self, text, day, month, *args, **kwargs):
     super(ZCalendar, self).__init__(*args, **kwargs)
     self.text = text
     self.day = day
     self.month = month
     self.calendar = Gtk.Calendar()
     self.dialog = Gtk.Dialog()
     self.init_dialog()
Esempio n. 22
0
    def test_gtk_calendar_and_pydate_rounding(self):
        gtk_calendar = Gtk.Calendar()
        year, month, day = 2018, 4, 31  # April 31st, 2018 (does not exist)
        gtk_calendar.select_month(month - 1, year)  # GTK months start at 0
        gtk_calendar.select_day(day)

        date = gui_utilities.gtk_calendar_get_pydate(gtk_calendar)
        self.assertEquals((date.year, date.month, date.day), (year, month, 30))
Esempio n. 23
0
    def __init__(self, parent,title="Perfil do Usuário"):
        Gtk.Dialog.__init__(self, title, parent, 0,
                            (Gtk.STOCK_OK, Gtk.ResponseType.OK,
                             Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))


        hbox1 =  Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        hbox2 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

        # Calendário
        self.frame_cal= Gtk.Frame(label="Calendário:")
        self.calendario = Gtk.Calendar()
        self.frame_cal.add(self.calendario)
        hbox1.pack_start(self.frame_cal, False, False , 10)


        sep = Gtk.VSeparator()
        hbox1.pack_start(sep, False, True , 0)

        # Reunião
        self.frame_reuniao= Gtk.Frame(label="Reunião (Horários):")
        self.textview_reuniao = Gtk.TextView()
        self.textview_reuniao.set_wrap_mode(True)
        self.textview_reuniao.set_editable(False)

        scroller = Gtk.ScrolledWindow()
        scroller.set_border_width(5)
        scroller.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroller.add(self.textview_reuniao)
        scroller.set_hexpand(True)
        scroller.set_vexpand(True)
        self.frame_reuniao.add(scroller)
        hbox1.pack_start(self.frame_reuniao, False, True , 10)

        # Descrição do Paciente
        self.frame_paciente = Gtk.Frame(label="Descrição (Paciente):")
        self.textview_paciente = Gtk.TextView()
        self.textview_paciente.set_wrap_mode(True)


        scroller = Gtk.ScrolledWindow()
        scroller.set_border_width(5)
        scroller.set_policy(
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroller.add(self.textview_paciente)
        scroller.set_hexpand(True)
        scroller.set_vexpand(True)
        self.frame_paciente.add(scroller)
        hbox2.pack_start(self.frame_paciente, True , True, 10)

        self.set_default_size(500, 400)
        # self.set_resizable(False)

        self.get_content_area().add(hbox1)
        self.get_content_area().add(hbox2)

        self.show_all()
Esempio n. 24
0
    def __init__(self, window, task):
        super().__init__("Task edit", window, 0,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                          Gtk.STOCK_SAVE, Gtk.ResponseType.APPLY))

        self.task = task

        entrylabel = Gtk.Label("Title", xalign=0)
        self.entry = TextEntry(self.task.title)
        self.entry.connect(
            "modified-cancel",
            lambda w: self.emit("response", Gtk.ResponseType.CANCEL))
        self.entry.connect("modified-save", self.on_save)

        calendarlabel = Gtk.Label("Due Date", xalign=0)
        calendarbutton = Gtk.MenuButton()
        calendarbox = Gtk.Box()
        self.calendartext = Gtk.Label("No date set")
        calendarimg = Gtk.Image.new_from_icon_name("pan-down-symbolic", 1)
        calendarbox.pack_start(self.calendartext, True, True, 0)
        calendarbox.pack_end(calendarimg, False, False, 0)
        calendarbutton.add(calendarbox)
        todaybutton = Gtk.Button("Today")
        todaybutton.connect("clicked", lambda w: self.set_today())
        tomorrowbutton = Gtk.Button("Tomorrow")
        tomorrowbutton.connect("clicked", lambda w: self.set_tomorrow())
        buttonsbox = Gtk.Box()
        buttonsbox.pack_start(todaybutton, True, True, 0)
        buttonsbox.pack_start(tomorrowbutton, True, True, 0)
        buttonsbox.pack_start(calendarbutton, True, True, 0)

        datepopover = Gtk.Popover()
        self.calendar = Gtk.Calendar()
        self.calendar.connect("day-selected", self.on_date_selected)
        nodatebutton = Gtk.Button("None")
        nodatebutton.connect("clicked", self.on_date_cleared)
        datebox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 12)
        datebox.pack_start(self.calendar, True, True, 0)
        datebox.pack_end(nodatebutton, False, False, 0)
        datepopover.add(datebox)
        datepopover.show_all()
        datepopover.hide()
        calendarbutton.set_popover(datepopover)

        if hasattr(self.task, "due_date") and self.task.due_date is not None:
            d = self.task.due_date
            self.set_calendar_date(d.year, d.month, d.day)
        else:
            self.calendar.select_day(0)

        box = self.get_content_area()
        box.add(entrylabel)
        box.add(self.entry)
        box.add(calendarlabel)
        box.add(buttonsbox)
        self.show_all()
        self.connect("response", self.on_response)
Esempio n. 25
0
 def __init__(self, parent):
     Gtk.Dialog.__init__(self, "Calendario", parent, 0,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                          Gtk.STOCK_OK, Gtk.ResponseType.OK))
     self.calendar = Gtk.Calendar()
     self.set_default_size(250, 200)
     box = self.get_content_area()
     box.add(self.calendar)
     self.show_all()
Esempio n. 26
0
 def _create_popover(self, widget):
     self.popover = Gtk.Popover()
     self.popover.set_relative_to(widget)
     self.popover.set_position(Gtk.PositionType.BOTTOM)
     calendar = Gtk.Calendar()
     calendar.connect('day-selected', self.on_calendar_day_selected)
     self.popover.connect('closed', self.on_popover_closed)
     self.popover.add(calendar)
     calendar.show()
Esempio n. 27
0
 def click(self, _, evt):
     if (evt.button, evt.type) == (1, Gdk.EventType.BUTTON_PRESS):
         cal = Gtk.Calendar()
         cal.set_display_options(
             Gtk.CalendarDisplayOptions.SHOW_WEEK_NUMBERS
             | Gtk.CalendarDisplayOptions.SHOW_DAY_NAMES
             | Gtk.CalendarDisplayOptions.SHOW_HEADING)
         self.popup = icebar.util.make_popup(cal, self)
         self.popup.show_all()
Esempio n. 28
0
    def __init__(self, org_directories):
        self.window = Gtk.Window()
        self.window.set_wmclass("traycalendar", "TrayCalendar")

        self.window.set_resizable(False)
        self.window.set_decorated(False)
        self.window.set_gravity(Gdk.Gravity.STATIC)

        window_width = 300

        # Set the window geometry.
        geometry = Gdk.Geometry()
        geometry.min_width = window_width
        geometry.max_width = window_width
        geometry.base_width = window_width
        self.window.set_geometry_hints(
            None, geometry, Gdk.WindowHints.MIN_SIZE | Gdk.WindowHints.MAX_SIZE
            | Gdk.WindowHints.BASE_SIZE)

        # Create the listview for the calendar events.
        list_model = Gtk.ListStore(str)
        list_view = Gtk.TreeView(list_model)
        list_column = Gtk.TreeViewColumn("Events",
                                         Gtk.CellRendererText(),
                                         text=0)
        list_column.set_fixed_width(window_width)
        list_view.append_column(list_column)

        # Create the calendar widget.
        calendar = Gtk.Calendar()
        self.calendar_events = scan_org_for_events(org_directories)
        calendar.connect('month-changed', self.mark_calendar_events)
        calendar.connect('day-selected', self.display_event_list, list_model)
        self.mark_calendar_events(calendar)
        self.display_event_list(calendar, list_model)

        close_button = Gtk.Button("Close")
        close_button.connect('clicked', lambda event: self.window.destroy())

        vbox = Gtk.VBox()
        vbox.add(close_button)
        vbox.add(calendar)
        vbox.add(list_view)

        self.window.add(vbox)

        rootwin = self.window.get_screen().get_root_window()
        # get_pointer is deprecated but using Gdk.Device.get_position
        # is not viable here: we have no access to the pointing device.
        screen, x, y, mask = rootwin.get_pointer()
        x -= window_width
        # Show the window right beside the cursor.
        self.window.move(x, y)

        self.window.show_all()
Esempio n. 29
0
 def setUp(self):
     self.m = Model()
     self.v = v = gtkmvc3.View()
     v['window'] = w = Gtk.Window()
     v['calendar'] = c = Gtk.Calendar()
     w.add(c)
     w.show_all()
     self.c = gtkmvc3.Controller(self.m, self.v)
     refresh_gui()
     self.adapt()
     refresh_gui()
Esempio n. 30
0
 def init(self):
     from gi.repository import Gtk
     self.set_tooltip(_("Double-click a day for details"))
     self.gui.calendar = Gtk.Calendar()
     self.gui.calendar.connect('day-selected-double-click', self.double_click)
     self.gui.calendar.set_display_options(
                                 Gtk.CalendarDisplayOptions.SHOW_HEADING)
     self.gui.get_container_widget().remove(self.gui.textview)
     vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
     vbox.pack_start(self.gui.calendar, False, False, 0)
     self.gui.get_container_widget().add_with_viewport(vbox)
     vbox.show_all()