python interactive window_如果PySide应用程序是从IPython interactive cons运行的,上下文菜单就会消失...
在下面給出的最小示例中,上下文菜單(右鍵單擊gui的白色部分)僅短暫顯示,然后消失。如果應(yīng)用程序是從IPython(0.13.1)控制臺(tái)啟動(dòng)的,則會(huì)出現(xiàn)這種情況。當(dāng)從shell正常啟動(dòng)時(shí),它可以正常工作。在import sys
from PySide import QtGui, QtCore
from IPython.lib.guisupport import get_app_qt4, start_event_loop_qt4
class ContextTestGui(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_ContextTestWindow()
self.ui.setupUi(self)
self.ui.treeView.addAction(self.ui.actionCopy)
self.ui.treeView.addAction(self.ui.actionShow)
class Ui_ContextTestWindow(object):
def setupUi(self, ContextTestWindow):
ContextTestWindow.resize(200, 100)
self.treeView = QtGui.QTreeView(ContextTestWindow)
self.treeView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.treeView.setMinimumSize(QtCore.QSize(100, 100))
self.actionCopy = QtGui.QAction("Copy",ContextTestWindow)
self.actionShow = QtGui.QAction("Show",ContextTestWindow)
def create_window(window_class,**kwargs):
app = get_app_qt4(sys.argv)
window = window_class()
window.show()
start_event_loop_qt4(app)
return window
if __name__ == '__main__':
simgui = create_window(ContextTestGui)
總結(jié)
以上是生活随笔為你收集整理的python interactive window_如果PySide应用程序是从IPython interactive cons运行的,上下文菜单就会消失...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: com/mysql/jdbc/sqler
- 下一篇: 只会python怎么挣钱_业余学pyth