示例#1
0
class DateTime(Date):
    def __init__(self, view, attrs):
        Widget.__init__(self, view, attrs)

        self.widget = gtk.HBox()
        self.entry = DateTimeEntry()
        for child in self.entry.get_children():
            add_operators(child)
            if isinstance(child, gtk.ComboBoxEntry):
                child.set_focus_chain([child.get_child()])
                child = child.get_child()
            child.set_property('activates_default', True)
            child.connect('key_press_event', self.sig_key_press)
            child.connect('activate', self.sig_activate)
            child.connect('changed', lambda _: self.send_modified())
            child.connect('focus-out-event', lambda x, y: self._focus_out())
        self.widget.pack_start(self.entry, expand=False, fill=False)

    def _set_editable(self, value):
        for child in self.entry.get_children():
            if isinstance(child, gtk.Entry):
                child.set_editable(value)
                child.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, value)
            elif isinstance(child, gtk.ComboBoxEntry):
                child.set_sensitive(value)

    def set_format(self, record, field):
        if field and record:
            date_format = field.date_format(record)
            time_format = field.time_format(record)
        else:
            date_format = '%x'
            time_format = '%X'
        self.entry.props.date_format = date_format
        self.entry.props.time_format = time_format
示例#2
0
 def create_widget(self):
     widget = DateTime()
     record = self.parent_widget.record
     field = self.parent_widget.field
     if record and field:
         format_ = field.time_format(record)
         widget.props.format = format_
     widget.connect('key_press_event', self.parent_widget.send_modified)
     widget.connect('focus-out-event', lambda w, e:
         self.parent_widget._focus_out())
     return widget
示例#3
0
 def create_widget(self):
     widget = add_operators(DateTime())
     record = self.parent_widget.record
     field = self.parent_widget.field
     if record and field:
         format_ = field.time_format(record)
         widget.props.format = format_
     widget.connect('key_press_event', self.parent_widget.send_modified)
     widget.connect('focus-out-event', lambda w, e:
         self.parent_widget._focus_out())
     return widget
示例#4
0
    def __init__(self, view, attrs):
        Widget.__init__(self, view, attrs)

        self.widget = gtk.HBox()
        self.entry = DateTimeEntry()
        for child in self.entry.get_children():
            add_operators(child)
            if isinstance(child, gtk.ComboBoxEntry):
                child.set_focus_chain([child.get_child()])
                child = child.get_child()
            child.set_property('activates_default', True)
            child.connect('key_press_event', self.sig_key_press)
            child.connect('activate', self.sig_activate)
            child.connect('changed', lambda _: self.send_modified())
            child.connect('focus-out-event', lambda x, y: self._focus_out())
        self.widget.pack_start(self.entry, expand=False, fill=False)