Embed a Python/Gtk program

More
27 Jan 2015 22:11 #55386 by BigJohnT
Does anyone have the basics that are needed to embed a python/gtk program into an Axis tab. I've found EMBED_TAB_NAME and that is pretty straight forward. The EMBED_TAB_COMMAND doesn't seem to have any docs describing how that works. I see a post from ArcEye that the program needs to take a WinID to load. So far I can get the tab to show up but nothing is in the tab.

Thanks
JT

Please Log in or Create an account to join the conversation.

More
27 Jan 2015 22:27 #55388 by ArcEye
Replied by ArcEye on topic Embed a Python/Gtk program
Hi JT,

You need to dig into the Axis code to see it clearly.

Axis creates a container window and replaces the {XID} parameter with the actual XWinID

So an INI line such as

EMBED_TAB_COMMAND = xterm -into {XID}

sees xterm called with something like xterm -into 0x7ffcd4f4 where the hex number is the actual winID of the container within the tab widget

I'll dig out the actual Axis line numbers in a bit.

So you need to write a program that can embed itself into a given winID

regards

Please Log in or Create an account to join the conversation.

More
27 Jan 2015 22:33 #55389 by ArcEye
Replied by ArcEye on topic Embed a Python/Gtk program
The code starts at 3285 of Axis in v2.6.6

The bit of code regards the winID is
 for i,t,c in zip(range(len(tab_cmd)), tab_names, tab_cmd):
        w = _dynamic_tab("user_" + str(i), t)
        f = Tkinter.Frame(w, container=1, borderwidth=0, highlightthickness=0)
        f.pack(fill="both", expand=1)
        xid = f.winfo_id()
        cmd = c.replace('{XID}', str(xid)).split()
        child = Popen(cmd)
        wait = cmd[:2] == ['halcmd', 'loadusr']

        _dynamic_childs[str(w)] = (child, cmd, wait)

regards

Please Log in or Create an account to join the conversation.

More
27 Jan 2015 22:42 #55390 by ArcEye
Replied by ArcEye on topic Embed a Python/Gtk program
These give some more info, but my python-fu runs out here

www.pygtk.org/pygtk2tutorial/sec-PlugsAndSockets.html

docs.python.org/2/extending/embedding.html

When I did it in C++ using Qt, I did exactly what I described, created an app that took the ID of the window to embed into as an argument

This is an extract.
#include "HAL_EmbedWidget.h"

int main( int argc, char ** argv )
{
    QApplication app(argc, argv);

     if (app.arguments().count() != 2) {
         qFatal("Error - expected window id as argument");
         return 1;
     }

     QString windowId(app.arguments()[1]);
     HAL_EmbedWidget window;
     window.embedInto(windowId.toULong());
     window.show();

     return app.exec();
}

There may be an even simpler way to do it gtk app to gtk app.

regards

Please Log in or Create an account to join the conversation.

More
27 Jan 2015 23:17 #55392 by BigJohnT
Replied by BigJohnT on topic Embed a Python/Gtk program
Thanks for the info, it gives me something to chew on... I seem to remember something Chris said about reparent.

JT

Please Log in or Create an account to join the conversation.

Time to create page: 0.095 seconds
Powered by Kunena Forum