Mercurial > libervia-backend
comparison sat_frontends/primitivus/primitivus @ 3005:595b8857538b
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Jul 2019 20:42:14 +0200 |
parents | d86cddc1cd05 |
children | 0b1c17c24bba |
comparison
equal
deleted
inserted
replaced
3004:d86cddc1cd05 | 3005:595b8857538b |
---|---|
584 @param message(unicode): body of the dialog | 584 @param message(unicode): body of the dialog |
585 @return (urwid_satext.Alert): the created Alert instance | 585 @return (urwid_satext.Alert): the created Alert instance |
586 """ | 586 """ |
587 popup = sat_widgets.Alert(title, message) | 587 popup = sat_widgets.Alert(title, message) |
588 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) | 588 popup.setCallback('ok', lambda dummy: self.removePopUp(popup)) |
589 self.showPopUp(popup) | 589 self.showPopUp(popup, width=75, height=20) |
590 return popup | 590 return popup |
591 | 591 |
592 def removePopUp(self, widget=None): | 592 def removePopUp(self, widget=None): |
593 """Remove current pop-up, and if there is other in queue, show it | 593 """Remove current pop-up, and if there is other in queue, show it |
594 | 594 |
610 #we still have popup to show, we display it | 610 #we still have popup to show, we display it |
611 self.showPopUp(next_popup) | 611 self.showPopUp(next_popup) |
612 else: | 612 else: |
613 self.redraw() | 613 self.redraw() |
614 | 614 |
615 def showPopUp(self, pop_up_widget, perc_width=40, perc_height=40, align='center', valign='middle'): | 615 def showPopUp(self, pop_up_widget, width=None, height=None, align='center', |
616 "Show a pop-up window if possible, else put it in queue" | 616 valign='middle'): |
617 """Show a pop-up window if possible, else put it in queue | |
618 | |
619 @param pop_up_widget: pop up to show | |
620 @param width(int, None): width of the popup | |
621 None to use default | |
622 @param height(int, None): height of the popup | |
623 None to use default | |
624 @param align: same as for [urwid.Overlay] | |
625 """ | |
626 if width == None: | |
627 width = 75 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 135 | |
628 if height == None: | |
629 height = 20 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 40 | |
617 if not isinstance(self.loop.widget, urwid.Overlay): | 630 if not isinstance(self.loop.widget, urwid.Overlay): |
618 display_widget = urwid.Overlay(pop_up_widget, self.main_widget, align, ('relative', perc_width), valign, ('relative', perc_height)) | 631 display_widget = urwid.Overlay( |
632 pop_up_widget, self.main_widget, align, width, valign, height) | |
619 self.loop.widget = display_widget | 633 self.loop.widget = display_widget |
620 self.redraw() | 634 self.redraw() |
621 else: | 635 else: |
622 self.notif_bar.addPopUp(pop_up_widget) | 636 self.notif_bar.addPopUp(pop_up_widget) |
623 | 637 |