wxpythonxterm

example of embeddeding xterm in wxPython panel


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.


Solution

  • 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

    1. My xterm have only -into option, use the window id given to -into as the parent window rather than the default root window
    2. We can't just attach xterm before starting the app, so using calllater and it works fine