How to stop keyboard from automatically popping up when app starts

326 views
Skip to first unread message

Anoop Rana

unread,
Feb 29, 2020, 11:59:31 AM2/29/20
to kivy-...@googlegroups.com
I have created an app and used window.bind(on_keyboard=self.some_function) as i am listening for keyboard event press.Everything is working but when the app opens up a keyboard is popping up automatically.I don't want the keyboard to open up auomatically when the app starts.Is there a way to do that?
Here is the code i'm using:
`class SecondWindow(Screen):
def init(self,**kwargs):
super(SecondWindow,self).init(**kwargs)
self.screen_list=[]
Window.bind(on_keyboard=self.Android_back_click)

def Android_back_click(self,window,key,*largs):
if key == 27:
print(self.manager.current)
if(self.manager.current=='main'):
print("Hello")`

ZenCODE

unread,
Mar 1, 2020, 2:26:00 PM3/1/20
to Kivy users support
The code is unreadable, un-indented and with no imports. Please post the complete, runnable code.

Thanks

Anoop Rana

unread,
Mar 2, 2020, 8:10:05 AM3/2/20
to kivy-...@googlegroups.com
This is the runnable code:I have used window.bind in class SecondWindow.But this results in a keyboard popping up when the app opens.How can i get the same functionality but without the keyboard opening at the opening of the application?
I am also attaching the file.py so that you can run the code directly at your pc.



from pathlib import Path
from kivymd.uix.dialog import MDDialog
from kivy.uix.progressbar import ProgressBar
from kivymd.uix.spinner import MDSpinner
import multiprocessing
import os
from openpyxl import Workbook
from openpyxl import load_workbook
import codecs
from ast import literal_eval
import itertools
import re
import xlrd
import time as wtime
from datetime import datetime,time
from openpyxl.styles import Font,Fill
from openpyxl.styles.colors import RED
from openpyxl.styles.colors import BLACK
from openpyxl.styles import PatternFill,Border,Side,Alignment,Protection,Font
from openpyxl.styles import colors
from openpyxl.styles.colors import BLUE
#import pygame
#from Tkinter import *
#import Tkinter
#import tkMessageBox
import logging
import json
import random
import numpy as np
#from pygame.locals import *
import xlsxwriter
#import pandas as pd
from shutil import copyfile
from kivymd.app import MDApp
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.widget import Widget
from kivy.properties import ObjectProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivymd.theming import ThemeManager
from kivymd.uix.menu import MDDropdownMenu
from kivymd.toast import toast
from kivy.core.window import Window
Window.softinput_mode = 'below_target'
#from kivymd.uix.button import MDRaisedButton

from kivy.clock import Clock
from kivy.graphics.context_instructions import Color
from kivy.graphics.stencil_instructions import (
    StencilPush,
    StencilUse,
    StencilPop,
    StencilUnUse,
)
from kivy.graphics.vertex_instructions import Ellipse, RoundedRectangle,Rectangle
from kivy.lang import Builder
from kivy.metrics import dp
from kivy.app import runTouchApp
from kivy.uix.button import Button
from kivy.uix.image import Image
from kivy.utils import get_color_from_hex
from kivy.properties import (
    StringProperty,
    BoundedNumericProperty,
    ListProperty,
    AliasProperty,
    BooleanProperty,
    NumericProperty,
    OptionProperty,
)
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.behaviors import ButtonBehavior
from kivy.animation import Animation
from kivy.uix.scrollview import ScrollView
from kivymd.uix.behaviors.backgroundcolorbehavior import (
    SpecificBackgroundColorBehavior,
)
from kivymd.uix.behaviors import (
    CircularRippleBehavior,
    RectangularRippleBehavior,
)
from kivymd.uix.behaviors import (
    CommonElevationBehavior,
    RectangularElevationBehavior,
    CircularElevationBehavior,
)
from kivymd.theming import ThemableBehavior

#from android.permissions import request_permissions, Permission
#request_permissions([Permission.WRITE_EXTERNAL_STORAGE])
#request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

