Virtual Keyboard with Kivy
Posted: 09 April 2015 04:16 AM   [ Ignore ]
Rank
Joined  2015-04-08
Total Posts:  1
New Member

Hi Everyone,

i have a simple Problem (i hope :D )

I have created a login uses interface with two textinputs and two labels. Now i want to show up a virtual keyboard wenn a textinput is focused.
Mycode looks like this:

__author__ 'VWGX1YO'
from kivy.app import App
from kivy
.uix.gridlayout import GridLayout
from kivy
.uix.label import Label
from kivy
.uix.textinput import TextInput
from kivy
.uix.vkeyboard import VKeyboard


class LoginScreen(GridLayout):

    
def __init__(self, **kwargs):
        
super(LoginScreenself).__init__(**kwargs)
        
vk VKeyboard(layout='azerty')
        
self.cols 2
        self
.add_widget(Label(text='User Name'))
        
self.username TextInput(multiline=False)
        
self.add_widget(self.username)
        
self.add_widget(Label(text='password'))
        
self.password TextInput(password=Truemultiline=False)
        
self.add_widget(self.password)
        
self.add_widget(vk)

    
def focused(self):
        if 
self.password.focus == True:
            
self.vk.on_key_down(self)
        
elif self.username.focus == True:
            
self.vk.on_key_down(self)


class 
MyApp(App):
    
def build(self):
        return 
LoginScreen()


if 
__name__ == '__main__':
    
MyApp().run()

class 
MyApp(App):
    
def build(self):
        return 
LoginScreen()


if 
__name__ == '__main__':
    
MyApp().run()

this code shows me my textinputs, labels and my virtual keyboard. But i have no idea how i can make the keyboard write into my textinputs. As you see i tried it with a method called “focus”, my idea was, if a textinput is focused,then the keyboard should write into this textinput. But unfortunately it didnt worked.
Do you have any idea how to realize that?

Will be glad about any help!

Best regards
Duall

Profile