开发者

Embed PyQt4 widget into wxPython window

I'm investigating whether it is possible to migrate an existing wxPython to PyQt. It would be nice if I could port some widgets to PyQt while others are still powered by wx. I already got both eventloops running side-a-side in an example (see below). But the widgets are still in separate windows. Is there a way to embed a Qt widget in a wxWindow? (I only need something that works on Linux, because this is only relevant for the transition phase.)

#!/usr/bin/env python

import wx, sys
from PyQt4 import QtCore, QtGui

class QEventLoopTimer(wx.Timer):
    def __init__(self, owner):
        wx.Timer.__init__(self, owner, wx.ID_ANY)
        self.Start(10)
        self.Bind(wx.EVT_TIMER, self.runEvents, self)
    def runEvents(self):
        QtCore.QCoreApplication.instance().processEvents()

wapp = wx.PySimpleApp()
qapp = QtGui开发者_JS百科.QApplication(sys.argv)

frame = wx.Frame(None, wx.ID_ANY, name = "test-wxqt.py")
frame.Show(True)
timer = QEventLoopTimer(frame)

button = QtGui.QPushButton("Hallo")
button.show()

wapp.MainLoop()


I don't think this is possible without hacking the low-level graphics interface for either toolkit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