VB6 frontend GUI with Python

Discussion in 'Python' started by Claire Blair, Nov 20, 2007.

  1. Claire Blair

    Claire Blair Guest

    I am trying to write a VB6 (not VB.Net) application that has a console
    window that allows Python command to be typed at the prompt.

    The idea is so that, I can have full Python scripting from within my
    application. I should be able to type commands from a Python script
    (include import etc, so I can use other Python libraries). In other
    words, I want to provide a complete (or almost complete) interactive
    Python Scripting environment from within my application - so that I
    enter commands in the VB6 console, and I get the (text) results
    displayed in my VB6 console, and in the case of a graphic output (let
    say I am importing wxPython for graphing functionality), I would have
    the graph display after I have typed my command in my VB6 console.

    My initial route was to try to embed the Python interpreter, using BOOST
    Python, writing a Win32 DLL around that and then calling the functions
    from VB6. But I had various problems with that approach - so I am now
    looking to use a Python COM server approach (although I would have
    preferred not to touch COM).

    I have done a lot of Googling and research online - but I can't find
    anything remotely useful, taht shows me how to do what I want to do. If
    anyone has done something similar to what I am trying to do, or knows of
    any links that may show me how to do provide a VB6 frontend GUI (i.e.
    console) fo ruse with Python, I will be very grateful.
    Claire Blair, Nov 20, 2007
    #1
    1. Advertising

  2. Claire Blair wrote:

    > I am trying to write a VB6 (not VB.Net) application that has a console
    > window that allows Python command to be typed at the prompt.
    >
    > The idea is so that, I can have full Python scripting from within my
    > application. I should be able to type commands from a Python script
    > (include import etc, so I can use other Python libraries). In other
    > words, I want to provide a complete (or almost complete) interactive
    > Python Scripting environment from within my application - so that I
    > enter commands in the VB6 console, and I get the (text) results
    > displayed in my VB6 console, and in the case of a graphic output (let
    > say I am importing wxPython for graphing functionality), I would have
    > the graph display after I have typed my command in my VB6 console.
    >
    > My initial route was to try to embed the Python interpreter, using BOOST
    > Python, writing a Win32 DLL around that and then calling the functions
    > from VB6. But I had various problems with that approach - so I am now
    > looking to use a Python COM server approach (although I would have
    > preferred not to touch COM).
    >
    > I have done a lot of Googling and research online - but I can't find
    > anything remotely useful, taht shows me how to do what I want to do. If
    > anyone has done something similar to what I am trying to do, or knows of
    > any links that may show me how to do provide a VB6 frontend GUI (i.e.
    > console) fo ruse with Python, I will be very grateful.


    You keep talking about "a console", but OTOH you want to use wxPython -
    which clearly is not console, but GUI. So I'm not really sure what you are
    after.

    It might be possible to make wx render into a given window-handle.

    But may I ask: what is the reason for using VB at all? Why not do the
    GUI-frontend in wxPython?

    Diez
    Diez B. Roggisch, Nov 20, 2007
    #2
    1. Advertising

  3. Claire Blair

    Claire Blair Guest

    Diez B. Roggisch wrote:
    > Claire Blair wrote:
    >
    >
    >>I am trying to write a VB6 (not VB.Net) application that has a console
    >>window that allows Python command to be typed at the prompt.
    >>
    >>The idea is so that, I can have full Python scripting from within my
    >>application. I should be able to type commands from a Python script
    >>(include import etc, so I can use other Python libraries). In other
    >>words, I want to provide a complete (or almost complete) interactive
    >>Python Scripting environment from within my application - so that I
    >>enter commands in the VB6 console, and I get the (text) results
    >>displayed in my VB6 console, and in the case of a graphic output (let
    >>say I am importing wxPython for graphing functionality), I would have
    >>the graph display after I have typed my command in my VB6 console.
    >>
    >>My initial route was to try to embed the Python interpreter, using BOOST
    >>Python, writing a Win32 DLL around that and then calling the functions
    >>from VB6. But I had various problems with that approach - so I am now
    >>looking to use a Python COM server approach (although I would have
    >>preferred not to touch COM).
    >>
    >>I have done a lot of Googling and research online - but I can't find
    >>anything remotely useful, taht shows me how to do what I want to do. If
    >>anyone has done something similar to what I am trying to do, or knows of
    >>any links that may show me how to do provide a VB6 frontend GUI (i.e.
    >>console) fo ruse with Python, I will be very grateful.

    >
    >
    > You keep talking about "a console", but OTOH you want to use wxPython -
    > which clearly is not console, but GUI. So I'm not really sure what you are
    > after.


    Yes, this seems to be confusing a lot of people. I want to be able to
    use various existing plotting libraries (most of which use wxPython or
    pyOpenGL). The end result is that (assuming my paths etc have been
    correctly set), I can type something like this in my console:

    >>> import someGraphingModule
    >>> # a few other commands to fetch data etc ...
    >>>
    >>> # The following line will then open a window (using
    >>> # wxPython, wxOpenGL (or whatever windowing library is
    >>> # is provided by module someGraphingModule
    >>> someGraphingModule.plotdata



    >
    > It might be possible to make wx render into a given window-handle.
    >
    > But may I ask: what is the reason for using VB at all? Why not do the
    > GUI-frontend in wxPython?
    >
    > Diez


    Simple. its because my main application (the GUI that is), is written in
    VB6. I have a MDI application (i.e. many child windows in the same
    application), and I want to use one of these windows as a console to
    inteactively type Python commands. If I were to use wxPython, I would
    not be able to treat the console 'the same' as the other child windows
    in the application (i.e. minimize, close all etc). Maybe a simpler way
    to think of this is to imagine that I am writing a PythonWin clone in
    VB6. What I am asking here, is how can I create the 'Interactive Window' ?
    Claire Blair, Nov 20, 2007
    #3
  4. > Simple. its because my main application (the GUI that is), is written in
    > VB6. I have a MDI application (i.e. many child windows in the same
    > application), and I want to use one of these windows as a console to
    > inteactively type Python commands. If I were to use wxPython, I would
    > not be able to treat the console 'the same' as the other child windows
    > in the application (i.e. minimize, close all etc). Maybe a simpler way
    > to think of this is to imagine that I am writing a PythonWin clone in
    > VB6. What I am asking here, is how can I create the 'Interactive Window' ?


    Your asking for more. Your asking for the interactive window (which
    shouldn't be too hard, just using subprocess and somehow attaching
    stdin/stdout - there should be code that does that) AND you are asking for
    integration of GUI. Which is much more complicated. I'm not a windows guru,
    but at least you need a way to communicate a window-handle to some
    background thread or so of the python interpreter, which will be used to
    render the plot. But that of course implies that the various plotting libs
    are somehow capable of doing so.

    I know that for example under X-windwow, you can "capture" one window and
    display it as part of another. If there exists something like that in
    Windwos, a way to shell various applications, that would help you.

    Apart from that the only thing that comes to my mind is an ActiveX-control,
    but even there I'm ont sure how event-loops and stuff behave.

    All in all - an integration hell....

    Diez
    Diez B. Roggisch, Nov 20, 2007
    #4
  5. > On Behalf Of Claire Blair
    > I am trying to write a VB6 (not VB.Net) application that has
    > a console window that allows Python command to be typed at the prompt.


    I'm not sure what pieces of the puzzle you're missing. Were you able to
    create a simple COM server with Python?

    At a conceptual level, how about this:

    * Your VB form creates an instance of the Python COM server
    * You pass a reference to the form to the COM server (server.SetForm Me
    'etc...)
    * You have a textbox in your VB form. You listen for Return key events
    * When you get a return key, you call a method on the COM server that says
    "submit text line"
    * The COM server examines the last line of text in the form's text box, and
    takes any necessary action, including:
    + Eval a line of interactive Python code
    + Write a result to the VB form's text box

    Do the above steps sound feasible?

    Regards,
    Ryan Ginstrom
    Ryan Ginstrom, Nov 20, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Al Bogner

    Tutorial for DB-Frontend with GUI

    Al Bogner, Nov 14, 2003, in forum: Python
    Replies:
    2
    Views:
    952
    Al Bogner
    Nov 15, 2003
  2. Piet
    Replies:
    0
    Views:
    405
  3. David Stockwell

    RE: GUI frontend for MySQL in wxPython

    David Stockwell, May 17, 2004, in forum: Python
    Replies:
    0
    Views:
    708
    David Stockwell
    May 17, 2004
  4. Anonymous
    Replies:
    5
    Views:
    404
    Steve Holden
    Oct 3, 2007
  5. Replies:
    2
    Views:
    1,016
    Mike Meyer
    Jan 11, 2008
Loading...

Share This Page