#android.whitelist = [org.test.myapp]
##from permissions.location import check_permission, ask_permission
from kivymd.uix.label import MDLabel



Builder.load_string("""

#:import MDLabel kivymd.uix.label.MDLabel
#:import MDTextField kivymd.uix.textfield.MDTextField
#:import MDRaisedButton kivymd.uix.button.MDRaisedButton
#:import get_hex_from_color kivy.utils.get_hex_from_color
#:import utils kivy.utils
#:import NavigationDrawerSubheader kivymd.uix.navigationdrawer.NavigationDrawerSubheader
#:set color_shadow [0, 0, 0, .2980392156862745]
#:set color_lilac [.07058823529411765, .07058823529411765, .14901960784313725, .8]
<WindowManager>:
    MainWindow:
        name:"main"
    SecondWindow:
        name:"second"

<MainWindow>:
    name: "main"
    lid1:lid1
    FloatLayout:
        orientation: 'vertical'
        canvas.before:
            Color:
                #rgb: 1,1,1
                rgba:utils.get_color_from_hex('#1f1f1f')
            Rectangle:
                #source: 'image.jpg'
                size: self.size
                pos: self.pos

        BoxLayout:
            orientation:"horizontal"
            #padding:[50,0,0,0]
            size_hint:[0.4,0.2]
            pos_hint:{"x":0.05,"y":.4}
           
            canvas.before:
                Color:
                    rgba:utils.get_color_from_hex('#474747')
                RoundedRectangle:
                    pos:self.pos
                    size:self.size
           
            Icon:
                pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                halign: 'center'
                font_style: 'Icon'
                icon_name: 'account'
                text: md_icons.get(self.icon_name)
                font_size: 85
                theme_text_color: 'Custom'
                   
                text_color: utils.get_color_from_hex('#ebebeb')
                on_release:
                    print("*******This should not be pressed*****")
                    app.root.current='second'
                   



        NavigationLayout:
            id:lid1
            MDNavigationDrawer:
                drawer_logo: 'image2.jpg'
                NavigationDrawerSubheader:
                    text:'Menu'
                NavigationDrawerIconButton:
                    icon:'information'
                    text:'About'
                    on_release:
                        print("ABOUT YES")
                       
                NavigationDrawerIconButton:
                    icon:'account'
                    text:'Author'
                    on_release:
                        print("AUTHOR YES")
                       

                NavigationDrawerIconButton:
                    icon:'file-video'
                    text:'Demo'
                    on_release:
                        print("DEMO YES")
                NavigationDrawerIconButton:
                    icon:'license'
                    text:'License'
                    on_release:
                        print("LICENSE YES")

               
<MyMDTextFieldRound@MDTextFieldRound>

    size_hint_x:None
    normal_color:color_shadow
    active_color:color_shadow
    pos_hint:{"center_x": 0.5}


<SecondWindow>:
    name: "second"
    instiname: instiname
    examiname: examiname
    suptdiname: suptdiname
    #lid2:lid2
    FloatLayout:

       
        FloatLayout:
            size: root.width, root.height/2
            orientation: 'vertical'
            canvas.before:
                Color:
                    rgba:utils.get_color_from_hex('#171F24')
                Rectangle:
                    #source: 'image.jpg'
                    size: self.size
                    pos: self.pos
           
           
           
            MDTextFieldRound:
                id:instiname
                #####input_type: 'text'
                ####keyboard_suggestions: True
                multiline:False
                hint_text:"Institute Name"
               
                pos_hint: {"x":0.11, "top":0.73}
                size_hint: 0.8, 0.12
                icon_type:'without'
               
               
           
            MDTextFieldRound:
                id:examiname
                ###input_type: 'text'
                ###keyboard_suggestions: True
                multiline:False
                hint_text: "Examination Name"
               
               
               


                pos_hint: {"x":0.11, "top":0.6}
                size_hint: 0.8, 0.12
                icon_type:"without"
               
               
           
            MDTextFieldRound:
                id:suptdiname
                ###input_type: 'text'
                ###keyboard_suggestions: True
                multiline:False
                hint_text: "Examination Suptd."
               

                pos_hint: {"x":0.11, "top":0.47}
                size_hint: 0.8, 0.12
                icon_type:"without"
               
               
        #MDFloatingActionButton:
         #   icon: 'gitlab'
         #   theme_text_color:'Custom'
         #   text_color:[1,1,1,1]
         #   md_bg_color:(0.404,0.227,0.718,1.0)
         #   pos_hint:{"x":0.79,"y":0.03}
           
          #  on_release: lid2.toggle_state()


        MDRaisedButton:
            text: "Submit"
            md_bg_color:utils.get_color_from_hex('#21323B')
            size_hint: 0.4, 0.07
            pos_hint:{"x":0.31,"y":0.1}
            on_release:
                app.root.current = "main"
                root.manager.transition.direction = "right"
                #root.assignime()




""")


