How do I prompt for a username/password in a script?
#1
I'm working on a script what connects to a MySQL database. The current version of the script uses a XML config file to store the hostname, port, username and password.

Instead of having to edit the XML file, I'd like a way in the script to allow the user to enter that info.

I see that I could do a dialog to prompt for an IP address and a number, but I don't see any way to prompt for text input.

Am I overlooking something simple here?

Thanks, Brian
Reply
#2
http://passion-xbmc.org/gros_fichiers/XB...l#Keyboard
Reply
#3
Thanks! I'm still having to change my thinking from mouse oriented programming.

xbmc.Keyboard will do the trick for me.

Brian
Reply
#4
Exclamation 
Here is an example inspired from Nabbox script:

Login
Code:
# Read login via a keyboard
keyboard = xbmc.Keyboard("", heading = "Please type your login")
keyboard.setHeading('Login') # optional
keyboard.doModal()
if (keyboard.isConfirmed()):
    inputText = keyboard.getText()
    print"Login: %s"%inputText
    
    # set login
    self.Login = inputText
    
    dialogInfo = xbmcgui.Dialog()
    dialogInfo.ok("Login", "Your Login is:", "%s"%inputText)
del keyboard

Password
Code:
# Read Password via a keyboard
keyboard = xbmc.Keyboard("", heading = "Please type your password", hidden = True)
keyboard.setHeading('Password') # optional
keyboard.setHiddenInput(True) # optional
keyboard.doModal()
if (keyboard.isConfirmed()):
    inputText = keyboard.getText()
    
    # set password parameter
    self.Password = inputText
    
    dialogInfo = xbmcgui.Dialog()
    dialogInfo.ok("Password", "Your new password have been set")
keyboard.setHiddenInput(False) # optional
del keyboard

You will notice a small difference between the login and password cases, especially the hidden attribute which allow to hide the password on the screen while you type it.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply

Logout Mark Read Team Forum Stats Members Help
How do I prompt for a username/password in a script?0