Quantcast

[pywin32 extensions] Traceback error on running startup script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[pywin32 extensions] Traceback error on running startup script

Maggard, Eric

Hi,

 

I am working on a Win7 machine (64-bit), but would like to embed pywin into a 32-bit MFC app.  I downloaded the 217 build for python 3.2 and then downloaded the python-3.2.2.msi install package.  I installed python and then installed the pywin32 extensions.  I also downloaded the source files pywin32-217.zip and successfully built the pythonwin application.  I made sure I downloaded the 32 bit versions to match my application I am embedding into.

 

I followed the embedding guild: http://tgolden.sc.sabren.com/pywin32-docs/html/pythonwin/doc/EmbeddingWin32ui.html and then also looked at your pythonwin application files.

 

When I start mu application, I am getting a traceback error when the function Win32uiHostGlue::DynamicApplicationInit is executing the following line:

      rc = (*pfnWin32uiInit)(this, (TCHAR *)cmd, (TCHAR *)additionalPaths);

 

The error that it is showing is:

      tuple: ('invalid syntax', ('<string>', 1, 1, '??????????????????????\x0f\n'))

 

I have tried to pass a CString, string, CString.GetString(), and string.c_str() and the traceback error changes slightly, but I always get the error. I am thinking python is not parsing the command string correctly.

 

I copied the pythonwin directly under the build directory I did to my application directory.  I traced the steps leading up to that line and it seems python is getting initialized correctly.  I can start the pythonwin application that is included under the build directory… so, I know it should be working.

 

Here is the initialization I am using:

      CString startup = "import pywin.framework.startup";

 

      // Check for theGlue Initialization

      if (!theGlue.DynamicApplicationInit(startup)) {

            AfxMessageBox("Could not attach to the Python win32ui extensions.");

//          return FALSE;

      }

      else

            AfxMessageBox("Python initialized");

 

If I can’t get this working, then I am thinking about removing the 3.2 version and trying the 3.1 or the 2.7 versions.

 

Thanks for your help,

Eric


_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pywin32 extensions] Traceback error on running startup script

Mark Hammond-4
Are you building your code as a unicode application?  In Python 3.3, the
"TCHAR" will actually be unicode.  If you do roll back to python 2.x, it
will be a regular "char *".

Mark

On 2/04/2012 2:04 AM, Maggard, Eric wrote:

> Hi,
>
> I am working on a Win7 machine (64-bit), but would like to embed pywin
> into a 32-bit MFC app.  I downloaded the 217 build for python 3.2 and
> then downloaded the python-3.2.2.msi install package.  I installed
> python and then installed the pywin32 extensions.  I also downloaded the
> source files pywin32-217.zip and successfully built the pythonwin
> application.  I made sure I downloaded the 32 bit versions to match my
> application I am embedding into.
>
> I followed the embedding guild:
> http://tgolden.sc.sabren.com/pywin32-docs/html/pythonwin/doc/EmbeddingWin32ui.html
> and then also looked at your pythonwin application files.
>
> When I start mu application, I am getting a traceback error when the
> function Win32uiHostGlue::DynamicApplicationInit is executing the
> following line:
>
>        rc = (*pfnWin32uiInit)(this, (TCHAR *)cmd, (TCHAR *)additionalPaths);
>
> The error that it is showing is:
>
>        tuple: ('invalid syntax', ('<string>', 1, 1,
> '??????????????????????\x0f\n'))
>
> I have tried to pass a CString, string, CString.GetString(), and
> string.c_str() and the traceback error changes slightly, but I always
> get the error. I am thinking python is not parsing the command string
> correctly.
>
> I copied the pythonwin directly under the build directory I did to my
> application directory.  I traced the steps leading up to that line and
> it seems python is getting initialized correctly.  I can start the
> pythonwin application that is included under the build directory… so, I
> know it should be working.
>
> Here is the initialization I am using:
>
>        CString startup = "import pywin.framework.startup";
>
> // Check for theGlue Initialization
>
> if (!theGlue.DynamicApplicationInit(startup)) {
>
>              AfxMessageBox("Could not attach to the Python win32ui
> extensions.");
>
> //          return FALSE;
>
>        }
>
> else
>
>              AfxMessageBox("Python initialized");
>
> If I can’t get this working, then I am thinking about removing the 3.2
> version and trying the 3.1 or the 2.7 versions.
>
> Thanks for your help,
>
> Eric
>
>
>
> _______________________________________________
> python-win32 mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/python-win32
>


_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pywin32 extensions] Traceback error on running startup script

Maggard, Eric
Hi Mark,

Thanks for the message.  Nope, I am not using Unicode, so I guess that is where the problem is.

