def __init__(self, value="", hint="", action=None, x=0, y=0, width=125, padding=5, id=None, **kwargs): """ A single-line text input field. The string value can be retrieved with Field.value. """ Editable.__init__(self, value, x=x, y=y, width=width, padding=(padding,0), wrap=False, id=id, **kwargs) img, w = Image(theme["field"]), 10 self.src = { "face" : crop(img, w, 0, 1, img.height), "cap1" : crop(img, 0, 0, w, img.height), "cap2" : crop(img, img.width-w, 0, w, img.height), } if action: # Override the Button.on_action() method from the given function. self.set_method(action, name="on_action") self.default = value self.append(Label(hint, fill=Color(0, 0.4))) self._pack()
def __init__(self, value="", hint="", action=None, x=0, y=0, width=125, padding=5, id=None, **kwargs): """ A single-line text input field. The string value can be retrieved with Field.value. """ Editable.__init__(self, value, x=x, y=y, width=width, padding=(padding, 0), wrap=False, id=id, **kwargs) img, w = Image(theme["field"]), 10 self.src = { "face": crop(img, w, 0, 1, img.height), "cap1": crop(img, 0, 0, w, img.height), "cap2": crop(img, img.width - w, 0, w, img.height), } if action: # Override the Button.on_action() method from the given function. self.set_method(action, name="on_action") self.default = value self.append(Label(hint, fill=Color(0, 0.4))) self._pack()
def __init__(self, caption="", action=None, x=0, y=0, width=125, id=None, **kwargs): """ A clickable button that will fire Button.on_action() when clicked. The action handler can be defined in a subclass, or given as a function. """ Control.__init__(self, x=x, y=y, width=width, id=id, **kwargs) img, w = Image(theme["button"]), 20 self.src = { "face": crop(img, w, 0, 1, img.height), "cap1": crop(img, 0, 0, w, img.height), "cap2": crop(img, img.width - w, 0, w, img.height), } if action: # Override the Button.on_action() method from the given function. self.set_method(action, name="on_action") _popdefault(kwargs, "width") _popdefault(kwargs, "height") self.append(Label(caption, **kwargs)) self._pack()
def __init__(self, caption="", action=None, x=0, y=0, width=125, id=None, **kwargs): """ A clickable button that will fire Button.on_action() when clicked. The action handler can be defined in a subclass, or given as a function. """ Control.__init__(self, x=x, y=y, width=width, id=id, **kwargs) img, w = Image(theme["button"]), 20 self.src = { "face" : crop(img, w, 0, 1, img.height), "cap1" : crop(img, 0, 0, w, img.height), "cap2" : crop(img, img.width-w, 0, w, img.height), } if action: # Override the Button.on_action() method from the given function. self.set_method(action, name="on_action") _popdefault(kwargs, "width") _popdefault(kwargs, "height") self.append(Label(caption, **kwargs)) self._pack()
def __init__(self, default=0.5, min=0.0, max=1.0, steps=100, x=0, y=0, width=125, id=None, **kwargs): """ A draggable slider that will fire Slider.on_action() when dragged. The slider's value can be retrieved with Slider.value. """ Control.__init__(self, x=x, y=y, width=width, id=id, **kwargs) self.min = min # Slider minimum value. self.max = max # Slider maximum value. self.default = default # Slider default value. self.value = default # Slider current value. self.steps = steps # Number of steps from min to max. img, w = Image(theme["slider"]), 5 self.src = { "face1": crop(img, w, 0, 1, img.height), "face2": crop(img, img.width - w, 0, 1, img.height), "cap1": crop(img, 0, 0, w, img.height), "cap2": crop(img, img.width - w, 0, w, img.height), "handle": Image(theme["slider-handle"]), } # The handle is a separate layer. self.append(Handle(self)) self._pack()
def __init__(self, default=0.5, min=0.0, max=1.0, steps=100, x=0, y=0, width=125, id=None, **kwargs): """ A draggable slider that will fire Slider.on_action() when dragged. The slider's value can be retrieved with Slider.value. """ Control.__init__(self, x=x, y=y, width=width, id=id, **kwargs) self.min = min # Slider minimum value. self.max = max # Slider maximum value. self.default = default # Slider default value. self.value = default # Slider current value. self.steps = steps # Number of steps from min to max. img, w = Image(theme["slider"]), 5 self.src = { "face1" : crop(img, w, 0, 1, img.height), "face2" : crop(img, img.width-w, 0, 1, img.height), "cap1" : crop(img, 0, 0, w, img.height), "cap2" : crop(img, img.width-w, 0, w, img.height), "handle" : Image(theme["slider-handle"]) } # The handle is a separate layer. self.append(Handle(self)) self._pack()
def __init__(self, caption="", fixed=False, modal=True, x=0, y=0, width=175, height=250, **kwargs): """ A panel containing other controls that can be dragged when Panel.fixed=False. Controls or (Layout groups) can be added with Panel.append(). """ Control.__init__(self, x=x, y=y, width=max(width, 60), height=max(height, 60), **kwargs) img, w = Image(theme["panel"]), 30 self.src = { "cap1": crop(img, 0, img.height - w, w, w), "cap2": crop(img, img.width - w, img.height - w, w, w), "cap3": crop(img, 0, 0, w, w), "cap4": crop(img, img.width - w, 0, w, w), "top": crop(img, w + 1, img.height - w, 1, w), "bottom": crop(img, w + 1, 0, 1, w), "left": crop(img, 0, w + 1, w, 1), "right": crop(img, img.width - w, w + 1, w, 1), "face": crop(img, w + 1, w + 1, 1, 1), } _popdefault(kwargs, "width") _popdefault(kwargs, "height") self.append(Label(caption, **kwargs)) self.append(Close()) self.fixed = fixed # Draggable? self.modal = modal # Closeable? self._pack()
def __init__(self, caption="", fixed=False, modal=True, x=0, y=0, width=175, height=250, **kwargs): """ A panel containing other controls that can be dragged when Panel.fixed=False. Controls or (Layout groups) can be added with Panel.append(). """ Control.__init__(self, x=x, y=y, width=max(width,60), height=max(height,60), **kwargs) img, w = Image(theme["panel"]), 30 self.src = { "cap1" : crop(img, 0, img.height-w, w, w), "cap2" : crop(img, img.width-w, img.height-w, w, w), "cap3" : crop(img, 0, 0, w, w), "cap4" : crop(img, img.width-w, 0, w, w), "top" : crop(img, w+1, img.height-w, 1, w), "bottom" : crop(img, w+1, 0, 1, w), "left" : crop(img, 0, w+1, w, 1), "right" : crop(img, img.width-w, w+1, w, 1), "face" : crop(img, w+1, w+1, 1, 1) } _popdefault(kwargs, "width") _popdefault(kwargs, "height") self.append(Label(caption, **kwargs)) self.append(Close()) self.fixed = fixed # Draggable? self.modal = modal # Closeable? self._pack()