class WindowManager(ScreenManager):
    pass

class MainWindow(Screen):
    pass


class SecondWindow(Screen):
    def __init__(self,**kwargs):
        super(SecondWindow,self).__init__(**kwargs)
        self.screen_list=[]
        Window.bind(on_keyboard=self.Android_back_click)
    def newcallback(self,text_of_selection,popup_widget):
        quit()

    def Android_back_click(self,window,key,*largs):
        if key == 27:
            print(self.manager.current)
            if(self.manager.current=='main'):
                print("Inside main")
            elif(self.manager.current=='second'):
                print("Inside second")
class Icon(MDLabel,Button):
    icon_name = StringProperty()




class MyMainApp(MDApp):
    #theme_cls=ThemeManager()
    def build(self):
        return WindowManager()


if __name__ == "__main__":
   
    MyMainApp().run()


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/179b1716-5d83-42ac-b64d-2211fb7215c4%40googlegroups.com.
file.py

Anoop Rana

unread,
Mar 4, 2020, 9:35:25 AM3/4/20
to kivy-...@googlegroups.com
Have you read the code? Anyone any suggestions?

Anoop Rana

unread,
Mar 8, 2020, 8:27:32 AM3/8/20
to kivy-...@googlegroups.com
Here is the code and keyboard popping up automatically screenshot on android.
Screenshot from 2020-03-08 17-41-44.png
Capture+_2020-03-08-17-45-45.png

Elliot Garbus

unread,
Mar 8, 2020, 8:43:21 AM3/8/20
to kivy-...@googlegroups.com

Here are some suggestions.  I don’t have any experience with Android – but expect that this approach will solve the problem.

 

First confirm your assumption that the Window.bind() in the __init__() is causing the keyboard to open from by commenting it out.

If that is the problem, then there are a few places that you can try moving it.

 

Screens have an on_enter event.  You could move the bind to the on_enter event for the screen.  Alternatively,  TextInput has an event on_focus that fires when the TextInput widget goes in or out of focus.  You could bind/unbind in the on_focus event.

Dheeraj Reddy Kondakindi

unread,
Mar 9, 2020, 7:21:54 AM3/9/20
to Kivy users support
how did u convet ur code to android app please help me to do that i use buildozer and kivy launcher
On Mon, Mar 2, 2020 at 12:56 AM ZenCODE <zenkey...@gmail.com> wrote:
The code is unreadable, un-indented and with no imports. Please post the complete, runnable code.

Thanks

On Saturday, February 29, 2020 at 6:59:31 PM UTC+2, Anoop Rana wrote:
I have created an app and used window.bind(on_keyboard=self.some_function) as i am listening for keyboard event press.Everything is working but when the app opens up a keyboard is popping up automatically.I don't want the keyboard to open up auomatically when the app starts.Is there a way to do that?
Here is the code i'm using:
`class SecondWindow(Screen):
def init(self,**kwargs):
super(SecondWindow,self).init(**kwargs)
self.screen_list=[]
Window.bind(on_keyboard=self.Android_back_click)

def Android_back_click(self,window,key,*largs):
if key == 27:
print(self.manager.current)
if(self.manager.current=='main'):
print("Hello")`

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Anoop Rana

