From 3b21a727dddd98500618095aafc5dea570df2b1e Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 14 Jul 2019 20:42:14 +0200 Subject: [PATCH] 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 --- sat_frontends/primitivus/primitivus | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sat_frontends/primitivus/primitivus b/sat_frontends/primitivus/primitivus index c2dbf117..0d230f2c 100755 --- a/sat_frontends/primitivus/primitivus +++ b/sat_frontends/primitivus/primitivus @@ -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: