我正在用Pythonista做一个小的定价工具。这是我写的。
# starts actions with go button
def getPrices(mtmPriceUser):
viewSelector = mtmPriceUser.superview
userInput = viewSelector['textview1'].text
userInput = float(userInput)
textLabel1 = v['label1']
discNamesList, discOutcomesdict = creatDiscList(standardDisc, userInput)
# create string of discounts and prices
priceString = createString(discNamesList,discOutcomesDict)
textLabel1.text = priceString
textLabel1.end_editing()
v = ui.load_view()
v.present('sheet')我得到以下错误
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/7C463C71-C565-47D8-A1D8-C2D588A974C1/Pythonista3/Documents/Pricing App/UI_Attempt.py", line 79, in getPrices
textLabel1.end_editing()
AttributeError: '_ui.Label' object has no attribute 'end_editing'在哪里使用end编辑方法?如果我不能,我怎么能在我按下按钮后让键盘消失呢?
发布于 2019-11-13 05:29:11
您似乎是在没有此方法的label上调用end_editing()。
您需要在用于数据输入的TextField或TextView对象上调用该方法。
在您的示例中,这似乎是viewSelector['textview1'],为了简单起见,它可能值得存储在一个变量中,就像您对标签所做的那样。
例如:
text_entry = viewSelector['textview1']
userInput = text_entry.text
# Your other code
text_entry.end_editing()https://stackoverflow.com/questions/57208179
复制相似问题