def __init__(self, title, message, affirmative_label, decline_label="Cancel", width=500, modal=False): Dialog.__init__(self, title=title, width=width, modal=modal) scrollbox = ScrollArea(Label(markup=message, padding=5, overflow=pango.WrapMode.WORD), scroll_horizontal=False, border=0, margin=2, margin_right=3, height=150) affirmative = Button(affirmative_label, id="affirmative_button") affirmative.connect("on-click", self._on_button_click) decline = Button(decline_label, id="decline_button") decline.connect("on-click", self._on_button_click) self.box.contents = VBox([ scrollbox, HBox([HBox(), decline, affirmative], expand=False, padding=10) ])
def __init__(self, labels=None, tab_position="top", tab_spacing=0, scroll_position=None, show_scroll="auto", scroll_selects_tab=True, **kwargs): Box.__init__(self, horizontal=False, spacing=0, **kwargs) #: list of tabs in the order of appearance self.tabs = [] #: list of pages in the order of appearance self.pages = [] #: container of the pages self.pages_container = self.pages_container_class(padding=1) #: container of tabs. useful if you want to adjust padding/placement self.tabs_container = Group(fill=False, spacing=tab_spacing) self.tabs_container.on_mouse_over = lambda button: False # ignore select-on-drag # viewport so that tabs don't go out of their area self._tabs_viewport = Viewport() self._tabs_viewport.get_min_size = self._tabs_viewport_get_min_size self._tabs_viewport.resize_children = self._tabs_viewport_resize_children self._tabs_viewport.add_child(self.tabs_container) #: wether scroll buttons should select next/previos tab or show the #: next/previos tab out of the view self.scroll_selects_tab = scroll_selects_tab #: container for custom content before tabs self.before_tabs = HBox(expand=False) #: container for custom content after tabs self.after_tabs = HBox(expand=False) #: button to scroll tabs back self.tabs_back = self.scroll_buttons_class("left", expand=False, visible=False, enabled=False, repeat_down_delay=150) self.tabs_back.connect("on-mouse-down", self.on_back_press) #: button to scroll tabs forward self.tabs_forward = self.scroll_buttons_class("right", expand=False, visible=False, enabled=False, repeat_down_delay=150) self.tabs_forward.connect("on-mouse-down", self.on_forward_press) #: the wrapping container that holds also the scroll buttons and everyting self.tabbox = self.tabbox_class(expand=False, expand_vert=False) self.tabbox.get_min_size = self.tabbox_get_min_size self.tabbox.get_height_for_width_size = self.tabbox_get_height_for_width_size self.tabbox.add_child(self.before_tabs, self.tabs_back, self._tabs_viewport, self.tabs_forward, self.after_tabs) #: current page self.current_page = 0 #: tab position: top, right, bottom, left and combinations: "top-right", "left-bottom", etc. self.tab_position = tab_position for label in labels or []: self.add_page(label) #: where to place the scroll buttons on tab overflow. one of "start" #: (both at the start), "end" (both at the end) or "around" (on left #: and right of the tabs) self.scroll_position = scroll_position #: determines when to show scroll buttons. True for always, False for #: never, "auto" for auto appearing and disappearing, and #: "auto_invisible" for going transparent instead of disappearing #: (the latter avoids tab toggle) self.show_scroll = show_scroll