self.getControl - TypeError:Non-Existent Control
#1
I want to set the label text of a control when i display the window.
I use the following code:
PHP Code:
ctrl self.getControl(5
But this gives me this error:
TypeError:Non-Existent Control 5

in my windowxml file i have a label control with id="5":
[HTML]
<control type="label" id="5">
<animation effect="slide" start="600,0" end="0,0" time="200">WindowOpen</animation>
<animation effect="slide" start="0,0" end="600,0" time="200">WindowClose</animation>
<description>Feed Label</description>
<width>427</width>
<posx>244</posx>
<posy>70</posy>
<align>center</align>
<aligny>center</aligny>
<label>Feeds loading...</label>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
</control>
[/HTML]
Does anyone know why this does not work.

I am trying to show an info dialog when pressing a listitem, so i use windowxml to create a custom dialog (dialog.yesno, dialog.ok is not good for me, no multiple lines)
Is this the right way?

thanks in advance
Reply
#2
Perhaps you're requesting the control prior to it being setup?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
I don't think that is the case.
Here is the full code of my problem. Hopefully someone can help me with this Smile
PHP Code:
import os
import pickle
import sys
import traceback
import xbmcgui
import xbmc
import random
import string
import re

class YouTubeGUI(xbmcgui.WindowXML):
        
id_obj ''
        
def setObj(self,val):
              
self.id_obj val
              ctrl 
self.getControl(5)
              
pass
    def onInit
(self):
        
pass 


base_path 
os.getcwd()        

YouTubeGUI("details.xml"base_path"DefaultSkin")
w.setObj(1)
w.doModal()
del w 
Reply
#4
The control isn't created until doModal() is called would be my guess. I'm sure one of the more experienced scripters can confirm this. You should do any such processing in the onInit callback.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
second try:

PHP Code:
class YouTubeGUI(xbmcgui.WindowXML):
    
def onInit(self):
                
ctrl xbmcgui.getControl(1)
                
ctrl.setLabel "david"
                
print "ja"
                
pass
        def testfunctie
():
                
ctrl xbmcgui.getControl(1)
                
ctrl.setLabel "david"
                
print "ja2"

base_path os.getcwd()        

YouTubeGUI("testje.xml"base_path"DefaultSkin")
#w.setObj(1)
w.doModal()
w.testfunctie()
del w 

neither print "ja" or print "ja2" is being executed...

Is there someone who can give me a working example of this:

Showing listitems, when clicking a listitem show a dialog (with labels and textboxes (multiple lines) + yes no button.
On cancel return to list.

This is what i am trying to do. I need getControl to set the textbox value/ labels etc

thanks
Reply
#6
i finally got it working using the code below:

PHP Code:
class MyFirstWinXML(xbmcgui.WindowXMLDialog):
    
def __init__(self,strXMLnamestrFallbackPathstrDefaultNameforceFallback):
        
# Changing the three varibles passed won't change, anything
        # Doing strXMLname = "bah.xml" will not change anything.
        # don't put GUI sensitive stuff here (as the xml hasn't been read yet
        # Idea to initialize your variables here
        
pass
 
    def onInit
(self):
        
# Put your List Populating code/ and GUI startup stuff here
        
pass 
 
    def onAction
(selfaction):
        
# Same as normal python Windows.
        
if action == ACTION_PREVIOUS_MENU:
                
self.close()
    
def onClick(selfcontrolID):
        
"""
            Notice: onClick not onControl
            Notice: it gives the ID of the control not the control object
        """
        
pass
 
    def onFocus
(selfcontrolID):
        
pass

base_path 
os.getcwd()        

tbd MyFirstWinXML("details.xml"base_path"DefaultSkin"0)
tbd.doModal()
del tdb 

But i still have the following problem. I cannot close the window. This is what the xbmc.log says about the onAction def:

ERROR: Exception in python script's onAction
Reply

Logout Mark Read Team Forum Stats Members Help
self.getControl - TypeError:Non-Existent Control0