From f2f45641a4fe64fdd21ace17fd20d31a048db7a9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 9 Oct 2022 14:09:31 +0800 Subject: [PATCH] bugfix --- kivyblocks/clickable.py | 45 +++++++++++++++++++++++++++++++++++++++ kivyblocks/toggleitems.py | 42 +----------------------------------- kivyblocks/version.py | 2 +- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/kivyblocks/clickable.py b/kivyblocks/clickable.py index 382fa75..e9bf4c7 100644 --- a/kivyblocks/clickable.py +++ b/kivyblocks/clickable.py @@ -16,6 +16,11 @@ from kivyblocks.widget_css import WidgetCSS from .uitype.factory import UiFactory, get_value from .command_action import cmd_action +def on_disabled(self, *args): + pass + +TouchRippleButtonBehavior.on_disabled = on_disabled + class TinyText(Text): def __init__(self, **kw): SUPER(TinyText, self, kw) @@ -26,6 +31,46 @@ class TinyText(Text): self.texture_update() self.size = self.texture_size +class PressableBox(TouchRippleButtonBehavior, Box): + normal_css = StringProperty("default") + actived_css = StringProperty("default") + box_actived = BooleanProperty(False) + def __init__(self, + border_width=1, + user_data=None, + radius=[], + **kw): + super(PressableBox, self).__init__( + padding=[border_width, + border_width, + border_width, + border_width], + radius=radius, + **kw) + self.border_width = border_width + self.user_data = user_data + self.actived = False + self.csscls = self.normal_css + + def active(self, flag): + self.box_actived = flag + + def on_box_actived(self, o, v): + if self.box_actived: + self.csscls = self.actived_css + else: + self.csscls = self.normal_css + + def on_press(self,o=None): + self.box_actived = True + + + def setValue(self,d): + self.user_data = d + + def getValue(self): + return self.user_data + class ClickableBox(TouchRippleButtonBehavior, Box): def __init__(self, border_width=1, diff --git a/kivyblocks/toggleitems.py b/kivyblocks/toggleitems.py index 2e31e86..ec3ad27 100644 --- a/kivyblocks/toggleitems.py +++ b/kivyblocks/toggleitems.py @@ -1,6 +1,5 @@ from functools import partial from kivy.logger import Logger -from kivy.uix.behaviors import TouchRippleButtonBehavior from kivy.graphics import Color, Rectangle from kivy.uix.boxlayout import BoxLayout from kivy.factory import Factory @@ -11,46 +10,7 @@ from kivyblocks.bgcolorbehavior import BGColorBehavior from kivyblocks.utils import CSize from kivyblocks.baseWidget import Box from kivyblocks.widget_css import WidgetCSS - -class PressableBox(TouchRippleButtonBehavior, Box): - normal_css = StringProperty("default") - actived_css = StringProperty("default") - box_actived = BooleanProperty(False) - def __init__(self, - border_width=1, - user_data=None, - radius=[], - **kw): - super(PressableBox, self).__init__( - padding=[border_width, - border_width, - border_width, - border_width], - radius=radius, - **kw) - self.border_width = border_width - self.user_data = user_data - self.actived = False - self.csscls = self.normal_css - - def active(self, flag): - self.box_actived = flag - - def on_box_actived(self, o, v): - if self.box_actived: - self.csscls = self.actived_css - else: - self.csscls = self.normal_css - - def on_press(self,o=None): - self.box_actived = True - - - def setValue(self,d): - self.user_data = d - - def getValue(self): - return self.user_data +from kivyblocks.clickable import PressableBox """ ToggleItems format: diff --git a/kivyblocks/version.py b/kivyblocks/version.py index 98a4617..5204063 100644 --- a/kivyblocks/version.py +++ b/kivyblocks/version.py @@ -1 +1 @@ -__version__ = '0.3.26' +__version__ = '0.3.27'