primitivus: better popup sizing:

- showPopUp now takes absolute height and width, this makes more sense than the relative
  ones used before
- if height or width is not set, a default is used which depend of the type of the widget
  (it's smaller if the widget is a note)
- size is set to a low value for widget alerts
- size is bigger else

fix 324
This commit is contained in:
Goffi 2019-07-14 20:42:14 +02:00
commit 3b21a727dd

View file

@ -586,7 +586,7 @@ class PrimitivusApp(QuickApp, InputHistory):
"""
popup = sat_widgets.Alert(title, message)
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
self.showPopUp(popup)
self.showPopUp(popup, width=75, height=20)
return popup
def removePopUp(self, widget=None):
@ -612,10 +612,24 @@ class PrimitivusApp(QuickApp, InputHistory):
else:
self.redraw()
def showPopUp(self, pop_up_widget, perc_width=40, perc_height=40, align='center', valign='middle'):
"Show a pop-up window if possible, else put it in queue"
def showPopUp(self, pop_up_widget, width=None, height=None, align='center',
valign='middle'):
"""Show a pop-up window if possible, else put it in queue
@param pop_up_widget: pop up to show
@param width(int, None): width of the popup
None to use default
@param height(int, None): height of the popup
None to use default
@param align: same as for [urwid.Overlay]
"""
if width == None:
width = 75 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 135
if height == None:
height = 20 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 40
if not isinstance(self.loop.widget, urwid.Overlay):
display_widget = urwid.Overlay(pop_up_widget, self.main_widget, align, ('relative', perc_width), valign, ('relative', perc_height))
display_widget = urwid.Overlay(
pop_up_widget, self.main_widget, align, width, valign, height)
self.loop.widget = display_widget
self.redraw()
else: