changeset c63256a6bb95 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=c63256a6bb95
description:
Improve size request of form widgets
issue8016
review45911002
diffstat:
CHANGELOG | 1 +
tryton/gui/window/nomodal.py | 7 +++++
tryton/gui/window/preference.py | 3 +-
tryton/gui/window/view_form/view/form_gtk/binary.py | 2 +-
tryton/gui/window/view_form/view/form_gtk/char.py | 6 ++--
tryton/gui/window/view_form/view/form_gtk/float.py | 4 +-
tryton/gui/window/view_form/view/form_gtk/integer.py | 5 +--
tryton/gui/window/view_form/view/form_gtk/many2one.py | 2 +-
tryton/gui/window/view_form/view/form_gtk/multiselection.py | 1 +
tryton/gui/window/view_form/view/form_gtk/selection.py | 2 +-
tryton/gui/window/view_form/view/form_gtk/textbox.py | 2 +-
tryton/gui/window/view_form/view/form_gtk/widget.py | 4 +-
tryton/gui/window/win_form.py | 7 +----
tryton/gui/window/win_search.py | 6 +----
tryton/gui/window/wizard.py | 16 ++++++++++++-
15 files changed, 40 insertions(+), 28 deletions(-)
diffs (244 lines):
diff -r 4a71d8ca9a27 -r c63256a6bb95 CHANGELOG
--- a/CHANGELOG Sun Feb 03 20:41:27 2019 +0100
+++ b/CHANGELOG Tue Feb 05 19:24:07 2019 +0100
@@ -1,3 +1,4 @@
+* Improve default size of widgets and dialog
* Use record and field properties of widget instead of method arguments
* Reduce offset when no search result
* Ensure URL scheme of bus (issue7792)
diff -r 4a71d8ca9a27 -r c63256a6bb95 tryton/gui/window/nomodal.py
--- a/tryton/gui/window/nomodal.py Sun Feb 03 20:41:27 2019 +0100
+++ b/tryton/gui/window/nomodal.py Tue Feb 05 19:24:07 2019 +0100
@@ -34,3 +34,10 @@
if focus and focus.is_ancestor(self.parent):
focus.grab_focus()
break
+
+ def default_size(self):
+ from tryton.gui.main import Main
+ main = Main()
+ allocation = main.window.get_allocation()
+ width, height = allocation.width, allocation.height
+ return max(width - 150, 0), max(height - 150, 0)
diff -r 4a71d8ca9a27 -r c63256a6bb95 tryton/gui/window/preference.py
--- a/tryton/gui/window/preference.py Sun Feb 03 20:41:27 2019 +0100
+++ b/tryton/gui/window/preference.py Tue Feb 05 19:24:07 2019 +0100
@@ -84,8 +84,7 @@
self.win.vbox.pack_start(self.screen.widget)
self.win.set_title(_('Preference'))
- width, height = self.parent.get_size()
- self.win.set_default_size(width, height)
+ self.win.set_default_size(*self.default_size())
self.register()
self.win.show()
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/binary.py
--- a/tryton/gui/window/view_form/view/form_gtk/binary.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/binary.py Tue Feb 05
19:24:07 2019 +0100
@@ -149,7 +149,7 @@
self.widget = gtk.HBox(spacing=0)
self.wid_size = gtk.Entry()
- self.wid_size.set_width_chars(10)
+ self.wid_size.set_width_chars(self.default_width_chars)
self.wid_size.set_alignment(1.0)
self.wid_size.props.sensitive = False
if self.filename and attrs.get('filename_visible'):
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/char.py
--- a/tryton/gui/window/view_form/view/form_gtk/char.py Sun Feb 03 20:41:27
2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py Tue Feb 05 19:24:07
2019 +0100
@@ -56,7 +56,7 @@
entry.set_property('activates_default', True)
if self.record:
field_size = self.record.expr_eval(self.attrs.get('size'))
- entry.set_width_chars(field_size or -1)
+ entry.set_width_chars(field_size or self.default_width_chars)
entry.set_max_length(field_size or 0)
return entry
@@ -121,10 +121,10 @@
size_entry = self.entry
if self.record:
field_size = self.record.expr_eval(self.attrs.get('size'))
- size_entry.set_width_chars(field_size or -1)
+ size_entry.set_width_chars(field_size or self.default_width_chars)
size_entry.set_max_length(field_size or 0)
else:
- size_entry.set_width_chars(-1)
+ size_entry.set_width_chars(self.default_width_chars)
size_entry.set_max_length(0)
value = self.get_client_value()
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/float.py
--- a/tryton/gui/window/view_form/view/form_gtk/float.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/float.py Tue Feb 05
19:24:07 2019 +0100
@@ -6,7 +6,7 @@
class FloatMixin(IntegerMixin):
- _width_chars = 18
+ default_width_chars = 18
def _prepare_entry(self, entry):
super()._prepare_entry(entry)
@@ -43,7 +43,7 @@
if digits:
width = sum(digits)
else:
- width = self._width_chars
+ width = self.default_width_chars
entry.set_width_chars(width)
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/integer.py
--- a/tryton/gui/window/view_form/view/form_gtk/integer.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/integer.py Tue Feb 05
19:24:07 2019 +0100
@@ -5,10 +5,10 @@
class IntegerMixin:
- _width_chars = 8
+ default_width_chars = 8
def _prepare_entry(self, entry):
- entry.set_width_chars(self._width_chars)
+ entry.set_width_chars(self.default_width_chars)
entry.set_max_length(0)
entry.set_alignment(1.0)
entry.connect('insert-text', self._insert_text)
@@ -30,7 +30,6 @@
def __init__(self, view, attrs):
super(Integer, self).__init__(view, attrs)
- self.entry.set_width_chars(8)
_, _, padding, pack_type = self.widget.query_child_packing(
self.entry)
self.widget.set_child_packing(self.entry, False, False,
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/many2one.py
--- a/tryton/gui/window/view_form/view/form_gtk/many2one.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py Tue Feb 05
19:24:07 2019 +0100
@@ -27,7 +27,7 @@
self.widget.set_property('sensitive', True)
self.wid_text = self.mnemonic_widget = gtk.Entry()
- self.wid_text.set_property('width-chars', 13)
+ self.wid_text.set_property('width-chars', self.default_width_chars)
self.wid_text.set_property('activates_default', True)
self.wid_text.connect('key-press-event', self.send_modified)
self.wid_text.connect('key_press_event', self.sig_key_press)
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/multiselection.py
--- a/tryton/gui/window/view_form/view/form_gtk/multiselection.py Sun Feb
03 20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/multiselection.py Tue Feb
05 19:24:07 2019 +0100
@@ -20,6 +20,7 @@
self.widget.set_shadow_type(gtk.SHADOW_ETCHED_IN)
else:
self.widget = gtk.VBox()
+ self.widget.set_size_request(100, 100)
self.widget.get_accessible().set_name(attrs.get('string', ''))
self.model = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING)
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/selection.py
--- a/tryton/gui/window/view_form/view/form_gtk/selection.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/selection.py Tue Feb 05
19:24:07 2019 +0100
@@ -19,7 +19,7 @@
child = self.mnemonic_widget = self.entry.get_child()
child.set_property('activates_default', True)
child.set_max_length(int(attrs.get('size', 0)))
- child.set_width_chars(10)
+ child.set_width_chars(self.default_width_chars)
selection_shortcuts(self.entry)
child.connect('activate', lambda *a: self._focus_out())
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/textbox.py
--- a/tryton/gui/window/view_form/view/form_gtk/textbox.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/textbox.py Tue Feb 05
19:24:07 2019 +0100
@@ -25,7 +25,7 @@
self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
self.scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
- self.scrolledwindow.set_size_request(-1, 80)
+ self.scrolledwindow.set_size_request(100, 100)
self.textview = self.mnemonic_widget = self._get_textview()
self.textview.connect('focus-out-event',
diff -r 4a71d8ca9a27 -r c63256a6bb95
tryton/gui/window/view_form/view/form_gtk/widget.py
--- a/tryton/gui/window/view_form/view/form_gtk/widget.py Sun Feb 03
20:41:27 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/widget.py Tue Feb 05
19:24:07 2019 +0100
@@ -17,6 +17,7 @@
class Widget(object):
expand = False
+ default_width_chars = 25
def __init__(self, view, attrs):
super(Widget, self).__init__()
@@ -140,8 +141,7 @@
self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.win.set_icon(TRYTON_ICON)
self.win.connect('response', self.response)
- parent_allocation = self.parent.get_allocation()
- self.win.set_default_size(-1, min(400, parent_allocation.height))
+ self.win.set_default_size(-1, self.default_size()[1])
self.accel_group = gtk.AccelGroup()
self.win.add_accel_group(self.accel_group)
diff -r 4a71d8ca9a27 -r c63256a6bb95 tryton/gui/window/win_form.py
--- a/tryton/gui/window/win_form.py Sun Feb 03 20:41:27 2019 +0100
+++ b/tryton/gui/window/win_form.py Tue Feb 05 19:24:07 2019 +0100
@@ -48,12 +48,7 @@
self.win.connect('close', self.close)
self.win.connect('response', self.response)
- allocation = self.parent.get_allocation()
- width, height, = allocation.width, allocation.height
- if self.parent != self.sensible_widget:
- width = max(width - 150, 0)
- height = max(height - 150, 0)
- self.win.set_default_size(width, height)
+ self.win.set_default_size(*self.default_size())
self.accel_group = gtk.AccelGroup()
self.win.add_accel_group(self.accel_group)
diff -r 4a71d8ca9a27 -r c63256a6bb95 tryton/gui/window/win_search.py
--- a/tryton/gui/window/win_search.py Sun Feb 03 20:41:27 2019 +0100
+++ b/tryton/gui/window/win_search.py Tue Feb 05 19:24:07 2019 +0100
@@ -41,11 +41,7 @@
self.win.set_default_response(gtk.RESPONSE_APPLY)
self.win.connect('response', self.response)
- parent_allocation = self.parent.get_allocation()
- width, height = parent_allocation.width, parent_allocation.height
- if self.parent != self.sensible_widget:
- width = max(width - 150, 0)
- self.win.set_default_size(min(600, width), min(400, height))
+ self.win.set_default_size(*self.default_size())
self.accel_group = gtk.AccelGroup()
self.win.add_accel_group(self.accel_group)
diff -r 4a71d8ca9a27 -r c63256a6bb95 tryton/gui/window/wizard.py
--- a/tryton/gui/window/wizard.py Sun Feb 03 20:41:27 2019 +0100
+++ b/tryton/gui/window/wizard.py Tue Feb 05 19:24:07 2019 +0100
@@ -401,7 +401,21 @@
return True
def show(self):
- self.dia.set_default_size(200, -1)
+ view = self.screen.current_view
+ if view.view_type == 'form':
+ expand = False
+ for name in view.get_fields():
+ widget = view[name]
+ if widget.expand:
+ expand = True
+ break
+ else:
+ expand = True
+ if expand:
+ width, height = self.default_size()
+ else:
+ width, height = -1, -1
+ self.dia.set_default_size(max(200, width), height)
self.dia.show()
def hide(self):