I'm looking for an example or advice for embedding an xterm window in a wxPython panel. I think I can get the window ID of a panel with something like "wid=somePanel.GetHandle()" and I should be able to pass that to "xterm -use wid" but so far I'm not having much luck making that work.
+1
A:
Here is a simple script that does work on my machine (ubuntu 8/python 2.5.2/wxpython2.8.10)
import wx
import os
def bindXterm(win):
winID = win.GetHandle()
print "binding xterm to window %d(%x)"%(winID,winID)
os.system("xterm -inot %d"%winID)
app = wx.PySimpleApp()
xtermFrame = wx.Frame(None)
xtermPanel = wx.Panel(xtermFrame)
xtermPanel.SetBackgroundColour((255,0,0))
app.SetTopWindow(xtermFrame)
xtermFrame.Show()
wx.CallLater(1000, bindXterm, xtermPanel)
app.MainLoop()
Two things to note are
- My xterm have only -into option, use the window id given to -into as the parent window rather than the default root window
- We can't just attach xterm before starting the app, so using calllater and it works fine
Anurag Uniyal
2009-07-20 07:08:48
Thanks. In a rare moment of lucidity I realized why my code wasn't working -- I was trying to embed an xterm in a OSX cocoa-based version of wxPython. This code works fine on my linux box, though I'm surprised that "-inot" works. Shouldn't that be "-into"?
Bryan Oakley
2009-07-20 13:38:48