[Mod] make CodeEditor singleton

This commit is contained in:
vn.py 2019-11-01 10:12:37 +08:00
parent 99fbebbbdb
commit 4f82f061ec
3 changed files with 9 additions and 3 deletions

View File

@ -8,6 +8,14 @@ class CodeEditor(QtWidgets.QMainWindow):
""""""
NEW_FILE_NAME = "Untitled"
_instance = None
def __new__(cls, *args, **kwargs):
""""""
if not cls._instance:
cls._instance = QtWidgets.QMainWindow.__new__(cls, *args, **kwargs)
return cls._instance
def __init__(self, main_engine=None, event_engine=None):
""""""
super().__init__()
@ -441,8 +449,6 @@ if __name__ == "__main__":
from vnpy.trader.ui import create_qapp
app = create_qapp()
editor = CodeEditor()
editor.show()
app.exec_()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -143,7 +143,7 @@ class MainWindow(QtWidgets.QMainWindow):
help_menu,
"代码编辑",
"editor.ico",
partial(self.open_widget, CodeEditor, "editor"),
partial(self.open_widget, CodeEditor, "editor")
)
self.add_toolbar_action(
"代码编辑",