Posts: 7
Joined: May 2016
Reputation:
0
Hi all,
I am using kodi android application. I am trying to add a button on the home screen with editbox for username and password fields. Means when user enters the correct username and password, the kodi app has to close.
For this I have used the Home.xml to add a button and used the ActivateWindow inbuilt function. With this I have the gui containing editbox and submit button. Now I want to write a code for the button press which will take a input from the two editboxes and compares it with available buffers. And Do the appropriate operation.
But I am not getting the location where to write the code in c++ and how to access the contents from the editboxes.
OR Is their any way to access the python code, if yes please tell me how? Please someone help me with this?
Posts: 7
Joined: May 2016
Reputation:
0
But when I use user = xbmcgui.Window(1234).getControl(501).getText(), the app is crashing.
I want to know the method by which I can read the input from the editbox. Please help me with this
Posts: 7
Joined: May 2016
Reputation:
0
Thanks for your reply. Even after splitting the command into two, the app is crashing.
Is their any way to avoid the app crash?
Posts: 1
Joined: May 2016
Reputation:
0
hey can you post the error if you can please?
Posts: 15,263
Joined: Jan 2009
Reputation:
727
ronie
Team-Kodi Member
Posts: 15,263
please post both your python code and your xml code.
i'll try to reproduce it if i can.
Posts: 7
Joined: May 2016
Reputation:
0
2016-06-02, 11:35
(This post was last modified: 2016-06-02, 11:41 by banana143.)
Thanks, I have solved the problem.
I am using the control edit box for password field.
With above method,How to accept the data in * form for password filed instead of text?
Posts: 7
Joined: May 2016
Reputation:
0
I have used the xbmcgui.ControlEdit with isPassword=1. But it is not reading the data inserted into the editbox. So I have used above method with xml file, instead of below method and it is reading input inserted into the editbox.
Please tell me the changes in the following code if any.
import xbmc
import xbmcaddon
import xbmcgui
addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')
ACTION_PREVIOUS_MENU = 10
class MyClass(xbmcgui.WindowDialog):
def __init__(self):
self.strActionInfo = xbmcgui.ControlLabel(100, 120, 200, 200, '', 'font13', '0xFFFF00FF')
self.addControl(self.strActionInfo)
self.strActionInfo.setLabel('Push BACK to quit')
self.name = xbmcgui.ControlEdit(530, 320, 400, 120, '', 'font13', '0xDD171717')
self.addControl(self.name)
self.pswd = xbmcgui.ControlEdit(530, 320, 400, 120, '', font='font16', textColor='0xDD171717', isPassword=1)
self.addControl(self.pswd)
self.button0 = xbmcgui.ControlButton(350, 500, 80, 30, "HELLO")
self.addControl(self.button0)
self.setFocus(self.button0)
self.setFocus(self.name)
self.name.setPosition(600, 320)
self.name.setWidth(400)
self.name_txt = ""
self.pswd_txt = ""
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
def onControl(self, control):
if control == self.button0:
self.name_txt = self.name.getText()
self.pswd_txt = self.pswd.getText()
#self.message(self.name)
def message(self, message):
dialog = xbmcgui.Dialog()
dialog.ok(" My message title", message)
mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
Posts: 15,263
Joined: Jan 2009
Reputation:
727
ronie
Team-Kodi Member
Posts: 15,263
i've tested your code and it works ok here.
perhaps your indenting is messed up?
Posts: 7
Joined: May 2016
Reputation:
0
How did you tested my code? When I run the above code, I have the GUI but I will not be able to enter any text inside the textbox. Can you please tell me the changes in this code so that it should read input from user?
Posts: 15,263
Joined: Jan 2009
Reputation:
727
ronie
Team-Kodi Member
Posts: 15,263
i didn't modify the code. just click on a textbox and the keyboard dialog pops up.