CallBack function in C Libraries.

fiensproto at gmail.com fiensproto at gmail.com
Thu Mar 20 19:16:22 EDT 2014


Hello. I want to use a c library. It is a complete graphic widget set.

Here code working. But i have problem with the callback function. The callback is executed while ClikOnForm is executed but i get a error message (see after code )
____________________________________________________________________

file fpgui-test.py

from ctypes import*

def TheProc(c_int): fpgui.fpgFormWindowTitle(0, 'Boum')
return 0

CMPFUNC = CFUNCTYPE(c_int)

TheProcF = CMPFUNC(TheProc)

fpgui = cdll.LoadLibrary("fpgui-32.dll")

fpgui.fpgInitialize() fpgui.fpgSetStyle('Demo Style') fpgui.fpgFormCreate(0, -1) fpgui.fpgFormSetPosition(0, 300,100,400,200) fpgui.fpgFormWindowTitle(0, 'Hello world!')

fpgui.fpgFormOnClick(0,TheProcF)

fpgui.fpgButtonCreate(0,0,-1) ; fpgui.fpgButtonSetPosition(0,0, 15, 10 , 150 , 40) fpgui.fpgButtonSetText(0,0, 'BUTTON1')

fpgui.fpgButtonCreate(0,1,-1) ; fpgui.fpgButtonSetPosition(0,1, 15, 70 , 150, 40) fpgui.fpgButtonSetText(0,1, 'Clickme')

fpgui.fpgFormShow(0) fpgui.fpgRun()

Here the error message if i click on form :

Traceback (most recent call last): File "_ctypes/callbacks.c", line 314, in 'calling callback function' TypeError: TheProc() takes exactly 1 argument (0 given)

What is wrong ?

Many thanks.



More information about the Python-list mailing list