button connection problem
#1
Lightbulb 
Hi there, i'm new at addon programming and even at python programming.

I'm doing a addon that is a GUI using pyxbmct that will launch other python script by pressing buttons.

I've been able to create my GUI but the only problem is that the addon doesn't wait that I press the button to call my other python file and call it right away when the addon start.

Here is my default.py script, please can someone help me with this issue.
thank you

What I'm trying to do is launch the file allume.py witch is in ./python/ by pressing on the button1.


# Import PyXBMCt module.
import pyxbmct.addonwindow as pyxbmct
import os
import xbmc
import xbmcaddon
from subprocess import call
_addon = xbmcaddon.Addon()
_addon_path = _addon.getAddonInfo('path')


class MyWindow(pyxbmct.AddonDialogWindow):

def __init__(self, title=''):
# You need to call base class' constructor.
super(MyWindow, self).__init__(title)
# Set the window width, height and the grid resolution: 8 rows, 8 columns.
self.setGeometry(600, 400, 8, 8)
# Create a text label.
label = pyxbmct.Label('Pieces', alignment=pyxbmct.ALIGN_CENTER)
# Place the label on the window grid.
self.placeControl(label, 0, 1, columnspan=3)
# Image
self.image = pyxbmct.Image(os.path.join(_addon_path, 'salon.png'))
self.placeControl(self.image, 1, 1, 3, 3)

# Create a button.
button1 = pyxbmct.Button('On/Off')
# Place the button on the window grid.
self.placeControl(button1, 4, 1, 1, 3)
# Connect the button to a function.
self.connect(button1, call(["python","./python/allume.py"]))


# Create an exit button.
button = pyxbmct.Button('Fermer')
# Place the button on the window grid.
self.placeControl(button, 7, 5, 1, 3)
# Connect the button to a function.
self.connect(button, self.close)


# Create a window instance.
window = MyWindow('Controle des lumieres')
# Show the created window.
window.doModal()
# Delete the window instance when it is no longer used.
del window
Reply

Logout Mark Read Team Forum Stats Members Help
button connection problem0