unread,
Mar 9, 2020, 8:03:13 AM3/9/20
to kivy-...@googlegroups.com
Yes the keyboard is opening because of Window.bind(on_keyboard).
I tried using on_event() inside one of screen and also removed the __init__ and replaced it by other_function_name() that has inside it Window.bind().
STILL the keyboard is opening automatically.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3a1d5a72-0f3c-4e67-a403-6dcccb3f5459%40googlegroups.com.

Anoop Rana

unread,
Mar 9, 2020, 9:27:49 AM3/9/20
to kivy-...@googlegroups.com
Isn't this a bug in kivy that whenever we use Window.bind(on_keyboard) a keyboard is popping up?Doesn't matter where you use it a keyboard (inside __init__ or any other function) .Does anyone have a working example of Window.bind(on_keyboard) which i can use to convert to an APK and check .Here is the app on playstore you can see that the keyboard popping up seems unclean.


Elliot Garbus

unread,
Mar 9, 2020, 9:52:53 AM3/9/20
to kivy-...@googlegroups.com
Did you try putting the bind into the on_focus event, in python code? 

Sent from my iPad

On Mar 9, 2020, at 6:27 AM, Anoop Rana <anoopr...@gmail.com> wrote:



Anoop Rana

unread,
Mar 9, 2020, 10:20:35 AM3/9/20
to kivy-...@googlegroups.com
I used on_enter as you suggested but the keyboard stillI pops-up automatically.I used the following code(something like this):
<MainWindow>:
        on_enter:
               root.my_function()

