CallBack function in C Libraries.

F

fiensproto

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.
 
M

Mark H Harris

def TheProc(c_int): fpgui.fpgFormWindowTitle(0, 'Boum')
return 0
TheProcF = CMPFUNC(TheProc)
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 ?

You defined TheProc(c_init) to take exactly 1 argument.

But when you called it, you didn't provide the argument.

So, you got a traceback indicating that TheProc() takes exactly one
argument.

Give the function call its required argument and the error will go
away... well, at least that one.


Cheers
 
F

fiensproto

Give the function call its required argument and the error will go
away... well, at least that one.

Yep, many thanks for the answer.
But... im totally beginner with Python.
I develop in Pascal and C and want to understand the basics of Python.

In concrete, what must i change in the code ?

Many thanks.
 
8

88888 Dihedral

Yep, many thanks for the answer.

But... im totally beginner with Python.

I develop in Pascal and C and want to understand the basics of Python.



In concrete, what must i change in the code ?



Many thanks.

Python is a dynamical typed functional
language with OOP supports in the
revisons, and well suited in the
giga-byte dram capacity
personal toy era that can relplace
her mother lisp's unrealized AI
project .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top