3
我有一個用一些textinput
的kivy應用程序,我想在智能手機上顯示一個數字鍵盤。我一直在閱讀,我認爲,與財產input_type=number
我可以得到正確的結果,但我意識到,與基維更新現在不工作。當我的textinput
聚焦時,如何獲得數字鍵盤?使用橫向模式的應用程序可能會很有用,或者鍵盤仍然會佔用一半的屏幕?這裏你有代碼:將數字鍵盤設置爲我的kivy應用程序python
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
class LoginScreen(GridLayout):
def __init__(self,**kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.cols=2
self.add_widget(Label(text='Subject'))
self.add_widget(Label(text=''))
self.add_widget(Label(text='1'))
self.add_widget(TextInput(multiline=False))
self.add_widget(Label(text='2'))
self.add_widget(TextInput(multiline=False))
self.add_widget(Label(text='3'))
self.add_widget(TextInput(multiline=False))
self.add_widget(Label(text='4'))
self.add_widget(TextInput(multiline=False))
b1=Button(text='Exit',background_color=[0,1,0,1],height=int(Window.height)/9.0) #doesn't work properly
self.add_widget(b1)
b2=Button(text='Run',background_color=[0,1,0,1],height=int(Window.height)/9.0) #doesn't work properly
self.add_widget(b2)
b1.bind(on_press=exit)
class SimpleKivy(App):
def build(self):
return LoginScreen()
if __name__=='__main__':
SimpleKivy().run()
請給我們展示一些代碼! –
@UlfGjerdingen我用代碼編輯了問題。 –