class MainWindow(Screen):
          def my_function(self,**kwargs):
                    Window.bind(on_keyboard=self.android_click_back)
          def android_click_back(self,window,key,*largs):
                       if(key==27):
                          print(''10000000000')#did something else


Elliot Garbus

unread,
Mar 9, 2020, 10:36:54 AM3/9/20
to kivy-...@googlegroups.com

Try putting it in the on_focus event, it further narrows when the bind would be called.  I suggest binding when the TextInput is in focus, and unbinding when focus is lost.

 

From: Anoop Rana
Sent: Monday, March 9, 2020 7:20 AM
To: kivy-...@googlegroups.com
Subject: Re: [kivy-users] Re: How to stop keyboard from automatically poppingup when app starts

 

I used on_enter as you suggested but the keyboard stillI pops-up automatically.I used the following code(something like this):

Anoop Rana

unread,
Mar 9, 2020, 10:41:16 AM3/9/20
to kivy-...@googlegroups.com
Can you give example how to unbind?
And how to use focus and InFocus of TextInput.

Elliot Garbus

unread,
Mar 9, 2020, 11:21:33 AM3/9/20
to kivy-...@googlegroups.com

Here is an example let me know if this helps.

 

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.properties import NumericProperty
from kivy.core.window import Window


class CharLimitTextInput(TextInput):
    max_characters = NumericProperty(
8# sets the max number of chars the user can input

   
def __init__(self, **kwargs):
       
super().__init__(multiline=False, **kwargs)     # Note: Multiline is False

   
def insert_text(self, substring, from_undo=False):
       
if len(self.text) < self.max_characters:
            ss = substring
if substring.isascii() else ''        # Only accept ASCII Strings
           
return super().insert_text(ss, from_undo=from_undo)

   
def on_text_validate(self):                         # Runs when enter is pressed, because multiline is false
       
if len(self.text) >= self.max_characters:
           
self.text = self.text[0:self.max_characters]
       
return super().on_text_validate()

   
def on_focus(self, _, focus):                       # Validate text if focus is lost
       
if focus:  # The TextInput is in focus
           
print('Text Widget in Focus')
            Window.bind(
on_keyboard=self.echo_key)
       
else:
            Window.unbind(
on_keyboard=self.echo_key)
            
print('TextInput Widget lost focus')

   
def echo_key(self, win, key, scancode, codepoint, modifier):
       
print(f'{self}, {win}, {key}, {scancode}, {codepoint}, {modifier}')

if __name__ == '__main__':
    kv =
"""
BoxLayout:
    orientation: 'vertical'
    Label:
        text: 'Test Text limit'
    CharLimitTextInput:
        id: input
        max_characters: 64
        hint_text: 'Enter up to 64 characters'
        size_hint_y: None
        height: dp(48)
    Label:
        text: input.text
    """


   
class TITestApp(App):
       
def build(self):
           
return Builder.load_string(kv)

    TITestApp().run()

Anoop Rana

unread,
Mar 9, 2020, 12:29:47 PM3/9/20
to kivy-...@googlegroups.com
The keyboard still pops-up when the app starts.Even though i have removed all the previous window.bind(on_keyboard=self.android_back_click) and let only the window.bind(on_keyboard=self.echo_key) and window.unbind() that you have given. Here is the screenshot.Why is this happening?It seems that it does not matter from where you call window.bind() once it is called the keyboard will open up.
Note that the TextInput is below the keyboard so it is not visible in the screenshot.But when i click on the screen the keyboard goes away and we can see the textinput.
Window.bind(on_keyboard) seems to be the problem here.

Capture+_2020-03-09-21-47-49.png

Elliot Garbus

unread,
Mar 9, 2020, 2:32:41 PM3/9/20
to kivy-...@googlegroups.com

Do you need to used the Window.bind?  Can you capture the key press of interest in the insert_test() method of the TextInput?

Robert Flatt

unread,
Mar 9, 2020, 9:55:24 PM3/9/20
to Kivy users support
I avoided this one because I know very little about .kv, so this is mostly guesswork.
For me this works as intended (keyboard when tap in input area, removed when tap elsewhere) on Android:

The text ends up in the next label, but I don't understand why. Elliot can you help me understand?

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.properties import NumericProperty
from kivy.core.window import Window


class CharLimitTextInput(TextInput):
    max_characters
= NumericProperty(8)  # sets the max number of chars the user can input

   
def __init__(self, **kwargs):
       
super().__init__(multiline=False, **kwargs)     # Note: Multiline is False

   
def insert_text(self, substring, from_undo=False):
       
if len(self.text) < self.max_characters:

           
# old style, I'm not using Python 3.7
            isascii
= lambda s: len(s) == len(s.encode())
            ss
= substring if isascii(substring) else ''        # Only accept ASCII Strings

           
return super().insert_text(ss, from_undo=from_undo)

   
def on_text_validate(self):                         # Runs when enter is pressed, because multiline is false
       
if len(self.text) >= self.max_characters:
           
self.text = self.text[0:self.max_characters]
       
return super().on_text_validate()

if __name__ == '__main__':
    kv
=
"""

BoxLayout:
    orientation: 'vertical'
    Label:
        text: 'Test Text limit'
    CharLimitTextInput:
        id: input
        max_characters: 64
        hint_text: 'Enter up to 64 characters'
        size_hint_y: None
        height: dp(48)
    Label:
        text: input.text
    Label:
        id: echo_here
        text: ""
    """

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Elliot Garbus

unread,
Mar 9, 2020, 10:03:58 PM3/9/20
to kivy-...@googlegroups.com

CharLimitTextInput:
        id: input
        max_characters: 64
        hint_text: 'Enter up to 64 characters'
        size_hint_y: None
        height: dp(48)
    Label:
        text: input.text

The id in a widget is a reference to the object.  The CharLimitTextInput is names input.  The input.text object is the text that is typed into the text box, it is also a kivy property.  This means it will get updated automatically.

 

Did that make sense?

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/b4d6c982-9a5c-4b2c-8a29-7b41a4c19be1%40googlegroups.com.

 

Robert Flatt

unread,
Mar 9, 2020, 10:05:59 PM3/9/20
to Kivy users support
I was not clear the text also appears in id: echo_here

Elliot Garbus

unread,
Mar 9, 2020, 10:11:49 PM3/9/20
to kivy-...@googlegroups.com

 

Do you have a standalone kv file named titest.kv?

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d7162cc1-8268-40f7-aae4-fe066a4cfbb3%40googlegroups.com.

 

Robert Flatt

unread,
Mar 9, 2020, 10:30:34 PM3/9/20
to Kivy users support
For the Buildozer build the only design file in the directory is main.py

Elliot Garbus

unread,
Mar 9, 2020, 10:53:04 PM3/9/20
to kivy-...@googlegroups.com
I don’t have a clue.  I pasted the file as is to a windows10 machine and it worked as expected. 
Perhaps remove the if __name__ == ... line  the indenting of the bottom of the file is not under the if anyway. 

Sent from my iPad

On Mar 9, 2020, at 7:30 PM, Robert Flatt <planckp...@gmail.com> wrote:


To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/8f721320-1487-4ef0-a86e-d3b0d2fdb939%40googlegroups.com.

Anoop Rana

unread,
Mar 9, 2020, 11:14:20 PM3/9/20
to kivy-...@googlegroups.com
This was also working for me but the only problem is that on android when the app starts the keyboard automatically starts popping up.@Robert 

Elliot Garbus

unread,
Mar 9, 2020, 11:32:48 PM3/9/20
to Kivy users support
 Can us use the insert_text() method to look for the keycode you are interested in?  If so, remove the on_focus routine (where the bind/unbind statements are located) does this work?

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Robert Flatt

unread,
Mar 10, 2020, 12:08:09 AM3/10/20
to Kivy users support
This was also working for me but the only problem is that on android when the app starts the keyboard automatically starts popping up.@Robert

With the code I posted above, which has no bind() ?

For me the keyboard only pops up when I tap the text input.

I used Buildozer 1.0  , made no changes to the .spec , and tested on Android 10.   Your case?

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Robert Flatt

unread,
Mar 10, 2020, 12:10:59 AM3/10/20
to Kivy users support
@Elliot  I get the same behavior on Windows as on Android, image below. (the image you posted did not render here, except as a placeholder)

Robert Flatt

unread,
Mar 10, 2020, 12:13:48 AM3/10/20
to Kivy users support
@Elliot, it seems pasting images does not render. Attached an image.

if <span style="font-family:Consolas;co
Annotation 2020-03-09 181154.jpg

Elliot Garbus

unread,
Mar 10, 2020, 12:28:00 AM3/10/20
to kivy-...@googlegroups.com

The image below is connect.  It is the same thing I see.

 

Going back to the kv code…

BoxLayout:
    orientation: 'vertical'
    Label:
        text: 'Test Text limit'  
# This is the Label above the text input.


    CharLimitTextInput:
        id: input
        max_characters: 64
        hint_text: 'Enter up to 64 characters'
        size_hint_y: None
        height: dp(48)
    Label:

        text: input.text          # This is the Label that echoes the text input
    Label:
        id: echo_here            
# This is a blank label
        text: ""

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/7473c67e-0602-42f6-912d-14cad992c2e4%40googlegroups.com.

 

Annotation 2020-03-09 181154.jpg

Anoop Rana

unread,
Mar 10, 2020, 12:47:30 AM3/10/20
to kivy-...@googlegroups.com
I have pinpointed from where the problem is arising.I am attaching two .py files .One of them is working(no automatic popup) and the other one is not working
.The problem is that i am using <WindowManager> and where all the <MainWindow> and <SecondWindow> is defined and a class corresponding to each exist.But this does not work correctly.
. In the other file there is no <WindowManager> and different screens are defined within the <Main>.So why is Window.bind() is working correctly in one file and not the other.
And by working correctly i mean no automatic popup when the app starts.

WORKING.py
NOT_WORKING.py

Robert Flatt

unread,
Mar 10, 2020, 12:48:48 AM3/10/20
to Kivy users support
Oh I see, thanks for your patience.



# Only accept ASCII Strings
  &n

Robert Flatt

unread,
Mar 10, 2020, 12:55:29 AM3/10/20
to Kivy users support
They are different binds. Don't know if this is the issue, but since we have a working example, and you have working code can we go home now?

Window.bind(on_keyboard=self.android_back_click)
Window.bind(on_keyboard = self.keyboard)




):
       
if len(self.text) < <span style="font

Elliot Garbus

unread,
Mar 10, 2020, 1:01:45 AM3/10/20
to kivy-...@googlegroups.com
def __init__(self,**kwargs):
               super(SecondWindow,self).__init__(**kwargs)
               self.screen_list=[]
               Window.bind(on_keyboard=self.android_back_click)
               Clock.schedule_once(lambda x: Window.release_all_keyboards(), 3)

 

The highlighted code seems to be a significant difference between the 2 files.

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

Anoop Rana

unread,
Mar 10, 2020, 1:12:32 AM3/10/20
to kivy-...@googlegroups.com
Yes i have used the highlighted code to release the keyboard when it pops up.So when the app starts the keyboard popsup automatically but then due to the highlighted line the keyboard goes away after 1 or 2 seconds automatically without me having to do it manually.Also if i remove the highlighted line then the keyboard remains there and does not go away and i have to manually click on the screen to shut it away.
I want the keyboard to not popup at all like in the WORKING.py file.

Clock.schedule_once(lambda x: Window.release_all_keyboards(), 3) #this is irrelevant here

Elliot Garbus

unread,
Mar 10, 2020, 1:23:52 AM3/10/20
to kivy-...@googlegroups.com

Another observation in ‘not working’  The indents are not correct here, looks like tabs.  I wonder if this could be part of the problem.

 

class SecondWindow(Screen):
    
        def __init__(self,**kwargs):
               super(SecondWindow,self).__init__(**kwargs)
               self.screen_list=[]
               Window.bind(on_keyboard=self.android_back_click)
               Clock.schedule_once(lambda x: Window.release_all_keyboards(), 3)
               #Window.release_all_keyboards()
        def newcallback(self,text_of_selection,popup_widget):
               quit()
        def android_back_click(self,window,key,*largs):
                if key == 27:
                    print(self.manager.current)
                    if(self.manager.current=='main'):
                       print('MAIN')
                       quit()
                    else:
                       print('SECOND')
                       self.manager.current='main'
                       return True

Anoop Rana

unread,
Mar 10, 2020, 1:34:48 AM3/10/20
to kivy-...@googlegroups.com
Oh those are because i pasted the code directly in that file. In my main.py file those unnecessary indents are not there.That is those unnecessary tabs/indents are not in my main.py file which i use to make the apk.

Anoop Rana

unread,
Mar 10, 2020, 2:10:34 AM3/10/20
to kivy-...@googlegroups.com
@Robert :
Those are basically the same bind except the name of the function called.I tried using the self.keyboard also but still the keyboard pops up automatically.There is some basic error/fault in there which we are not able to catch.

Anoop Rana

unread,
Mar 10, 2020, 4:06:24 AM3/10/20
to kivy-...@googlegroups.com
I think the only difference between the two files that is causing this issue is:
Using App and MDApp.Maybe this is kivymd side bug?
class MyApp(App):    #working
    def build(self):
        return Main()

class MyMainApp(MDApp): #not working
   
    def build(self):
        return WindowManager()


Anoop Rana

unread,
Mar 10, 2020, 5:33:41 AM3/10/20
to kivy-...@googlegroups.com
It is confirmed related to class MyMain(MDApp) that i am using instead of MyMain(App).This seems to be a bug at kivymd side.If you've a working example for KivyMD for window.bind(on_keyboard) please send.

Anoop Rana

unread,
Mar 13, 2020, 2:50:52 AM3/13/20
to kivy-...@googlegroups.com
I figured out where the problem is.
MDTextFieldRound was the problem .By default it has on_focus property and it has value True.Also I am now using MDTextField.
Reply all
Reply to author
Forward
0 new messages