我正在制作一个GUI,其中有一个生成标签的函数,我想让用户也可以更改这些标签的文本。在
但这让我非常头疼,所以我试了一个小规模,我创建了一个显示标签数量的标签,我试图用不同的解决方案更新“新数量标签文本”,但没有成功。在
我试着穿线,但失败了。然后我尝试了在Kivy时钟对象,但我也失败了,我没有失败,因为那些不起作用,因为我是新编程,我不真正理解他们。 生产日期:
class Screen_two(Screen):
productsamount = StringProperty(None)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Clock.schedule_once(self.update_amount_label, 0)
def update_amount_label(self, dt):
n = 0
for i in db.databaseDict.items():
n += 1
self.ids.productsamount.text = 'Amount of goods: {}'.format(n)
千伏:
^{pr2}$编辑1:
我想用defadd_product(self):
函数更改标签文本。在
编辑2:
我不想只更改标签的文本一次,但我想在每次调用函数(按钮按下)时更改标签文本。例如:每当我在文本输入中写入内容并按下按钮时,我希望将标签文本更改为我在Textinput中所写的内容,而不是仅更改一次,而是每次按下按钮时。(对不起,我没有说清楚(英语不是我的母语)
试试这个。您有一个对事件有本机支持的按钮。在
例如,它有“按”或“放”。对于这些事件,您可以附加将被触发的函数。在
生产日期:
千伏:
^{pr2}$ps:我没有测试过,但我认为它应该可以工作
以下是您的代码的一个版本,我对其进行了修改以实现您的目标:
我想这应该有帮助
这会帮助你更好地理解它
相关问题 更多 >
编程相关推荐