Embedding a Tkinter widget inside a PyGtk HMI

S

Sebastien Aubry

Hello,

I am trying to embed a Tkinter widget (TkZinc, http://www.tkzinc.org)
inside a PyGtk HMI.

A guru gave me this advice: "I think you can do some magic using the XID
of the Tkinter widget's window to produce a GdkWindow"

I wrote this little program, which gets the XID of the Tkinter window
and uses it to create a gtk.gdk.Window.
However, I was unable to find any example of embedding a gtk.gdk.Window
inside a classik gtk.Window. I can't believe it has never been done
before and I was astonished to see the low number of results when typing
"gtk.gdk.window_foreign_new" in Google.

Is this the correct way to do this? Should I use Plugs and Sockets,
instead (the documentation is not clear about this and I will update it
if I find new things)?

Any hint would be appreciated!

Sébastien Aubry

import Tkinter
import gtk
from threading import Thread

def creategtk():
xid_ = t.winfo_id()
print xid_
main = gtk.Window(gtk.WINDOW_TOPLEVEL)
main.set_title(GTK Window")
main.connect("destroy", gtk.main_quit)
main.realize()
foreign = gtk.gdk.window_foreign_new(long(xid_))
main.show()
gtk.main()

t = Tkinter.Tk()
Tkinter.Label(t, text='Tk Label').pack()
Thread(target=creategtk).start()
t.mainloop()
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top