
Dear Developers, Hi, I have a C++ program and I want to package it under the tools menu. I made a dll from my program. My dll gets two input ( pdb name and volum density level ,) and generate the output. when I save the python codes to execute my dll in the chimera IDLE, every thing works well and my program starts working and generates the output. here is the code that I ran in the IDLE: import ctypes dll = ctypes.CDLL('tracer_v2.dll') dll.calc.argtypes = [ctypes.c_char_p, ctypes.c_double] dll.calc.restype = ctypes.c_int print(dll.calc('1733_H',3)) The problem that I faced is that when I add an extension button to the chimera and wants to call my function (calc('1733_H', 3) ) from there, I get an error: WindowsError Exception in Tk callback Function: <function command at 0x0D1A89B0> (type: <type 'function'>) Args: () Traceback (innermost last): File "C:\Program Files (x86)\Chimera 1.10.1\bin\lib\site-packages\Pmw\Pmw_1_3_3\lib\PmwBase.py", line 1747, in __call__ return apply(self.func, args) File "C:\Program Files (x86)\Chimera 1.10.1\share\chimera\baseDialog.py", line 449, in command getattr(s, buttonFuncName(txt))() File "Z:\Tracer_Chimera\GUI\TracerUI\gui.py", line 43, in Apply TracerUI.mainchain() File "Z:\Tracer_Chimera\GUI\TracerUI\__init__.py", line 9, in mainchain dll = ctypes.CDLL('tracer_v2.dll') File "C:\Program Files (x86)\Chimera 1.10.1\bin\lib\ctypes\__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 126] The specified module could not be found Would you please help me know how I can fix it? Thanks, Maryam Arab Research Assistant Old Dominion University

Hi Maryam, The problem is that your ctypes.CDLL(‘tracer_v2.dll’) can’t find the file ‘tracer_v2.dll’. Probably if Chimera does not start in the directory with that dll it won’t find it. You should give it a full path to the file. If the DLL is in the same directory as your ctypes call then you might try from os import path dll_path = path.join(path.dirname(__file__), ‘tracer_v2.dll’) dll = ctypes.CDLL(dll_path) Tom
On Jun 13, 2015, at 7:24 AM, MARYAM ARAB <marab002@odu.edu> wrote:
Dear Developers,
Hi, I have a C++ program and I want to package it under the tools menu. I made a dll from my program. My dll gets two input ( pdb name and volum density level ,) and generate the output. when I save the python codes to execute my dll in the chimera IDLE, every thing works well and my program starts working and generates the output. here is the code that I ran in the IDLE:
import ctypes dll = ctypes.CDLL('tracer_v2.dll') dll.calc.argtypes = [ctypes.c_char_p, ctypes.c_double] dll.calc.restype = ctypes.c_int print(dll.calc('1733_H',3))
The problem that I faced is that when I add an extension button to the chimera and wants to call my function (calc('1733_H', 3) ) from there, I get an error:
WindowsError Exception in Tk callback Function: <function command at 0x0D1A89B0> (type: <type 'function'>) Args: () Traceback (innermost last): File "C:\Program Files (x86)\Chimera 1.10.1\bin\lib\site-packages\Pmw\Pmw_1_3_3\lib\PmwBase.py", line 1747, in __call__ return apply(self.func, args) File "C:\Program Files (x86)\Chimera 1.10.1\share\chimera\baseDialog.py", line 449, in command getattr(s, buttonFuncName(txt))() File "Z:\Tracer_Chimera\GUI\TracerUI\gui.py", line 43, in Apply TracerUI.mainchain() File "Z:\Tracer_Chimera\GUI\TracerUI\__init__.py", line 9, in mainchain dll = ctypes.CDLL('tracer_v2.dll') File "C:\Program Files (x86)\Chimera 1.10.1\bin\lib\ctypes\__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 126] The specified module could not be found
Would you please help me know how I can fix it?
Thanks, Maryam Arab Research Assistant Old Dominion University
_______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
participants (2)
-
MARYAM ARAB
-
Tom Goddard