# HG changeset patch # User Goffi # Date 1563129734 -7200 # Node ID 595b8857538b2ee4a83a2a927207db9dd9abd40f # Parent d86cddc1cd055de38ffcb5423e2f0ea73a2b853b 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 diff -r d86cddc1cd05 -r 595b8857538b sat_frontends/primitivus/primitivus --- a/sat_frontends/primitivus/primitivus Sun Jul 14 20:38:34 2019 +0200 +++ b/sat_frontends/primitivus/primitivus Sun Jul 14 20:42:14 2019 +0200 @@ -586,7 +586,7 @@ """ 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 @@ 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: