当我将注意力集中在switch
时,有人可以告诉我如何显示突出显示Switch
小部件吗?应该看起来像是专注的。
from kivy.uix.screenmanager import Screen
from kivy.app import App
from kivy.core.window import Window
from kivy.properties import StringProperty, ObjectProperty
from kivy.clock import Clock
Window.clearcolor = (0.5, 0.5, 0.5, 1)
Window.size = (200, 150)
class User(Screen):
swtch = ObjectProperty(None)
def __init__(self, **kwargs):
super(User, self).__init__(**kwargs)
Clock.schedule_once(self.swtch_focus, 1)
def swtch_focus(self, *args):
self.swtch.focus = True
class Test(App):
def build(self):
return self.root
if __name__ == '__main__':
Test().run()
User:
swtch: swtch
BoxLayout:
orientation: "vertical"
GridLayout:
cols: 2
padding: 20, 20
spacing: 10, 10
Switch:
id:swtch
答案 0 :(得分:0)
在github中有hoverableBehaviour是链接https://gist.github.com/KeyWeeUsr/3166f13d363d5558f481d538c6a5d2aa复制代码并创建一个模块到当前目录并导入它以使用它,您可以将其添加到您的Widget以获得焦点或突出显示功能。这是怎么做的。
java.io.IOException