This commit is contained in:
yumoqing 2022-10-09 14:09:31 +08:00
parent dc854b0695
commit f2f45641a4
3 changed files with 47 additions and 42 deletions

View File

@ -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,

View File

@ -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:

View File

@ -1 +1 @@
__version__ = '0.3.26'
__version__ = '0.3.27'