Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hiding android keyboard in kivy

Tags:

python

kivy

i am building a simple app that has several screens and i have been dealing with the android keyboard not hiding after the next screen is displayed. i have looked over the internet and have not found a solution that fixes this issue. below is a block of code that i found here. i have tried to modify it unsuccessfully. apparently i needed to import the android module for it to work but i'am not quite sure how to do it. please help if you have any idea how the hide the keyboard . Thanks

def hide_keyboard(f):
    def new_function(self, *args, **kwargs):
        try:
            if platform == "android":
                android.hide_keyboard()
            self.root.from_n.focus = False
            self.root.to_n.focus = False
        except:
            import traceback; traceback.print_exc();
        f(self, *args, **kwargs)

    return new_function
like image 436
Emmanuel Nabi Avatar asked Nov 05 '16 05:11

Emmanuel Nabi


Video Answer


1 Answers

Looks like Window has a method for this:

from kivy.core.window import Window
Window.release_all_keyboards()
like image 54
inclement Avatar answered Sep 30 '22 16:09

inclement