Q:

QGIS custom forms using python logic

I use QGIS and I want to work with custom forms using python logic and I try to follow this manual.  In my custom qu I add one new pushButton and I want for example for educations rules to open some image.  But that dont work dont show me anything,any idea where I have wrong in my python code ?
Here the python code :
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import os
from PyQt4.QtGui import QWidget

nameField = None
myDialog = None
def my_form_open(dialog, layer, feature):
    geom = feature.geometry()
    control = dialog.findChild(QWidget, "MyLineEdit")
    global myDialog
    myDialog = dialog
    global nameField
    nameField = dialog.findChild(QLineEdit,"Name")
    buttonBox = dialog.findChild(QDialogButtonBox,"buttonBox")
    pushButton = dialog.findChild(QPushButton,"pushButton")

    # Disconnect the signal that QGIS has wired up for the dialog to the button box.
    pushButton.accepted.disconnect(myDialog.accept)

    # Wire up our own signals.
    pushButton.accepted.connect(validate)

def validate():
    filename='C:/Users/username/Desktop/image.jpg'
    os.startfile(filename)

A:

I think you want to use pushButton.clicked  rather and pushButton.accepted.

