【发布时间】:2018-05-20 09:49:12
【问题描述】:
我想制作一个文本输入选择器(以便光标在其上闪烁),而不是单击文本输入本身,而是单击一个按钮。如何轻松做到这一点?
.py:
import kivy
kivy.require('1.10.0')
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
class Main(Screen):
def __init__(self, **kwargs):
super(Main, self).__init__(**kwargs)
def select_textinput(self, instance):
pass
class GUI(App):
def build(self):
sm = ScreenManager()
sm.add_widget(Main())
return sm
if __name__ == '__main__':
GUI().run()
.kv:
#: kivy 1.10.0
<Main>:
name: "main_screen"
TextInput:
id: ti
text: "Try to put the cursor here without clicking"
Button:
text: "Click here to select the text input !"
on_press: root.select_textinput(ti)
【问题讨论】:
-
您必须具体说明您的问题,而不是您询问了 XY problem 导致我浪费时间。更新您的问题,我很乐意再次为您提供帮助