[Mod] make CodeEditor singleton
This commit is contained in:
parent
99fbebbbdb
commit
4f82f061ec
@ -8,6 +8,14 @@ class CodeEditor(QtWidgets.QMainWindow):
|
|||||||
""""""
|
""""""
|
||||||
NEW_FILE_NAME = "Untitled"
|
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):
|
def __init__(self, main_engine=None, event_engine=None):
|
||||||
""""""
|
""""""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -441,8 +449,6 @@ if __name__ == "__main__":
|
|||||||
from vnpy.trader.ui import create_qapp
|
from vnpy.trader.ui import create_qapp
|
||||||
|
|
||||||
app = create_qapp()
|
app = create_qapp()
|
||||||
|
|
||||||
editor = CodeEditor()
|
editor = CodeEditor()
|
||||||
editor.show()
|
editor.show()
|
||||||
|
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
@ -143,7 +143,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
help_menu,
|
help_menu,
|
||||||
"代码编辑",
|
"代码编辑",
|
||||||
"editor.ico",
|
"editor.ico",
|
||||||
partial(self.open_widget, CodeEditor, "editor"),
|
partial(self.open_widget, CodeEditor, "editor")
|
||||||
)
|
)
|
||||||
self.add_toolbar_action(
|
self.add_toolbar_action(
|
||||||
"代码编辑",
|
"代码编辑",
|
||||||
|
Loading…
Reference in New Issue
Block a user