将 PyQt4 小部件嵌入 wxPython 窗口
我正在研究是否可以将现有的 wxPython 迁移到 PyQt。如果我可以将一些小部件移植到 PyQt,而其他小部件仍然由 wx 提供支持,那就太好了。我已经在示例中同时运行了两个事件循环(见下文)。但小部件仍然位于单独的窗口中。有没有办法在 wxWindow 中嵌入 Qt 小部件? (我只需要在 Linux 上运行的东西,因为这仅与过渡阶段相关。)
#!/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.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'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.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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为如果不破解这两个工具包的低级图形接口,这是不可能的。
I don't think this is possible without hacking the low-level graphics interface for either toolkit.