diff --git a/vnpy/trader/ui/editor.py b/vnpy/trader/ui/editor.py index 42d0ae38..050be6b9 100644 --- a/vnpy/trader/ui/editor.py +++ b/vnpy/trader/ui/editor.py @@ -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_() diff --git a/vnpy/trader/ui/ico/editor.ico b/vnpy/trader/ui/ico/editor.ico index c0f1ae00..e886970f 100644 Binary files a/vnpy/trader/ui/ico/editor.ico and b/vnpy/trader/ui/ico/editor.ico differ diff --git a/vnpy/trader/ui/mainwindow.py b/vnpy/trader/ui/mainwindow.py index 1e95e097..2cad1a7b 100644 --- a/vnpy/trader/ui/mainwindow.py +++ b/vnpy/trader/ui/mainwindow.py @@ -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( "代码编辑",