def __init__(self, contents = None, padding = 1, horizontal = False, owner = None, open_on_hover = None, spacing = 0, hide_on_leave = False, hide_on_interstitial = False, disable_toggling = False, **kwargs): Box.__init__(self, contents = contents, padding = padding, horizontal = horizontal, spacing = spacing, **kwargs) self.expand, self.expand_vert = False, False self.x_align = 0 #: in case of a sub menu - a menu item that this menu belongs to self.owner = owner #: if specified, will open submenus menu after cursor has been over the item for the specified seconds self.open_on_hover = open_on_hover #: if set, will hide the menu when mouse moves out. defaults to False self._hide_on_leave = hide_on_leave #: if set, will hide the menu when mouse moves between menuitems. defaults to False self._hide_on_interstitial = hide_on_interstitial #: if set, clicking on menu items with submenus will only show them instead of toggling #: this way the menu becomes more persistent self.disable_toggling = disable_toggling self._toggled = False self._scene_mouse_down = None self._scene_mouse_move = None self._scene_key_press = None self._echo = False self._timeout = None self.connect("on-render", self.__on_render) self.connect("on-mouse-down", self.__on_mouse_down) self.interactive = True
def __init__(self, horizontal=False, thickness=None, size=0, offset=0, **kwargs): Box.__init__(self, **kwargs) self.interactive, self.cursor = True, False self.spacing = 0 self.thickness = thickness if thickness else self.thickness #: whether the scroll bar is vertical or horizontal self.orient_horizontal = horizontal #: width of the bar in pixels self.size = size #: scroll position in range 0..1 self.offset = offset if horizontal: self.expand_vert = False self.min_height = thickness else: self.expand = False self.min_width = thickness #: slider container self.slider_zone = Widget() #: slider widget self.slider = ScrollBarSlider() self.slider_zone.add_child(self.slider) #: the scroll up button self.up = ScrollBarButton( direction="left" if self.orient_horizontal else "up") #: the scroll down button self.down = ScrollBarButton( direction="right" if self.orient_horizontal else "down") self.add_child(self.up, self.slider_zone, self.down) self._timeout = None for button in (self.up, self.down): self.connect_child(button, "on-mouse-down", self.on_scrollbutton_pressed) self.connect_child(button, "on-mouse-up", self.on_scrollbutton_released) self.connect_child(button, "on-mouse-out", self.on_scrollbutton_released) self.connect_child(self.slider, "on-drag", self.on_slider_drag) self.connect("on-click", self.on_click)
def __init__(self, horizontal = False, thickness = None, size = 0, offset = 0, **kwargs): Box.__init__(self, **kwargs) self.interactive, self.cursor = True, False self.spacing = 0 self.thickness = thickness if thickness else self.thickness #: whether the scroll bar is vertical or horizontal self.orient_horizontal = horizontal #: width of the bar in pixels self.size = size #: scroll position in range 0..1 self.offset = offset if horizontal: self.expand_vert = False self.min_height = thickness else: self.expand = False self.min_width = thickness #: slider container self.slider_zone = Widget() #: slider widget self.slider = ScrollBarSlider() self.slider_zone.add_child(self.slider) #: the scroll up button self.up = ScrollBarButton(direction="left" if self.orient_horizontal else "up") #: the scroll down button self.down = ScrollBarButton(direction="right" if self.orient_horizontal else "down") self.add_child(self.up, self.slider_zone, self.down) self._timeout = None for button in (self.up, self.down): self.connect_child(button, "on-mouse-down", self.on_scrollbutton_pressed) self.connect_child(button, "on-mouse-up", self.on_scrollbutton_released) self.connect_child(button, "on-mouse-out", self.on_scrollbutton_released) self.connect_child(self.slider, "on-drag", self.on_slider_drag) self.connect("on-click", self.on_click)
def __init__(self, contents=None, padding=1, horizontal=False, owner=None, open_on_hover=None, spacing=0, hide_on_leave=False, hide_on_interstitial=False, disable_toggling=False, **kwargs): Box.__init__(self, contents=contents, padding=padding, horizontal=horizontal, spacing=spacing, **kwargs) self.expand, self.expand_vert = False, False self.x_align = 0 #: in case of a sub menu - a menu item that this menu belongs to self.owner = owner #: if specified, will open submenus menu after cursor has been over the item for the specified seconds self.open_on_hover = open_on_hover #: if set, will hide the menu when mouse moves out. defaults to False self._hide_on_leave = hide_on_leave #: if set, will hide the menu when mouse moves between menuitems. defaults to False self._hide_on_interstitial = hide_on_interstitial #: if set, clicking on menu items with submenus will only show them instead of toggling #: this way the menu becomes more persistent self.disable_toggling = disable_toggling self._toggled = False self._scene_mouse_down = None self._scene_mouse_move = None self._scene_key_press = None self._echo = False self._timeout = None self.connect("on-render", self.__on_render) self.connect("on-mouse-down", self.__on_mouse_down) self.interactive = True
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
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