1
我正在運行一個快速小測試,通過將值打印到TextInput來顯示當前選定的微調值。Kivy Spinner問題不立即更新文本值
當單擊微調框時,它會打開下拉框,就像我點擊「全部顯示」選項時一樣,它將它設置爲活動狀態(意思是當前選定的值),並且下拉框關閉, t似乎沒有正確註冊,因爲它不會進入函數,直到我打開下拉菜單並再次單擊該值。
有關如何解決此問題的任何建議?
from kivy.uix.spinner import Spinner
from kivy.uix.widget import Widget
import kivy.event
from kivy.uix.textinput import TextInput
from kivy.app import App
from kivy.core.window import Window
import kivy
def Display_All(s):
displayWindow.text = s
return None
def Pick(event):
val = fileMenu.text
if val == 'Display All':
Display_All(val)
Root = Widget(size = (890, 505))
displayWindow = TextInput(pos = (250, 30), size = (620, 470))
fileMenu = Spinner(text = 'File',
values = ('File', 'Display All', 'Print', 'Search Specific'),
size = (120, 44), pos = (0, 460))
fileMenu.bind(on_press = Pick)
Root.add_widget(displayWindow)
Root.add_widget(fileMenu)
class ExampleApp(App):
def build(self):
return Root
Window.size = (890, 505)
if __name__ == '__main__':
ExampleApp().run()
你可以把它變成[mcve]嗎? – zeeMonkeez
更新了可運行版本的代碼,很抱歉! – Afflicted