Example #1
1
    def __setattr__(self, name, val):
        if name in ("width",) and hasattr(self, "main_box"):
            self.main_box.__setattr__(name, val)
        else:
            Fixed.__setattr__(self, name, val)

        if name == "contents" and hasattr(self, "box"):
            self.box.add_child(val)
Example #2
1
    def __init__(self, contents = None,
                 title = None, draggable = True,
                 width = 500,
                 modal = False,
                 **kwargs):
        Fixed.__init__(self, **kwargs)
        self.interactive, self.mouse_cursor = True, False

        #: whether the dialog is modal or not. in case of modality won't be able
        #: to click on other interface elements while dialog is being displayed
        self.modal = modal

        #: dialog content - message and such like
        self.contents = contents

        #: container for description and buttons
        # setting it interactive and filling extents so that they can't be clicked through
        self.box = VBox(contents, interactive=True, mouse_cursor = False)
        def fill_blank():
            self.box.graphics.rectangle(0, 0, self.box.width, self.box.height)
            self.box.graphics.new_path()
        self.box.do_render = fill_blank

        #: the main container box that contains title and contents
        components = []
        self.title_label = None
        if title:
            self.title_label = self.title_class(title)
            components.append(self.title_label)
        components.append(self.box)

        self.main_box = self.dialog_box_class(components, interactive=draggable, draggable=draggable, width=width, padding=0)

        self.connect_child(self.main_box, "on-drag", self.on_drag)
        self._dragged = False

        self.add_child(self.main_box)

        #: fill color for the background when the dialog is modal
        self.background_fill = "#fff"

        #: opacity of the background fill when the dialog is modal
        self.background_opacity = .5

        #: initial centered position as a tuple in lieu of scale_x, scale_y
        self.pre_dragged_absolute_position = None
Example #3
0
    def __setattr__(self, name, val):
        if name in ("width", ) and hasattr(self, "main_box"):
            self.main_box.__setattr__(name, val)
        else:
            Fixed.__setattr__(self, name, val)

        if name == "contents" and hasattr(self, "box"):
            self.box.add_child(val)
Example #4
0
    def __init__(self,
                 contents=None,
                 title=None,
                 draggable=True,
                 width=500,
                 modal=False,
                 **kwargs):
        Fixed.__init__(self, **kwargs)
        self.interactive, self.mouse_cursor = True, False

        #: whether the dialog is modal or not. in case of modality won't be able
        #: to click on other interface elements while dialog is being displayed
        self.modal = modal

        #: dialog content - message and such like
        self.contents = contents

        #: container for description and buttons
        # setting it interactive and filling extents so that they can't be clicked through
        self.box = VBox(contents, interactive=True, mouse_cursor=False)

        def fill_blank():
            self.box.graphics.rectangle(0, 0, self.box.width, self.box.height)
            self.box.graphics.new_path()

        self.box.do_render = fill_blank

        #: the main container box that contains title and contents
        components = []
        self.title_label = None
        if title:
            self.title_label = self.title_class(title)
            components.append(self.title_label)
        components.append(self.box)

        self.main_box = self.dialog_box_class(components,
                                              interactive=draggable,
                                              draggable=draggable,
                                              width=width,
                                              padding=0)

        self.connect_child(self.main_box, "on-drag", self.on_drag)
        self._dragged = False

        self.add_child(self.main_box)

        #: fill color for the background when the dialog is modal
        self.background_fill = "#fff"

        #: opacity of the background fill when the dialog is modal
        self.background_opacity = .5

        #: initial centered position as a tuple in lieu of scale_x, scale_y
        self.pre_dragged_absolute_position = None
Example #5
0
    def __setattr__(self, name, val):
        if name == 'selection':
            name = "_selection"
            self._mark_selection = True

        if self.__dict__.get(name, "hamster_graphics_no_value_really") == val:
            return

        Fixed.__setattr__(self, name, val)
        if name == 'range' and hasattr(self, "end_grip"):
            self.end_grip.visible = val == True
        elif name in ("alloc_w", "min_width") and hasattr(self, "range"):
            self._adjust_grips()
        elif name == "snap_points":
            self._rebuild_snaps()
        elif name == "_selection":
            self._adjust_grips()
Example #6
0
 def __init__(self, expand=False, **kwargs):
     Fixed.__init__(self, expand=expand, **kwargs)
     self.connect("on-render", self.__on_render)
Example #7
0
    def __init__(self,
                 values=[],
                 selection=None,
                 snap_to_ticks=True,
                 range=False,
                 grips_can_cross=True,
                 snap_points=None,
                 snap_distance=20,
                 inverse=False,
                 snap_on_release=False,
                 **kwargs):
        Fixed.__init__(self, **kwargs)

        self.scale_width = 10.5

        #: list of available items. It can be list of either strings or numbers
        #: for number ranges use the python `range <http://docs.python.org/library/functions.html#range>`_ generator.
        self.values = values

        #: Possible values: [True, "start", "end"]. When set to true will add
        #: second handler to select range.
        #: if "start" the selection range will be from start till current position
        #: if "end", the selection range will be from current position till end
        #: Defaults is False which means that a single value is selected instead
        self.range = range

        #: if set to true, the selection will be painted on the outer range
        self.inverse = inverse

        #: should the slider snap to the exact tick position
        self.snap_to_ticks = snap_to_ticks

        self._snap_sprites = []
        #: list of specially highlighted points
        self.snap_points = snap_points

        #: distance in pixels at which the snap points should start attracting
        self.snap_distance = snap_distance

        #: Normally the grip snaps to the snap points when dragged.
        #: This changes behaviour so that dragging is free, but upon release,
        #: if a snap point is in the distance, snaps to that.
        self.snap_on_release = snap_on_release

        #: works for ranges. if set to False, then it won't be possible to move
        #: start grip after end grip and vice versa
        self.grips_can_cross = grips_can_cross

        self._prev_value = None

        self.start_grip = self.slidergrip_class()
        self.end_grip = self.slidergrip_class(visible=range == True)

        for grip in (self.start_grip, self.end_grip):
            self.connect_child(grip, "on-drag", self.on_grip_drag)
            self.connect_child(grip, "on-drag-finish",
                               self.on_grip_drag_finish)

        self.add_child(self.start_grip, self.end_grip)

        self._selection = selection

        self._mark_selection = True

        self.connect("on-render", self.__on_render)
Example #8
0
 def __init__(self, expand=False, **kwargs):
     Fixed.__init__(self, expand=expand, **kwargs)
     self.connect("on-render", self.__on_render)