Re: CallBack function in C Libraries.

2014-03-21 Thread fiensproto
 I'm afraid it doesn't help that GoogleGroups has badly mangled the  
 
 formatting of your code.  I'm not quite sure what to suggest since it  
 
 isn't one of the usual problems, but you might find reading  
 
 https://wiki.python.org/moin/GoogleGroupsPython helpful.  It will  
 
 certainly help with the double-spacing in your quote above.

 Rhodri James *-* Wildebeest Herder to the Masses


Yep, Many thanks for help
Hum, i have find the solution, it was in CallBack function in help-doc.

= 

#file fpgui-test.py
from ctypes import*

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

def TheProcBut0():
fpgui.fpgButtonSetText(0,0, 'Boum also')
return 0 

def TheProcBut1():
fpgui.fpgButtonSetText(0,1, 'Boum too')
return 0 
 
CMPFUNC = CFUNCTYPE(c_int)

TheProcF = CMPFUNC(TheProc)
TheProcB0 = CMPFUNC(TheProcBut0)
TheProcB1 = CMPFUNC(TheProcBut1)

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.fpgButtonOnClick(0,0,TheProcB0) 

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

fpgui.fpgFormShow(0)
fpgui.fpgRun()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CallBack function in C Libraries.

2014-03-21 Thread Mark H Harris

On 3/21/14 7:02 AM, fienspr...@gmail.com wrote:

Yep, Many thanks for help
Hum, i have find the solution, it was in CallBack function in help-doc.


   No, it was not in the CallBack function in help-doc ...



def TheProc(): == you moved c_int from here ...
 fpgui.fpgFormWindowTitle(0, 'Boum')
 return 0


{snip}


CMPFUNC = CFUNCTYPE(c_int)    and placed it here ...

TheProcF = CMPFUNC(TheProc)== so that when you called TheProc ...



... it wasn't expecting exactly one parameter. So, your python 
traceback no longer warns about the parameter 'mismatch' in the defined 
function  TheProc().


   I'm not picking on you, but this error was obvious; as was it's 
solution, so I'm just wondering ?


Cheers

--
https://mail.python.org/mailman/listinfo/python-list


Re: CallBack function in C Libraries.

2014-03-21 Thread fiensproto
Le vendredi 21 mars 2014 16:50:18 UTC, Mark H. Harris a écrit :
  def TheProc(): == you moved c_int from here ...
 
   fpgui.fpgFormWindowTitle(0, 'Boum')
 
   return 0

  CMPFUNC = CFUNCTYPE(c_int)    and placed it here ...

 
 
 ... it wasn't expecting exactly one parameter. So, your python 
 
 traceback no longer warns about the parameter 'mismatch' in the defined 
 
 function  TheProc().
 
 
 
 I'm not picking on you, but this error was obvious; as was it's 
 
 solution, so I'm just wondering ?
 

Hello and thanks for answer.

Hum, i do not understand why, but the code is working ... ;-)

Some remarks :

 def TheProc():   
  fpgui.fpgFormWindowTitle(0, 'Boum')
  return 0== that does the trick...


And 

  CMPFUNC = CFUNCTYPE(c_int)    1 argument minimum..

It seems that CFUNCTYPE() want minimum 1 argument, even if TheProc() is a 
simple procedure, without argument...

Hum, it is my really first program in Python and im impressed how easy it was 
to do my Pascal (fpc) library work!
Im busy to try to do it work for java programs but it is not so easy.

By the way, is it possible to hide the terminal-window ?

That library is a complete graphic widget set (from Form to Stringgrid and 
more).
So, i will prefer that the console was hided...

And last question, how to retrieve the directory of the main Python application 
?

Many thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


CallBack function in C Libraries.

2014-03-20 Thread 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CallBack function in C Libraries.

2014-03-20 Thread Mark H Harris

On 3/20/14 6:16 PM, fienspr...@gmail.com wrote:


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
--
https://mail.python.org/mailman/listinfo/python-list


Re: CallBack function in C Libraries.

2014-03-20 Thread 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CallBack function in C Libraries.

2014-03-20 Thread 88888 Dihedral
On Friday, March 21, 2014 7:56:43 AM UTC+8, fiens...@gmail.com wrote:
  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.

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 .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CallBack function in C Libraries.

2014-03-20 Thread Rhodri James

On Thu, 20 Mar 2014 23:56:43 -, fienspr...@gmail.com wrote:


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 ?


In abstract, exactly the same thing that you would change if a C compiler  
had complained to you that you had failed to give a function call the  
right number of arguments.  More than that I have no idea; it's your code,  
presumably you know what it should be doing.  I have absolutely no idea  
how TheProc() is being called by your widgets.  Are you sure it should be  
declared as taking a single parameter?


I'm afraid it doesn't help that GoogleGroups has badly mangled the  
formatting of your code.  I'm not quite sure what to suggest since it  
isn't one of the usual problems, but you might find reading  
https://wiki.python.org/moin/GoogleGroupsPython helpful.  It will  
certainly help with the double-spacing in your quote above.


--
Rhodri James *-* Wildebeest Herder to the Masses
--
https://mail.python.org/mailman/listinfo/python-list