def date_range_entry_dialog(title,prompt,default_from=None,default_to=None,buttons=('_OK','_Cancel'),default=0): button_list=[] i=0 for x in buttons: button_list.append(x) button_list.append(i) i+=1 dialog = gtk.Dialog(title,None,gtk.DIALOG_MODAL,tuple(button_list)) dialog.vbox.set_property('border-width',15) ##TODO: This doesn't work, find an alternative way to create spacing prompt_label=gtk.Label() prompt_label.set_label(prompt) prompt_label.set_line_wrap(True) prompt_label.set_width_chars(40) def check_cb(check,cal): cal.set_sensitive(check.get_active()) date_box=gtk.HBox() cal_from=gtk.Calendar() cal_to=gtk.Calendar() if default_from: cal_from.select_month(default_from.month-1,default_from.year) cal_from.select_day(default_from.day) if default_to: cal_to.select_month(default_to.month-1,default_to.year) cal_to.select_day(default_to.day) from_box=gtk.VBox() from_check=gtk.CheckButton('From') from_check.set_active(True) from_box.pack_start(from_check) from_box.pack_start(cal_from) to_box=gtk.VBox() to_check=gtk.CheckButton('To') to_check.set_active(True) to_box.pack_start(to_check) to_box.pack_start(cal_to) date_box.pack_start(from_box) date_box.pack_start(to_box) from_check.connect('toggled', check_cb,cal_from) to_check.connect('toggled', check_cb,cal_to) dialog.vbox.pack_start(prompt_label) dialog.vbox.pack_start(date_box) dialog.vbox.show_all() dialog.set_default_response(default) response=dialog.run() if from_check.get_active(): date_from=cal_from.get_date() date_from=date(date_from[0],date_from[1]+1,date_from[2]) else: date_from=None if to_check.get_active(): date_to=cal_to.get_date() date_to=date(date_to[0],date_to[1]+1,date_to[2]) else: date_to=None dialog.destroy() return response,date_from,date_to
def __init__(self, parent_window): super(HistoryView, self).__init__() self.parent_window = parent_window self.calendar = gtk.Calendar() self.tomato_view = self._create_tomato_view() self.tomato_model = self.tomato_view.get_model() self.stat_model = WeeklyStatisticsModel() self.stat_graph = WeeklyBarChart(self.stat_model) tomato_wnd = gtk.ScrolledWindow() tomato_wnd.add(self.tomato_view) tomato_wnd.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) tomato_view = gtk.Viewport() tomato_view.add(tomato_wnd) top_hbox = gtk.HBox(False, 0) top_hbox.pack_start(self.calendar, False, False, padding=5) top_hbox.pack_start(tomato_view, True, True, padding=5) top_vbox = gtk.VBox(False, 0) top_vbox.pack_start(top_hbox, True, True, padding=5) self.pack1(top_vbox, shrink=False) self.pack2(self.stat_graph, shrink=False) self._on_day_changed(self.calendar) self.calendar.connect('day-selected', self._on_day_changed)
def __init__(self, X, Y, width, height, cntrl): self.controller = gtk.Calendar() cntrl.fixed.put(self.controller, X, Y) print "fu" self.controller.connect("day_selected", self.on_day_selected) #cntrl.fix.put(self.label, 40, 230) self.controller.show()
def __init__(self): self.__date = None self.__format = '%x' gtk.Entry.__init__(self) self.set_width_chars(12) self.connect('focus-out-event', self.focus_out) self.connect('activate', self.activate) # Calendar Popup self.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'tryton-find') self.set_icon_tooltip_text(gtk.ENTRY_ICON_SECONDARY, _('Open the calendar')) self.connect('icon-press', self.icon_press) self.__cal_popup = gtk.Window(gtk.WINDOW_POPUP) self.__cal_popup.set_events(self.__cal_popup.get_events() | gtk.gdk.KEY_PRESS_MASK) self.__cal_popup.set_resizable(False) self.__cal_popup.connect('delete-event', self.cal_popup_closed) self.__cal_popup.connect('key-press-event', self.cal_popup_key_pressed) self.__cal_popup.connect('button-press-event', self.cal_popup_button_pressed) self.__calendar = gtk.Calendar() cal_options = gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_HEADING self.__calendar.set_display_options(cal_options) self.__cal_popup.add(self.__calendar) self.__calendar.connect('day-selected', self.cal_popup_changed) self.__calendar.connect('day-selected-double-click', self.cal_popup_double_click) self.__calendar.show()
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 __init__(self, parent): """Constructor.""" self.cal=gtk.Calendar() self.cal.set_display_options(gtk.CALENDAR_SHOW_HEADING) self.cal.set_display_options(gtk.CALENDAR_SHOW_DAY_NAMES) self.cal.set_display_options(gtk.CALENDAR_SHOW_WEEK_NUMBERS) self.show()
def __init__(self): """create a CheckFilterCombo """ gtk.HBox.__init__(self, False, 10) self.__combo_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) self.combo = gtk.ComboBox(self.__combo_store) cell = gtk.CellRendererText() self.combo.pack_start(cell, False) self.combo.add_attribute(cell, 'text', 0) self.combo.show() self.combo.connect("changed", self.__changed) self.__combo_store.append([_("before"), self.before]) self.__combo_store.append([_("on or before"), self.on_before]) self.__combo_store.append([_("on"), self.on_date]) self.__combo_store.append([_("on or after"), self.on_after]) self.__combo_store.append([_("after"), self.after]) self.calendar = gtk.Calendar() self.calendar.show() self.calendar.connect("day-selected", self.__changed) vb = gtk.VBox(False, 5) vb.show() vb.pack_start(self.combo, True, False) self.pack_start(vb, False, False) self.pack_start(self.calendar, False, False)
def __init__(self, date=None): gtk.Entry.__init__(self) self.set_width_chars(len( dt.datetime.now().strftime("%x"))) # size to default format length self.date = date if date: self.set_date(date) self.news = False self.prev_cal_day = None #workaround self.popup = gtk.Window(type=gtk.WINDOW_POPUP) calendar_box = gtk.HBox() self.date_calendar = gtk.Calendar() self.date_calendar.mark_day(dt.datetime.today().day) self.date_calendar.connect("day-selected", self._on_day_selected) self.date_calendar.connect("day-selected-double-click", self.__on_day_selected_double_click) self.date_calendar.connect("button-press-event", self._on_cal_button_press_event) calendar_box.add(self.date_calendar) self.popup.add(calendar_box) self.connect("button-press-event", self._on_button_press_event) self.connect("key-press-event", self._on_key_press_event) self.connect("focus-in-event", self._on_focus_in_event) self.connect("focus-out-event", self._on_focus_out_event) self._parent_click_watcher = None # bit lame but works self.connect("changed", self._on_text_changed) self.show() self.connect("destroy", self.on_destroy)
def __init__(self, parent_window=None, date=None): Dialog.__init__( self, unicode("Calendario", "latin-1").encode("utf-8"), parent_window, 0, ) self.set_position(gtk.WIN_POS_MOUSE) hbox = gtk.HBox(False, 8) hbox.set_border_width(8) self.vbox.pack_start(hbox, 1, False, 0) self.date = date calendar = gtk.Calendar() calendar.connect('day_selected_double_click', self.on_calendar_double_click) if date <> None and date <> "": calendar.select_day(int(date[0:2])) calendar.select_month(int(date[3:5]) - 1, int(date[6:10])) hbox.pack_start(calendar, True, True, 0) self.set_default_response(gtk.RESPONSE_CANCEL) self.show_all() calendar.grab_focus() response = self.run() if response == gtk.RESPONSE_OK: self.destroy() self.date = calendar.get_date() self.date = str(zfill(self.date[2], 2)) + "/" + str( zfill(self.date[1] + 1, 2)) + "/" + str(zfill(self.date[0], 4)) else: self.destroy()
def __init__(self): gtk.HBox.__init__(self, False, 0) self.calendar = gtk.Calendar() self.entry = gtk.Entry() self.button = gtk.Button(label='^') self.cwindow = gtk.Window(gtk.WINDOW_TOPLEVEL) self.display = False self.currentDate = datetime.date.today() self.cwindow.set_position(gtk.WIN_POS_MOUSE) self.cwindow.set_decorated(False) self.cwindow.set_modal(True) self.timepicker = TimePicker() self.btn_done = gtk.Button("Hecho") box2 = gtk.HBox() box2.pack_start(self.timepicker, False) box2.pack_start(self.btn_done) box = gtk.VBox() box.pack_start(self.calendar, False) box.pack_start(box2, False) self.cwindow.add(box) self.entry.set_width_chars(10) self.pack_start(self.entry, True, True, 0) self.pack_start(self.button, False, False, 0) self.__connect_signals() self.update_entry()
def cal_open(self, widget, event, dest, parent=None): win = gtk.Dialog(_('OpenERP - Date selection'), parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) cal = gtk.Calendar() cal.display_options(gtk.CALENDAR_SHOW_HEADING | gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_WEEK_NUMBERS) cal.connect('day-selected-double-click', lambda *x: win.response(gtk.RESPONSE_OK)) win.vbox.pack_start(cal, expand=True, fill=True) win.show_all() try: val = self._date_get(dest.get_text()) if val: cal.select_month(int(val[5:7]) - 1, int(val[0:4])) cal.select_day(int(val[8:10])) except ValueError: pass response = win.run() if response == gtk.RESPONSE_OK: year, month, day = cal.get_date() dt = DT.date(year, month + 1, day) dest.set_text(dt.strftime(LDFMT)) win.destroy()
def __init__(self): gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_UTILITY) self.set_wmclass("gimmie", "Gimmie") self.set_decorated(False) self.set_resizable(False) self.set_keep_above(True) self.stick() self.set_title(_("Calendar")) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) frame.show() self.add(frame) vbox = gtk.VBox(False, 6) vbox.set_border_width(6) vbox.show() frame.add(vbox) self.cal = gtk.Calendar() self.cal.set_display_options(self.cal.get_display_options() | gtk.CALENDAR_SHOW_WEEK_NUMBERS) self.cal.show() vbox.pack_start(self.cal, True, False, 0)
def cal_open(self, widget, event, model=None, window=None): if self.readonly: common.message(_('This widget is readonly !')) return True win = gtk.Dialog(_('OpenERP - Date selection'), window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) hbox = gtk.HBox() hbox.pack_start(gtk.Label(_('Hour:')), expand=False, fill=False) hour = gtk.SpinButton(gtk.Adjustment(0, 0, 23, 1, 5), 1, 0) hbox.pack_start(hour, expand=True, fill=True) hbox.pack_start(gtk.Label(_('Minute:')), expand=False, fill=False) minute = gtk.SpinButton(gtk.Adjustment(0, 0, 59, 1, 10), 1, 0) hbox.pack_start(minute, expand=True, fill=True) win.vbox.pack_start(hbox, expand=False, fill=True) cal = gtk.Calendar() cal.display_options(gtk.CALENDAR_SHOW_HEADING | gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_WEEK_NUMBERS) cal.connect('day-selected-double-click', lambda *x: win.response(gtk.RESPONSE_OK)) win.vbox.pack_start(cal, expand=True, fill=True) win.show_all() try: val = self.get_value(model, timezone=False) if val: hour.set_value(int(val[11:13])) minute.set_value(int(val[-5:-3])) cal.select_month(int(val[5:7]) - 1, int(val[0:4])) cal.select_day(int(val[8:10])) else: hour.set_value(time.localtime()[3]) minute.set_value(time.localtime()[4]) except ValueError: pass response = win.run() if response == gtk.RESPONSE_OK: hr = int(hour.get_value()) mi = int(minute.get_value()) dt = cal.get_date() month = int(dt[1]) + 1 day = int(dt[2]) date = DT(dt[0], month, day, hr, mi) try: value = date.strftime(DHM_FORMAT) except ValueError: common.message( _('Invalid datetime value! Year must be greater than 1899 !' )) else: self.show(value, timezone=False) self._focus_out() win.destroy()
def __init__(self, text_info=None, day=None, month=None, *args, **kwargs): super(PZCalendar, self).__init__(*args, **kwargs) self.text_info = text_info self.day = day self.month = month self.calendar = gtk.Calendar() self.dialog = gtk.Dialog() self.init_dialog()
def init(self): 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) if self.uistate.screen_width() <= 1024: self.gui.calendar.set_display_options(gtk.CALENDAR_SHOW_HEADING) self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().add_with_viewport(self.gui.calendar) self.gui.calendar.show()
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Calendar") self.window.connect("delete_event", self.delete_event) self.window.set_border_width(12) calendar = gtk.Calendar() self.window.add(calendar) calendar.show_all() self.window.show()
def __init__(self, associated_widget, callback=None): super(CalendarPopup, self).__init__(None) self.calendar = gtk.Calendar() self._associated_widget = associated_widget self._callback = callback self.vbox.pack_start(self.calendar) self.set_decorated(False) self.set_position(gtk.WIN_POS_NONE) self.set_property('skip-taskbar-hint', True) self.connect('focus-out-event', lambda *discard: self.hide(False)) self.calendar.connect('day-selected-double-click', lambda *discard: self.hide(True))
def __init__(self, the_time=None): gtk.HBox.__init__(self) # preset values self.__flags = None # the date entry self.__date_entry = gtk.Entry() self.__date_entry.set_size_request(80, -1) self.pack_start(self.__date_entry, True, True, 0) self.__date_entry.show() self.__date_entry.connect("activate", self.on_date_entry_activate) # the date button self.__date_button = gtk.Button() self.__date_button.connect('clicked', self.date_button_clicked) self.pack_start(self.__date_button, False, False, 0) # the down arrow arrow = gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_OUT) self.__date_button.add(arrow) arrow.show() # finally show the button self.__date_button.show() # the calendar popup self.__cal_popup = gtk.Window(gtk.WINDOW_POPUP) self.__cal_popup.set_events(self.__cal_popup.get_events() | gdk.KEY_PRESS_MASK) self.__cal_popup.connect('delete_event', self.delete_popup) self.__cal_popup.connect('key_press_event', self.key_press_popup) self.__cal_popup.connect('button_press_event', self.button_press_popup) self.__cal_popup.set_resizable(False) # Todo: Needed? frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) self.__cal_popup.add(frame) frame.show() # the calendar self.__calendar = gtk.Calendar() self.__calendar.display_options(gtk.CALENDAR_SHOW_DAY_NAMES | gtk.CALENDAR_SHOW_HEADING) self.__calendar.connect('day-selected', self.day_selected) self.__calendar.connect('day-selected-double-click', self.day_selected_double_click) frame.add(self.__calendar) self.__calendar.show() # set provided date and time self.set_time(the_time)
def __init__(self, my_widget): self.win = gtk.Window(gtk.WINDOW_POPUP) self.my_widget = my_widget self.win.set_resizable(False) self.is_visible = False self.vbox = gtk.VBox() self.vbox.show() self.win.add(self.vbox) self.calendar = gtk.Calendar() self.calendar.thaw() self.calendar.show() self.gdk_parent_win = None self.vbox.pack_start(self.calendar, False, False, 0)
def main(): calendar = gtk.Calendar() entry = gtk.Entry() text = gtk.TextView() text.set_editable(False) text.get_buffer().set_text("""You chose to: * Frobnicate the foo. * Reverse the glop. * Enable future auto-frobnication.""") assistant = gtk.Assistant() assistant.append_page(calendar) assistant.append_page(entry) assistant.append_page(text) # It's important to set the page type so that the widget knows # which buttons to display. In this case, the Intro page won't # show a "Back" button. Note that the "Forward" button isn't # enabled until the page is marked as complete -- see the # "day_selected" signal handler below. When the user selects a day # in the calendar widget, the "Forward" button is enabled. assistant.set_page_type(calendar, gtk.ASSISTANT_PAGE_INTRO) assistant.set_page_title(calendar, "This is an assistant.") # The Content page type is for "ordinary" pages. Note that this # page is marked as complete here, so the user can press Forward # without doing any real action on the page. assistant.set_page_type(entry, gtk.ASSISTANT_PAGE_CONTENT) assistant.set_page_title(entry, "Enter some information on this page.") assistant.set_page_complete(entry, True) # The Summary page type is for the final page of the Assistant. assistant.set_page_type(text, gtk.ASSISTANT_PAGE_SUMMARY) assistant.set_page_title(text, "Congratulations, you're done.") # Handle the cancel and close buttons. assistant.connect("cancel", done) assistant.connect("close", done) # Get a callback when a calendar day is selected -- we'll allow # the user to move "Forward" when this is done. calendar.connect("day_selected", calendar_day_selected, assistant) calendar.show() entry.show() text.show() assistant.show() gtk.main()
def cal_open(self, widget, event, dest, parent=None): win = gtk.Dialog(_('OpenERP - Date selection'), parent, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) hbox = gtk.HBox() hbox.pack_start(gtk.Label(_('Hour:')), expand=False, fill=False) hour = gtk.SpinButton(gtk.Adjustment(0, 0, 23, 1, 5), 1, 0) hbox.pack_start(hour, expand=True, fill=True) hbox.pack_start(gtk.Label(_('Minute:')), expand=False, fill=False) minute = gtk.SpinButton(gtk.Adjustment(0, 0, 59, 1, 10), 1, 0) hbox.pack_start(minute, expand=True, fill=True) win.vbox.pack_start(hbox, expand=False, fill=True) cal = gtk.Calendar() cal.display_options(gtk.CALENDAR_SHOW_HEADING|gtk.CALENDAR_SHOW_DAY_NAMES|gtk.CALENDAR_SHOW_WEEK_NUMBERS) cal.connect('day-selected-double-click', lambda *x: win.response(gtk.RESPONSE_OK)) win.vbox.pack_start(cal, expand=True, fill=True) win.show_all() try: val = self.get_value(dest, timezone=False) if val: val = DT.datetime.strptime(val[:len(DHM_FORMAT) + 2], DHM_FORMAT) hour.set_value(val.hour) minute.set_value(val.minute) cal.select_month(val.month-1, val.year) cal.select_day(val.day) elif dest == self.entry1: hour.set_value(0) minute.set_value(0) elif dest == self.entry2: hour.set_value(23) minute.set_value(59) except ValueError: pass response = win.run() if response == gtk.RESPONSE_OK: hr = int(hour.get_value()) mi = int(minute.get_value()) year, month, day = cal.get_date() date = DT.datetime(year, month+1, day, hr, mi) try: value = date.strftime(DHM_FORMAT) except ValueError: common.message(_('Invalid datetime value! Year must be greater than 1899 !')) else: self.set_datetime(value, dest, timezone=False) win.destroy()
def __init__(self, **kw): if self._calendar_img is None: f = self.getConfigAsString('calendar_image') self.__class__._calendar_img = gtk.gdk.pixbuf_new_from_file(f) if not hasattr(self, '_entry'): entry = self._entry = gtk.Entry() entry.set_width_chars(13) if not hasattr(self, '_label'): self._label = gtk.Label('') if not hasattr(self, '_obj'): self._obj = gtk.EventBox() if not hasattr(self, '_vbox'): button = gtk.Button() i = gtk.Image() i.set_from_pixbuf(self._calendar_img) button.add(i) button.connect('clicked', self._popup_dialog) vbox = gtk.VBox() vbox.pack_start(entry, False, True) vbox.pack_start(self._label, False, True) hbox = gtk.HBox() hbox.pack_start(vbox, True, True) hbox.pack_start(button, False, False) self._vbox = gtk.VBox() self._vbox.pack_start(hbox, False, False) self._obj.add(self._vbox) if not hasattr(self, '_ctrl'): self._ctrl = False if not hasattr(self.__class__, '_dia'): dia = gtk.Dialog(_("Select a date"), None, 0, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) dia.set_position(gtk.WIN_POS_MOUSE) dia.set_default_response(gtk.RESPONSE_OK) cal = gtk.Calendar() cal.connect('day_selected_double_click', lambda *a: dia.response(gtk.RESPONSE_OK)) dia.vbox.add(cal) self.__class__._dia = dia self.__class__._cal = cal # super(Gtk2DateEntry, self).__init__(**kw) self._processArgs(Gtk2DateEntry, kw) self._entry.connect('key_press_event', self._change_value) self._entry.connect('key_release_event', self._release)
def __init__(self, initial_value=0, parent_window=None): gtk.Dialog.__init__(self) try: if not gobject.signal_lookup("on-change-calendar-window", self): gobject.signal_new("on-change-calendar-window", self, gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (float, )) except: pass self.set_modal(True) if parent_window: parent_window.set_transient_for(self) hbox = gtk.HBox() self.calendar = gtk.Calendar() buttonCurrent = gtk.Button() buttonDelete = gtk.Button() buttonCurrent.add(gtk.Label("Current")) buttonDelete.add(gtk.Label("Delete")) hbox.pack_start(buttonCurrent) hbox.pack_start(buttonDelete) self.vbox.pack_start(self.calendar, False, False) self.vbox.pack_start(hbox) self.set_decorated(False) self.set_position(gtk.WIN_POS_NONE) self.set_property("skip-taskbar-hint", True) buttonCurrent.connect("pressed", self.do_select_current) buttonDelete.connect("pressed", self.do_select_none) self.calendar.connect("day-selected-double-click", self.do_select_day) self.connect("focus-out-event", self.do_hide_calendar) self.value = initial_value # if there are a value, select the day if self.value: year, month, day, hour, minute, second, dow, doy, isdst = time.localtime( self.value) self.calendar.select_month(month - 1, year) self.calendar.select_day(day) self.show_all() self.action_area.hide()
def __init__(self): gtk.HBox.__init__(self) self.calendar = gtk.Calendar() self.calendar.set_properties(show_day_names=False) self.calendar.connect("day-selected", self.on_calendar__changed) self.button = gtk.CheckButton("Today") self.button.connect("toggled", self.on_button__toggle) # TODO center, probably by using Alignment. self.pack_start(self.button) self.pack_start(self.calendar) self.show_all()
def __init__(self, entry): self.entry = entry self.window = gtk.Window(gtk.WINDOW_POPUP) self.window.connect('destroy', self.destroy) self.window.set_position(gtk.WIN_POS_MOUSE) self.window.set_modal(True) self.window.set_resizable(False) self.calendar = gtk.Calendar() self.calendar.connect('day_selected_double_click', self.selectDay) self.window.add(self.calendar) self.calendar.show() self.window.show()
def __init__(self, date): """ Initialize the DatePicker. date is a python datetime.date object. """ gtk.HBox.__init__(self) image = gtk.image_new_from_icon_name('x-office-calendar', gtk.ICON_SIZE_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=managerlib.LocalTz()) self._date_entry = gtk.Entry() self._date_entry.set_width_chars(14) # we could use managerlib.formatDate here, but since we are parsing # this, leave it alone self.date_picker_locale = managerlib.find_date_picker_locale() # unset locale if we can't parse it here locale.setlocale(locale.LC_TIME, self.date_picker_locale) self._date_entry.set_text(self._date.strftime("%x")) # return to original locale locale.setlocale(locale.LC_TIME, '') atk_entry = self._date_entry.get_accessible() atk_entry.set_name('date-entry') self._cal_button = 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) self.pack_start(self._cal_button) 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 = gtk.Calendar() atk_entry = self._calendar.get_accessible() atk_entry.set_name("Calendar") self.show() self._date_entry.show() self._cal_button.show()
def __init__(self, entry): gtk.Window.__init__(self, gtk.WINDOW_POPUP) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_modal(True) self.set_resizable(False) self.set_destroy_with_parent(True) toplevel = entry.get_toplevel() self.set_transient_for(toplevel) buttonapply = gtk.Button() img = gtk.image_new_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON) buttonapply.set_image(img) buttonapply.connect("clicked", self.on_buttonapply_clicked) buttoncancel = gtk.Button() img = gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON) buttoncancel.set_image(img) buttoncancel.connect("clicked", self.on_buttoncancel_clicked) vbox = gtk.VBox(False, 8) vbox.pack_start(buttonapply, False, False, 0) vbox.pack_start(buttoncancel, False, False, 0) calendar = gtk.Calendar() calendar.connect("day-selected", self.on_day_selected) calendar.connect("day-selected-double-click", self.on_day_clicked) hbox = gtk.HBox() hbox.pack_start(vbox, False, False, 0) hbox.pack_start(calendar, False, False, 0) self._calendar = calendar self._entry = entry self._saved_date = entry.get_text(validate=False) if self._saved_date: try: year, month, day = map(int, self._saved_date.split("-")) calendar.select_month(month-1, year) calendar.select_day(day) # Check for a valid date, mostly incorrect year datetime.date(year, month, day).strftime(const.DATE_FORMAT) except ValueError: # Raised by both splitting and setting an incorrect date date = datetime.date.today().strftime(const.DATE_FORMAT) self._saved_date = date self._entry.set_text(date) vp = gtk.Viewport() vp.add(hbox) self.add(vp) self._set_position() self.show_all()
def __init__(self, dateentry): gtk.Window.__init__(self, gtk.WINDOW_POPUP) self.add_events(gdk.BUTTON_PRESS_MASK) self.connect('key-press-event', self._on__key_press_event) self.connect('button-press-event', self._on__button_press_event) self._dateentry = dateentry frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.add(frame) frame.show() vbox = gtk.VBox() vbox.set_border_width(6) frame.add(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) self.calendar.show() buttonbox = gtk.HButtonBox() buttonbox.set_border_width(6) buttonbox.set_layout(gtk.BUTTONBOX_SPREAD) vbox.pack_start(buttonbox, False, False) 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) button.show() self.set_resizable(False) self.set_screen(dateentry.get_screen()) self.realize() req = self._vbox.size_request() try: height = req[1] except TypeError: height = req.height self.height = height
def __calendar_dialog(self, widget, entry): d = gtk.Window(gtk.WINDOW_TOPLEVEL) d.set_title(_('Pick a date')) vb = gtk.VBox() cal = gtk.Calendar() vb.pack_start(cal, expand=False, padding=0) btn = gtk.Button(_('Done')) btn.connect('clicked', self.__get_date, cal, entry, d) vb.pack_start(btn, expand=False, padding=4) d.add(vb) d.set_position(gtk.WIN_POS_MOUSE) d.show_all()
def __init__(self, parent, blank_date_enabled): actions = [ gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK ] if blank_date_enabled: actions.insert(0, gtk.RESPONSE_REJECT) actions.insert(0, "Nenhuma") gtk.Dialog.__init__(self, "Selecionar data", parent.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, tuple(actions)) content_area = self.get_content_area() self.calendar = gtk.Calendar() content_area.pack_start(self.calendar) self.calendar.show()