changeset 0a8e146b547b in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=0a8e146b547b
description:
Correctly set format and readonly on Date/Time Dict widget
issue9967
review333551002
diffstat:
tryton/gui/window/view_form/view/form_gtk/dictionary.py | 20 +++++++++++++++-
1 files changed, 18 insertions(+), 2 deletions(-)
diffs (44 lines):
diff -r c1cb1325f3f8 -r 0a8e146b547b
tryton/gui/window/view_form/view/form_gtk/dictionary.py
--- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py Fri Dec 25
13:17:11 2020 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py Mon Jan 11
00:08:50 2021 +0100
@@ -304,8 +304,10 @@
record = self.parent_widget.record
field = self.parent_widget.field
if record and field:
- format_ = field.time_format(record)
- widget.props.format = format_
+ date_format = field.date_format(record)
+ time_format = field.time_format(record)
+ widget.props.date_format = date_format
+ widget.props.time_format = time_format
widget.connect('key_press_event', self.parent_widget.send_modified)
widget.connect('focus-out-event', lambda w, e:
self.parent_widget._focus_out())
@@ -317,6 +319,15 @@
def set_value(self, value):
self.widget.props.value = timezoned_date(value)
+ def set_readonly(self, readonly):
+ for child in self.widget.get_children():
+ if isinstance(child, Gtk.Entry):
+ child.set_editable(not readonly)
+ child.set_icon_sensitive(
+ Gtk.EntryIconPosition.PRIMARY, not readonly)
+ elif isinstance(child, Gtk.ComboBox):
+ child.set_sensitive(not readonly)
+
class DictDateEntry(DictEntry):
expand = False
@@ -340,6 +351,11 @@
def set_value(self, value):
self.widget.props.value = value
+ def set_readonly(self, readonly):
+ super().set_readonly(readonly)
+ self.widget.set_icon_sensitive(
+ Gtk.EntryIconPosition.PRIMARY, not readonly)
+
DICT_ENTRIES = {
'char': DictEntry,