gpt4 book ai didi

python - 在TextInput中单击鼠标时光标消失(不闪烁)-Python Kivy

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:07 26 4
gpt4 key购买 nike

我正在使用带树莓派的python和Kivy库构建一个小型应用程序。

GUI在浮动布局中包含4个文本输入和3个按钮。
问题是,当我单击文本输入光标时,该光标显示并且立即消失。
仅在不释放鼠标单击的情况下,才能介绍文本。

.kv文件:

<AddStuffMenu>:
FloatLayout:
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Button:
text: "Info"
pos_hint: {'center_x': 0.5, 'center_y': .8}
size_hint: .5, .1
font_size: self.height * 0.5
background_color:0,0,0,0
color: 0,0,1,1
enabled : False
TextInput:
size_hint: .2, None
height:30
text:''
pos_hint: {'center_x': 0.5, 'center_y': .7}
multiline: False
hint_text : "code"
id: code
TextInput:
size_hint: .2, None
height:30
text:''
pos_hint: {'center_x': .5, 'center_y': .6}
multiline: False
hint_text : "product"
id: product
TextInput:
size_hint: .2, None
height:30
text:''
pos_hint: {'center_x': .5, 'center_y': .5}
multiline: False
hint_text : "amount"
id: amount
TextInput:
size_hint: .2, None
height:30
text:''
pos_hint: {'center_x': .5, 'center_y': .4}
multiline: False
hint_text : "price"
id: price
Button:
text: "Scan"
pos_hint: {'center_x': .2, 'center_y': .2}
size_hint: .15, .1
font_size: self.height * 0.5
background_color:1, 0, 0, 1
on_press: root.scan()
Button:
text: "Add"
pos_hint: {'center_x': .5, 'center_y': .2}
size_hint: .15, .1
font_size: self.height * 0.5
background_color: 1, 0, 0, 1
on_press: root.add()
Button:
text: "Back"
pos_hint: {'center_x': .8, 'center_y': .2}
size_hint: .15, .1
font_size: self.height * 0.5
background_color: 1, 0, 0, 1
on_press: root.exitScope()


.py文件

class AddStuffMenu(Screen):

def __init__(self,**kwargs):
super (AddStuffMenu,self).__init__(**kwargs)

def exitScope(self,*args):
self.manager.current = 'screenTableData'

def scan(self,*args):
os.system('python /home/pi/barcode.py')
if(os.path.getsize('/home/pi/barcode.txt') > 0):
code = open('/home/pi/barcode.txt', 'r').read()
result = getLineByUPC(code)
if result is not None:
self.ids.codeInput.text = str(result[0])
self.ids.produsInput.text = str(result[1])
else:
popup = Popup(title='INFO', content=Label(text="Produc doesn't exist"), size_hint=(None, None), size=(500, 300), font_size='23sp', valign='justify', haligh='top')
popup.open()
self.ids.code.text = code
else:
popup = Popup(title='INFO', content=Label(text="Try again"), size_hint=(None, None), size=(500, 300), font_size='23sp', valign='justify', haligh='top')
popup.open()


def add(self,*args):
print("AddStuffMenu - add")
print(self.ids.code.text)
print(self.ids.product.text)
print(self.ids.amount.text)
print(self.ids.price.text)


有什么建议吗?

最佳答案

由于您尚未发布任何代码,很难分辨...

我猜你有一个由onbuttonclick或类似的东西定义的参数。您可能需要包括onbuttonrelease参数。

关于python - 在TextInput中单击鼠标时光标消失(不闪烁)-Python Kivy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54355339/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com