[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"
|
||||
|
||||
_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 |
@ -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(
|
||||
"代码编辑",
|
||||
|
Loading…
Reference in New Issue
Block a user