Thanks for your quick reply!
As you can see in the code, there are TWO buttons: one hello and one close button. both of them dont work. Look at the code I posted, i promise by my mothers life, there are two buttons..
I used
this code from your doc
One further problem:
As playing around a little more, i added a discrete running thread, which should update the text of a label in the gui. The update works, but it seems to "overwrite" the label in graphics without clearing the previous content, so there is a mashup with all the updated texts. Is it possible to "clear" a control?
My actual code:
Code:
class MyAddon(pyxbmct.BlankFullWindow):
def __init__(self):
"""Class constructor"""
# Call the base class' constructor.
super(MyAddon, self).__init__()
# Set width, height and the grid parameters
self.setGeometry(300, 330, 5, 2)
# Call set controls method
self.set_controls()
# Call set navigation method.
self.set_navigation()
# Connect Backspace button to close our addon.
self.connect(pyxbmct.ACTION_NAV_BACK, self.close)
def set_controls(self):
"""Set up UI controls"""
# Image control
image = pyxbmct.Image(os.path.join(_addon_path, 'xbmc-logo.png'), aspectRatio=0, colorDiffuse='0xF0FFF0F0')
self.placeControl(image, 0, 0, rowspan=2, columnspan=2)
# Text label
label = pyxbmct.Label('Your name:')
self.placeControl(label, 2, 0)
# Text label
self.label2 = pyxbmct.Label('Counter')
self.placeControl(self.label2, 5, 0, columnspan=2)
# Text edit control
self.name_field = pyxbmct.Edit('')
self.placeControl(self.name_field, 2, 1)
# Close button
self.close_button = pyxbmct.Button('Close')
self.placeControl(self.close_button, 3, 0)
# Connect close button
self.connect(self.close_button, self.close)
# Hello button.
self.hello_buton = pyxbmct.Button('Hello')
self.placeControl(self.hello_buton, 3, 1)
# Connect Hello button.
self.connect(self.hello_buton, lambda:
xbmc.executebuiltin('Notification(Hello {0}!, Welcome to PyXBMCt.)'.format(
self.name_field.getText())))
def set_navigation(self):
"""Set up keyboard/remote navigation between controls."""
self.name_field.controlUp(self.hello_buton)
self.name_field.controlDown(self.hello_buton)
self.close_button.controlLeft(self.hello_buton)
self.close_button.controlRight(self.hello_buton)
self.hello_buton.setNavigation(self.name_field, self.name_field, self.close_button, self.close_button)
# Set initial focus.
self.setFocus(self.name_field)
class BackgroundTask(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
i = 0
while 1:
i += 1
gui.label2 = pyxbmct.Label("Counter: %s" %i)
gui.placeControl(gui.label2, 5, 0, columnspan=2)
xbmc.log("counter: %s" %i)
time.sle*p(1)
if __name__ == '__main__':
gui = MyAddon()
bgthread = BackgroundTask()
bgthread.start()
gui.doModal()
del gui
i have seen, that following message is in the logfile:
Code:
16:09:59 T:140716885931776 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.AttributeError'>
Error Contents: 'MyAddon' object has no attribute 'window_close_button'
Traceback (most recent call last):
File "/home/hal/.kodi/addons/script.module.pyxbmct/lib/pyxbmct/addonwindow.py", line 755, in onControl
if control == self.window_close_button:
AttributeError: 'MyAddon' object has no attribute 'window_close_button'
-->End of Python script error report<--