How best to handle SystemError in ctypes callback

2022-01-05 Thread Jarrod G
With the following code: import ctypes > import readline > from ctypes.util import find_library > > rl = ctypes.cdll.LoadLibrary(find_library('readline')) > > rl_redisplay = rl.rl_redisplay > rl_redisplay.restype = None > rl_redisplay.argtypes = None > > rl_redisplay_function = ctypes.c_void_p.in_

Re: c bindings with non-python thread callback while python exits

2021-01-26 Thread Barry Scott
ing is > running. However, when the program terminates normally and there happens to > be one last callback underway, the c bindings hang. When viewed with GDB, I > can see that the callback thread callstack looks like this: > > futex_abstimed_wait_cancelable() > _pthread_cond

c bindings with non-python thread callback while python exits

2021-01-26 Thread Paul Grinberg
ience): PyGILState_STATE gstate; gstate = PyGILState_Ensure(); PyObject_CallObject(cb, arglist); PyGILState_Release(gstate); This works perfectly while the python program using this c binding is running. However, when the program terminates normally and there happens to be one last callback underway,

Binding menu accelerator to a callback

2021-01-12 Thread Rich Shepard
Menu options work from the menu, but not from the accelerator associated with that menu item. My research suggests that while 'command' works for the menu item, 'bind' is required for the associated accelerator. For example, File -> Quit is defined this way: self.file_menu.add_command(

Re: Fwd: How to specify JSON parameters in CallBack?

2020-12-13 Thread Chris Angelico
On Mon, Dec 14, 2020 at 4:57 AM Ethan Furman wrote: > > From: Caleb Gattegno > Date: Fri, Dec 11, 2020 at 5:02 PM > Subject: How to specify JSON parameters in CallBack? > > > Please can you suggest where should I look for advice on converting a old > style web app which v

Fwd: Fwd: How to specify JSON parameters in CallBack?

2020-12-13 Thread Ethan Furman
From: Caleb Gattegno Date: Fri, Dec 11, 2020 at 5:02 PM Subject: How to specify JSON parameters in CallBack? Please can you suggest where should I look for advice on converting a old style web app which vends whole pages of html with a cgi-bin/python script invoked bypython3 server.py, into

question on callback functions with ctypes

2020-06-20 Thread oyster
question on callback functions with ctypes I try to use GoVCL( https://github.com/ying32/govcl ) in python via ctypes. GoVCL supplies C header and simple C demo under https://github.com/ying32/govcl/tree/master/Tools/makeCHeader/test Now the simple python code can run on both win7 and win10

Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Abdur-Rahmaan Janhangeer
alues to the names "i" and "icon". > On the last line you create a lambda, an anonymous function, which you > pass as the command callback for the button. Of course, no code inside the > lambda is actually executed at this point. It is only after the entire for > loop h

Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Abdur-Rahmaan Janhangeer
excuses for typos! -- https://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Calvin Spealman
quot;i" and "icon". On the last line you create a lambda, an anonymous function, which you pass as the command callback for the button. Of course, no code inside the lambda is actually executed at this point. It is only after the entire for loop has completed, later when the user sees

Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-07 Thread Abdur-Rahmaan Janhangeer
erent names are written on the gui just the callback is takest the newest icon object for all three buttons I know just a reference issue but it's been **bugging** me. Thanks All -- Abdur-Rahmaan Janhangeer Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: Cannot pass a variable given from url to route's callback fucntion and redirect issue

2018-08-30 Thread Rurpy via Python-list
On Thursday, August 30, 2018 at 10:08:34 AM UTC-6, Νίκος Βέργος wrote: > I did try it with 'None' and as page='index.html' Flask return an error both > ways (while bottle framework does not) I think you are mistaken, making the change I suggested fixes the "TypeError: index() missing 1 required p

Re: Cannot pass a variable given from url to route's callback fucntion and redirect issue

2018-08-30 Thread Rurpy via Python-list
e user clicks on the images within the html > tamplate, to pass those variables value to '/' route so to perfrom then asome > action with those values > > The error iam receiving is this: > === > builtins.TypeError > TypeError: index() missing 1 required positional arg

Re: Python call c pass a callback function on Linux

2018-01-24 Thread Jason Qian via Python-list
HI Dennis, Thanks for the help, After changing WINFUNCTYPE to CFUNCTYPE, the call back function works on the Linux :) Thanks again, Jason On Wed, Jan 24, 2018 at 6:15 PM, Dennis Lee Bieber wrote: > On Wed, 24 Jan 2018 17:16:22 -0500, Jason Qian via Python-list > declaimed the foll

Re: Python call c pass a callback function on Linux

2018-01-24 Thread Chris Angelico
On Thu, Jan 25, 2018 at 9:16 AM, Jason Qian via Python-list wrote: > Hi, > > I have following code that works fine on windows. > > InvocationCB=WINFUNCTYPE(None, c_char_p, c_int) > submit = lib.submit > submit.argtypes = [ctypes.c_void_p, c_void_p,InvocationCB] > submit.restype = ctypes.c_int >

Python call c pass a callback function on Linux

2018-01-24 Thread Jason Qian via Python-list
Hi, I have following code that works fine on windows. InvocationCB=WINFUNCTYPE(None, c_char_p, c_int) submit = lib.submit submit.argtypes = [ctypes.c_void_p, c_void_p,InvocationCB] submit.restype = ctypes.c_int def handleResponse(message, code): print('--- handleResponse ---') prin

Re: Return str to a callback raise a segfault if used in string formating

2017-10-15 Thread dieter
Vincent Vande Vyvre writes: > Le 14/10/17 à 15:59, Stefan Behnel a écrit : > ... > Thanks, I know Cython but the code is already in C. > > This is a lib released as a frontend.  Then usable only in command line. This does not prevent the use of "Cython". In fact, one of its use cases is the creat

Re: Return str to a callback raise a segfault if used in string formating

2017-10-14 Thread Paul Moore
On 14 October 2017 at 16:06, Vincent Vande Vyvre wrote: > I think I've found the problem, the string (a file path) is modified in c > with "sprintf, snprintf, ..." And I plan to change that with some CPython > equivalent function. Nice :-) Glad you found it. Paul -- https://mail.python.org/mailm

Re: Return str to a callback raise a segfault if used in string formating

2017-10-14 Thread Vincent Vande Vyvre
Le 14/10/17 à 15:59, Stefan Behnel a écrit : Vincent Vande Vyvre schrieb am 13.10.2017 um 13:18: Le 13/10/17 à 12:39, Paul Moore a écrit : As a specific suggestion, I assume the name of the created file is a string object constructed in the C extension code, somehow. The fact that you're gettin

Re: Return str to a callback raise a segfault if used in string formating

2017-10-14 Thread Stefan Behnel
Vincent Vande Vyvre schrieb am 13.10.2017 um 13:18: > Le 13/10/17 à 12:39, Paul Moore a écrit : >> As a specific suggestion, I assume the name of the created file is a >> string object constructed in the C extension code, somehow. The fact >> that you're getting the segfault with some uses of that

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread dieter
Thomas Jollans writes: > On 2017-10-13 11:07, Vincent Vande Vyvre wrote: >> Le 13/10/17 à 09:23, Chris Angelico a écrit : >>> On Fri, Oct 13, 2017 at 4:46 PM, Vincent Vande Vyvre > ... > If you have custom C code, it's likely that there is a memory management > problem there. It's not unusual for

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Paul Moore
On 13 October 2017 at 12:18, Vincent Vande Vyvre wrote: > Le 13/10/17 à 12:39, Paul Moore a écrit : >> >> As a specific suggestion, I assume the name of the created file is a >> string object constructed in the C extension code, somehow. The fact >> that you're getting the segfault with some uses

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Vincent Vande Vyvre
Le 13/10/17 à 12:39, Paul Moore a écrit : As a specific suggestion, I assume the name of the created file is a string object constructed in the C extension code, somehow. The fact that you're getting the segfault with some uses of that string (specifically, passing it to %-formatting) suggests th

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Paul Moore
As a specific suggestion, I assume the name of the created file is a string object constructed in the C extension code, somehow. The fact that you're getting the segfault with some uses of that string (specifically, passing it to %-formatting) suggests that there's a bug in the C code that construc

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Thomas Jollans
On 2017-10-13 11:07, Vincent Vande Vyvre wrote: > Le 13/10/17 à 09:23, Chris Angelico a écrit : >> On Fri, Oct 13, 2017 at 4:46 PM, Vincent Vande Vyvre >> wrote: >>> Simplified code: >>> >>> ---%<-- >>> ... >>> ---%<--

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Vincent Vande Vyvre
Le 13/10/17 à 09:23, Chris Angelico a écrit : On Fri, Oct 13, 2017 at 4:46 PM, Vincent Vande Vyvre wrote: Simplified code: ---%<-- ... ---%<-- If I place self.callback() at the end of the func process that doesn't

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Chris Angelico
ult on disk with a new name > self.out_filename.write(.) > > def run_multitasks(self): > while self.tasks: > t = Thread(target=process, args=self.tasks.pop(0)) > t.start() > t.join() > self.callback(self.out_f

Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Vincent Vande Vyvre
sks:     t = Thread(target=process, args=self.tasks.pop(0))     t.start()     t.join()     self.callback(self.out_filename)     def add_task(self, fname, callback):     self.tasks.append(fname)     self.callback = callback     if len(self.tasks) =

RE: Issue with ctypes and callback functions

2016-08-14 Thread Bill Somerville
-Original Message- From: Bill Somerville Sent: 04 August 2016 18:23 To: 'eryk sun' ; python-list@python.org Subject: RE: Issue with ctypes and callback functions -Original Message- From: eryk sun [mailto:eryk...@gmail.com] from_param is a hook method for a type that&

RE: Issue with ctypes and callback functions

2016-08-04 Thread Bill Somerville
IG. Does it provide some means to instantiate a wrapped type from an address? If it does, then you can use a void pointer as the callback parameter. Hi Eryk, Thanks for looking at this. I had got as far as looking at the code above and guessed that only ctypes types were supported. This does

Re: Issue with ctypes and callback functions

2016-08-03 Thread eryk sun
of having the Python callback (my_cb) > magically > receive the SWIG wrapped 'my_type' struct. from_param is a hook method for a type that's set in a function pointer's argtypes. It gets called to convert an argument when the function pointer is called from Python. The return va

RE: Issue with ctypes and callback functions

2016-08-03 Thread Bill Somerville
-Original Message- From: eryk sun [mailto:eryk...@gmail.com] Sent: 03 August 2016 13:16 To: python-list@python.org Cc: Bill Somerville Subject: Re: Issue with ctypes and callback functions On Wed, Aug 3, 2016 at 9:38 AM, Bill Somerville wrote: > > Is this a good place to ask que

Re: Issue with ctypes and callback functions

2016-08-03 Thread eryk sun
On Wed, Aug 3, 2016 at 9:38 AM, Bill Somerville wrote: > > Is this a good place to ask questions about the above? Discussing ctypes is fine here. There's also a ctypes-users list. -- https://mail.python.org/mailman/listinfo/python-list

Issue with ctypes and callback functions

2016-08-03 Thread Bill Somerville
Hi All, Is this a good place to ask questions about the above? Regards Bill. -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about code writing '% i, callback'

2015-12-01 Thread Ian Kelly
On Mon, Nov 30, 2015 at 7:44 PM, Dennis Lee Bieber wrote: > On Mon, 30 Nov 2015 10:55:23 -0800 (PST), fl declaimed > the following: > >>Thanks Ian. I created the class because I want to use the original example >>line >> >> UI.Button("button %s" % i,

Re: Question about code writing '% i, callback'

2015-11-30 Thread fl
On Monday, November 30, 2015 at 12:02:57 PM UTC-5, Ian wrote: > On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: > > I come across the following code snippet. > > > > for i in range(10): > > def callback(): > > print "clicked button", i

Re: Question about code writing '% i, callback'

2015-11-30 Thread Ian Kelly
callbackk() > return > UI=buibutton() > > > for i in range(10): > def callback(): > print "clicked button", i > UI.Button("button %s" % i, callback) > > > To my surprise, the output is not the original link expected. i.e. it is &

Re: Question about code writing '% i, callback'

2015-11-30 Thread fl
On Monday, November 30, 2015 at 12:37:52 PM UTC-5, Terry Reedy wrote: > On 11/30/2015 11:44 AM, fl wrote: > > > I come across the following code snippet. > > > for i in range(10): > > def callback(): > > print "clicked button", i &

Re: Question about code writing '% i, callback'

2015-11-30 Thread fl
On Monday, November 30, 2015 at 11:44:44 AM UTC-5, fl wrote: > Hi, > > I come across the following code snippet. > > > > > > for i in range(10): > def callback(): > print "clicked button", i > UI.Button("button %s" % i

Re: Question about code writing '% i, callback'

2015-11-30 Thread Terry Reedy
On 11/30/2015 11:44 AM, fl wrote: I come across the following code snippet. for i in range(10): def callback(): print "clicked button", i UI.Button("button %s" % i, callback) http://effbot.org/zone/default-values.htm Note that the above is an in

Re: Question about code writing '% i, callback'

2015-11-30 Thread Ian Kelly
On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: > I come across the following code snippet. > > for i in range(10): > def callback(): > print "clicked button", i > UI.Button("button %s" % i, callback) > > The content inside parenthesis i

Re: Question about code writing '% i, callback'

2015-11-30 Thread Zachary Ware
On Mon, Nov 30, 2015 at 10:53 AM, Zachary Ware wrote: > On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: >> The content inside parenthesis in last line is strange to me. >> >> "button %s" % i, callback > > https://docs.python.org/library/stdtypes.html#printf-s

Re: Question about code writing '% i, callback'

2015-11-30 Thread Zachary Ware
On Mon, Nov 30, 2015 at 10:44 AM, fl wrote: > The content inside parenthesis in last line is strange to me. > > "button %s" % i, callback https://docs.python.org/library/stdtypes.html#printf-style-string-formatting -- Zach -- https://mail.python.org/mailman/listinfo/python-list

Question about code writing '% i, callback'

2015-11-30 Thread fl
Hi, I come across the following code snippet. for i in range(10): def callback(): print "clicked button", i UI.Button("button %s" % i, callback) The content inside parenthesis in last line is strange to me. "button %s" % i, callback T

Re: Embedded Python and C Callback functions

2015-06-07 Thread dieter
; > } > > it tries to PyINCREF to my passed callback. This indicates that it expects the "callback" to be a Python object. Check the C-API specification. It should tell you which parameters are expected to be Python objects and which C objects. -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedded Python and C Callback functions

2015-06-07 Thread Stefan Behnel
doc.mefi...@gmail.com schrieb am 07.06.2015 um 10:56: > And I can't use Cython, because I have C++ module, and I have to use it. That's not a valid reason. Cython supports C++ code just fine. http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html Stefan -- https://mail.python.org/mailma

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
> >And I can't use Cython, because I have C++ module, and I have to use it. > >-- > >https://mail.python.org/mailman/listinfo/python-list > > Are you using Boost? > http://www.boost.org/doc/libs/1_58_0/libs/python/doc/ > > It handles lots of the setup for you. > > Laura No, I'm not using Boost

Re: Embedded Python and C Callback functions

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 01:56:47 -0700, doc.mefi...@gmail.com writes: >And I can't use Cython, because I have C++ module, and I have to use it. >-- >https://mail.python.org/mailman/listinfo/python-list Are you using Boost? http://www.boost.org/doc/libs/1_58_0/libs/python/doc/ It handles

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
I'm trying to debug and find my error. It goes wrong when: PyObject *v; v = va_arg(*p_va, PyObject *); if (v != NULL) { if (*(*p_format - 1) != 'N') Py_INCREF(v); } it tries to PyINCREF to my passed call

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
And I can't use Cython, because I have C++ module, and I have to use it. -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedded Python and C Callback functions

2015-06-07 Thread doc . mefisto
No, myclass is not null. I think my style of passing arguments is wrong. -- https://mail.python.org/mailman/listinfo/python-list

Re: Embedded Python and C Callback functions

2015-06-06 Thread dieter
doc.mefi...@gmail.com writes: > Hi. I'm a newbie in python. But I want embed it in my C program. > > There is such method of my class: > @staticmethod > def install_instr_callback(callback): > # set hook for every change of PC > m68k.set_instr_hook_callback(call

Embedded Python and C Callback functions

2015-06-06 Thread doc . mefisto
Hi. I'm a newbie in python. But I want embed it in my C program. There is such method of my class: @staticmethod def install_instr_callback(callback): # set hook for every change of PC m68k.set_instr_hook_callback(callback) And in my C code there is such callback function: s

Re: Threading: execute a callback function in the parent thread

2015-03-20 Thread Ian Kelly
On Fri, Mar 20, 2015 at 11:29 AM, wrote: > Hi everyone, > > just like the title says I'm searching for a mechanism which allows to call a > callback function from a thread, being the callback executed in the parent > thread (it can also be the main thread). I'm basica

Threading: execute a callback function in the parent thread

2015-03-20 Thread massi_srb
Hi everyone, just like the title says I'm searching for a mechanism which allows to call a callback function from a thread, being the callback executed in the parent thread (it can also be the main thread). I'm basically looking for something like the CallAfter method of the wx or

Re: Callback functions arguments

2014-10-28 Thread ast
e to be called every time the slider is moved. This procedure will be passed one argument, the new scale value. If the slider is moved rapidly, you may not get a callback for every possible position, but you'll certainly get a callback when it settles Command on Spinbox widget A procedure

Re: Callback functions arguments

2014-10-28 Thread Chris Angelico
On Tue, Oct 28, 2014 at 6:35 PM, ast wrote: > OK, but i still find very strange the choice of Python's designers to > make the Scale behaves like that. That's nothing to do with Python's design. That's all about Tkinter, which presumably is imitating Tk. Python allows t

Re: Callback functions arguments

2014-10-28 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.15231.1414399974.18130.python-l...@python.org... Tanks for you answer Python doesn't "know" it has to pass an argument, it just does it. Change the callback to def maj(): print(&quo

Re: Callback functions arguments

2014-10-27 Thread Jean-Michel Pichavant
- Original Message - > From: "ast" > To: python-list@python.org > Sent: Monday, 27 October, 2014 9:16:26 AM > Subject: Callback functions arguments > > Hi > > In this web site at example n°5 > http://fsincere.free.fr/isn/python/cours_python_tkinter.p

Re: Callback functions arguments

2014-10-27 Thread Peter Otten
afenetre, from_=-100, to=100, resolution=10, \ > orient=HORIZONTAL, length=300, width=20, label="Offset", \ > tickinterval=20, variable=Valeur, command=maj) > > The "maj" callback function is: > > def maj(nouvelleValeur): > print(nouvelleValeur) &g

Callback functions arguments

2014-10-27 Thread ast
length=300, width=20, label="Offset", \ tickinterval=20, variable=Valeur, command=maj) The "maj" callback function is: def maj(nouvelleValeur): print(nouvelleValeur) When the user move the scale with the mouse, the new position is supposed to be printed on the python she

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-25 Thread Chris Angelico
her down the stack and harder to isolate from the lock, > although I would argue that's probably a code smell. I'd definitely call it code smell. What happens with this? with lock: def inner(): do_more_work() f.add_done_callback(inner) The lock's possibly released

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-25 Thread Ian Kelly
On Thu, Sep 25, 2014 at 8:47 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Thu, Sep 25, 2014 at 3:46 AM, Marko Rauhamaa wrote: >>> Example (pseudocode): >>> >>>def callback(self): >>> with self.lock: >>>

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-25 Thread Marko Rauhamaa
Ian Kelly : > On Thu, Sep 25, 2014 at 3:46 AM, Marko Rauhamaa wrote: >> Example (pseudocode): >> >>def callback(self): >> with self.lock: >> ... >> >>def xyz(self, f): >> with self.lock: >> ... >&

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-25 Thread Ian Kelly
> > There should be a guarantee that the callback is not called from the > same thread before returning from Future.add_done_callback. Otherwise, > the caller may have a really difficult time handling preemption and > avoiding deadlocks at the same time. > > Example (p

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-25 Thread Marko Rauhamaa
Ian Kelly : > The documentation for Future.add_done_callback says: "If the future > has already completed or been cancelled, fn will be called > immediately." That sounds really bad. There should be a guarantee that the callback is not called from the same thread be

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-24 Thread Ian Kelly
On Wed, Sep 24, 2014 at 8:44 AM, Praveen Gollakota wrote: > However, it seemed to fail when I removed the `time.sleep(random.random())` > statements, i.e. at least a few `func` functions and `callbacks` **did not** > run in the same thread. > > For a project that I am working o

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-24 Thread dieter
Praveen Gollakota writes: > In the ThreadPoolExecutor (TPE), is the callback always guaranteed to run in > the same thread as the submitted function? To answer question of this type (yourself), you may look at the relevant source code. I am quite sure that the "submitted functi

ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

2014-09-24 Thread Praveen Gollakota
Hello, In the ThreadPoolExecutor (TPE), is the callback always guaranteed to run in the same thread as the submitted function? For example, I tested this with the following code. I ran it many times and it seemed like `func` and `callback` always ran in the same thread. import

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 wa

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(): <== yo

Re: CallBack function in C Libraries.

2014-03-21 Thread fiensproto
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

Re: CallBack function in C Libraries.

2014-03-20 Thread Rhodri James
On Thu, 20 Mar 2014 23:56:43 -, 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 c

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 Pa

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 ?

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' TypeEr

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

Re: Help with implementing callback functions using ctypes

2013-05-26 Thread Dan Stromberg
On Sun, May 26, 2013 at 9:12 AM, Shriramana Sharma wrote: > On Friday, May 24, 2013 8:56:28 AM UTC+5:30, Dan Stromberg wrote: > > Cython is good. So is the new cffi, which might be thought of as a > > safer (API-level) version of ctypes (which is ABI-level). > > Hi -- can you clarify what is this

RE: Help with implementing callback functions using ctypes

2013-05-26 Thread Carlos Nepomuceno
https://cffi.readthedocs.org/en/release-0.6/ > Date: Sun, 26 May 2013 09:12:10 -0700 > Subject: Re: Help with implementing callback functions using ctypes > From: samj...@gmail.com > To: python-list@python.org > > On Friday, May 24, 201

Re: Help with implementing callback functions using ctypes

2013-05-26 Thread Shriramana Sharma
On Friday, May 24, 2013 8:56:28 AM UTC+5:30, Dan Stromberg wrote: > Cython is good. So is the new cffi, which might be thought of as a > safer (API-level) version of ctypes (which is ABI-level). Hi -- can you clarify what is this new CFFI and where I can get it? In the Python 3 library reference

Re: Help with implementing callback functions using ctypes

2013-05-23 Thread Dan Stromberg
On Wed, May 8, 2013 at 10:54 PM, dieter wrote: > jamadagni writes: > > ... > I cannot help you with "ctypes". But, if you might be able to use > "cython", then calling callbacks is not too difficult > (you can find an example in e.g. my "dm.xmlsec.binding"). > > Note, however, that properly hand

Re: Help with implementing callback functions using ctypes

2013-05-23 Thread jamadagni
r than where Python's control goes? If I had seen this post I might not have even spent time on Cython. (For some reason Google Groups doesn't send me email updates even if I ask it to.) Using CTYpes I was able to implement a callback with less coding (for this particular requirement) than

Re: Help with implementing callback functions using ctypes

2013-05-09 Thread Nobody
using ctypes. However it would seem that the first call to the > callback results in a segfault. > # call the C function > spiro_to_bezier_strict ( src, len ( src ), bc ) This line should be: spiro_to_bezier_strict ( src, len ( src ), byref(bc) ) Without the byref(...), it will try

Re: Help with implementing callback functions using ctypes

2013-05-09 Thread Stefan Behnel
elps in debugging crashes like this one. http://docs.cython.org/src/userguide/debugging.html > (you can find an example in e.g. my "dm.xmlsec.binding"). An "official" example is here: https://github.com/cython/cython/tree/master/Demos/callback > Note, however, that prop

Re: Help with implementing callback functions using ctypes

2013-05-08 Thread dieter
jamadagni writes: > ... I cannot help you with "ctypes". But, if you might be able to use "cython", then calling callbacks is not too difficult (you can find an example in e.g. my "dm.xmlsec.binding"). Note, however, that properly handling the GIL ("Global Interpreter Lock") may be of great impor

Help with implementing callback functions using ctypes

2013-05-08 Thread jamadagni
ython script spiro.py using ctypes. However it would seem that the first call to the callback results in a segfault. (The line before the callback is executed.) I tried debugging using gdb but perhaps because of my insufficient knowledge I couldn't find out what is causing the problem. I

Re: ctypes callback with char array

2012-06-02 Thread Diez B. Roggisch
ohlfsen writes: > Hello. > > Hoping that someone can shed some light on a tiny challenge of mine. > > Through ctypes I'm calling a c DLL which requires me to implement a callback > in Python/ctypes. > > The signature of the callback is something like > > void

ctypes callback with char array

2012-05-30 Thread ohlfsen
Hello. Hoping that someone can shed some light on a tiny challenge of mine. Through ctypes I'm calling a c DLL which requires me to implement a callback in Python/ctypes. The signature of the callback is something like void foo(int NoOfElements, char Elements[][100]) How do I pos

Re: Debug python from DLL callback?

2011-11-30 Thread Fabio Zadrozny
On Wed, Nov 30, 2011 at 7:34 AM, Jason Veldicott wrote: > Hi, > > I am wondering if anyone here might be able to suggest if there is a way of > switching over from python execution into debug mode of an IDE, from python > code that is executed as a callback from a C++ DLL?

Debug python from DLL callback?

2011-11-30 Thread Jason Veldicott
Hi, I am wondering if anyone here might be able to suggest if there is a way of switching over from python execution into debug mode of an IDE, from python code that is executed as a callback from a C++ DLL? Thanks Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: C Callback Function using ctypes

2011-03-26 Thread OJ
(most recent call last): >  File "_ctypes/callbacks.c", line 295, in 'calling callback function' >  File "./core.py", line 54, in DebugMessage >    print lvl, msg.value > AttributeError: 'LP_c_char' object has no attribute 'value' > -- http://mail.python.org/mailman/listinfo/python-list

Re: C Callback Function using ctypes

2011-03-26 Thread Nobody
On Sat, 26 Mar 2011 05:23:27 +0300, OJ wrote: > Hi I am opening a shared library which has defined the following > callback prototype: > extern void DebugMessage(int level, const char *message, ...); > > My implementation in Python looks like this: > DEBUGFUNC = cty

C Callback Function using ctypes

2011-03-25 Thread OJ
Hi I am opening a shared library which has defined the following callback prototype: extern void DebugMessage(int level, const char *message, ...); My implementation in Python looks like this: DEBUGFUNC = ctypes.CFUNCTYPE(None, ctypes.c_int, ctypes.POINTER(ctypes.c_char)) def DebugMessage(lvl

Callback mysteries

2011-03-24 Thread Fons Adriaensen
Hello all, I wonder if someone could explain some of the following. (Python 3.2) I have a class which has a method called 'callback()'. An instance of this class calls a C extension which then calls back into Python. In all cases below, two arguments are passed to the C code and

How to implement a callback COM object in Python

2010-11-16 Thread Michael Bode
Hi, I'm trying to write a COM client to a COM server which controls a power meter. The COM server fires events that should be handled by the client. The docs state that I have to supply a class which implements the IFM2DeviceEvents interface. I need some instructions on how to translate the VB sam

Re: optparser: how to register callback to display binary's help

2010-10-15 Thread hiral
mething like > > def myHelp(option, opt, value, parser): >     parser.print_help() >     if hasattr(parser.values, 'file') and parser.values.file: >         proc = subprocess.Popen([parser.values.file, '-h'], > stdout=subprocess.PIPE, stderr=subprocess.PIPE) >         prin

Re: optparser: how to register callback to display binary's help

2010-10-13 Thread Jean-Michel Pichavant
, value, parser): parser.print_help() if hasattr(parser.values, 'file') and parser.values.file: proc = subprocess.Popen([parser.values.file, '-h'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print proc.stdout.read() print proc.stderr.read() parser.

Re: optparser: how to register callback to display binary's help

2010-10-13 Thread Michele Simionato
Here is a solution using plac (http://pypi.python.org/pypi/plac) and not OptionParse, in the case the Linux underlying command is grep: import subprocess import plac @plac.annotations(help=('show help', 'flag', 'h')) def main(help): if help: script_usage = plac.parser_from(main).forma

optparser: how to register callback to display binary's help

2010-10-13 Thread hiral
Hi, I want to display help message of python script and then display help message from the binary file (which also supports -h option): Assumptions: 1) 'mybinary' - is linux executable file which supports '-h' and on '- h' option it displays the help message 2) myscript.py - when passing '-h' opt

Re: Call CFUNCTYPE, class Structure, ctype, dll and Callback function problem

2010-07-31 Thread legard_new
On Jul 31, 10:22 pm, "Mark Tolonen" wrote: > "legard_new" wrote in message > > news:70faf0b4-fead-49ac-bf18-e182fd63b...@j8g2000yqd.googlegroups.com... > > > > > > > Hello, > > > I have a problem with calling Callback function with Pyt

  1   2   3   4   >