Setting focus to True on TextInput crashes app in Windows

11 views
Skip to first unread message

KaitainJ

unread,
Dec 23, 2018, 5:52:57 PM12/23/18
to Kivy users support
This is with

[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MS
C v.1500 32 bit (Intel)]

This code works perfectly on Linux but trashes the app with a fatal freeze on Windows.

def createTextInputPrompts( promptAndDefaultPairs ):

   
assert thisIsMainThread()
    boxLayout
= GridLayout(cols=1)


    primaryInput
= None


   
for [prompt, default] in promptAndDefaultPairs:
        label
= Label(text=prompt)
        textinput
= TextInput(text=default, multiline=False)
       
if not primaryInput:
            primaryInput
= textinput
        textinput
.write_tab = False
        textinput
.bind(focus=textInputGotFocus)
        boxLayout
.add_widget( label )
        boxLayout
.add_widget( textinput )
   
return [boxLayout, primaryInput]

Client code:

def tryToSetInitialFocus( self ):
       
if self.m_PrimaryInput:
           
print( "Will attempt on " + str( self.m_PrimaryInput ) )
           
self.m_PrimaryInput.focus = True
           
print( "Set focus ")
           
self.m_PrimaryInput = None



Output:

[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
Will attempt on <kivy.uix.textinput.TextInput object at 0x0401EC38>


(Dies horribly at this point, requiring manual shutdown of frozen app.)

The app also waits for a few hundred ms after widget creation before calling tryToSetInitialFocus(). I tried extending this on Windows, but it made no difference. As I say, it all works beautifully in Linux. Also makes no difference if I remove the focus binding. 

If I remove the call to tryToSetInitialFocus(), everything in the rest of the app works fine in Windows. It's the one piece of functionality I can't get working on it, requiring manual mouse click focusing on every new text input dialog. (It's happy for me to tab around subsequently.)



Reply all
Reply to author
Forward
0 new messages