I did get 2.7 running and initializing, but I am having a problem getting the interactive window to show, open a script, or create new script.

I tried to run the startup.py and intpyapp.py scripts, but neither did anything that I could see.  Then I setup this script to try to start an interactive session:

import sys
import win32ui
# First step - redirect python output to the debugging device, until we
# can create a window to capture it.

# Note that this is only useful while debugging, and simply sends any
# Python output (ie, exceptions while developing the startup code) is
# printed to the MSVC debugger. Note that since this code was written,
# the win32trace module has appeared, giving another alternative to
# debugging this code.
class DebugOutput:
  softspace=1
  def write(self,message):
    win32ui.OutputDebug(message)
sys.stderr=sys.stdout=DebugOutput()

# One of your first priorities should be to set sys.stdout to somewhere useful,
# depending on what useful means to your application. This code simply creates
# the Pythonwin Interactive Window, which handles this automatically.

# Now here is the code that does the real work.
import win32con
from pywin.framework import intpyapp, app, interact

class SpecApp(intpyapp.InteractivePythonApp):
  def InitInstance(self):
    # Call the base class (if you want)
    intpyapp.InteractivePythonApp.InitInstance(self)
    # Do domething useful, specific to your app.
    # Here, we minimise the interactive window.
    # (after painting the main frame)
    win32ui.PumpWaitingMessages()
    interact.edit.currentView.GetParent().ShowWindow(win32con.SW_MINIMIZE)

app = SpecApp()

It didn't start an interactive session in my application.

I looked in the intpyapp.py script and I tried to setup menu items to do call the ID_FILE_IMPORT, ID_FILE_RUN, and ID_VIEW_INTERACTIVE.  But even running the intpyapp.py script, the menu items in my app or greyed out. Do I need to setup handlers under my app to process these?  I didn't think I would need to, since I thought the pywin would process the calls first.  How can I check that pywin is actually getting initialized and running?

Thanks,
Eric

-----Original Message-----
From: Mark Hammond [mailto:[hidden email]]
Sent: Sunday, April 01, 2012 6:06 PM
To: Maggard, Eric
Cc: [hidden email]
Subject: Re: [python-win32] [pywin32 extensions] Traceback error on running startup script

Are you building your code as a unicode application?  In Python 3.3, the
"TCHAR" will actually be unicode.  If you do roll back to python 2.x, it
will be a regular "char *".

Mark

On 2/04/2012 2:04 AM, Maggard, Eric wrote:

> Hi,
>
> I am working on a Win7 machine (64-bit), but would like to embed pywin
> into a 32-bit MFC app.  I downloaded the 217 build for python 3.2 and
> then downloaded the python-3.2.2.msi install package.  I installed
> python and then installed the pywin32 extensions.  I also downloaded the
> source files pywin32-217.zip and successfully built the pythonwin
> application.  I made sure I downloaded the 32 bit versions to match my
> application I am embedding into.
>
> I followed the embedding guild:
> http://tgolden.sc.sabren.com/pywin32-docs/html/pythonwin/doc/EmbeddingWin32ui.html
> and then also looked at your pythonwin application files.
>
> When I start mu application, I am getting a traceback error when the
> function Win32uiHostGlue::DynamicApplicationInit is executing the
> following line:
>
>        rc = (*pfnWin32uiInit)(this, (TCHAR *)cmd, (TCHAR *)additionalPaths);
>
> The error that it is showing is:
>
>        tuple: ('invalid syntax', ('<string>', 1, 1,
> '??????????????????????\x0f\n'))
>
> I have tried to pass a CString, string, CString.GetString(), and
> string.c_str() and the traceback error changes slightly, but I always
> get the error. I am thinking python is not parsing the command string
> correctly.
>
> I copied the pythonwin directly under the build directory I did to my
> application directory.  I traced the steps leading up to that line and
> it seems python is getting initialized correctly.  I can start the
> pythonwin application that is included under the build directory... so, I
> know it should be working.
>
> Here is the initialization I am using:
>
>        CString startup = "import pywin.framework.startup";
>
> // Check for theGlue Initialization
>
> if (!theGlue.DynamicApplicationInit(startup)) {
>
>              AfxMessageBox("Could not attach to the Python win32ui
> extensions.");
>
> //          return FALSE;
>
>        }
>
> else
>
>              AfxMessageBox("Python initialized");
>
> If I can't get this working, then I am thinking about removing the 3.2
> version and trying the 3.1 or the 2.7 versions.
>
> Thanks for your help,
>
> Eric
>
>
>
> _______________________________________________
> python-win32 mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/python-win32
>


_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Loading...