diff --git a/vnpy/trader/ui/editor.py b/vnpy/trader/ui/editor.py index 71fa8578..42d0ae38 100644 --- a/vnpy/trader/ui/editor.py +++ b/vnpy/trader/ui/editor.py @@ -8,7 +8,7 @@ class CodeEditor(QtWidgets.QMainWindow): """""" NEW_FILE_NAME = "Untitled" - def __init__(self): + def __init__(self, main_engine=None, event_engine=None): """""" super().__init__() @@ -296,6 +296,13 @@ class CodeEditor(QtWidgets.QMainWindow): event.accept() + def show(self): + """""" + if not self.tab.count(): + self.open_editor() + + self.showMaximized() + def update_path_label(self): """""" editor = self.get_active_editor() @@ -436,7 +443,6 @@ if __name__ == "__main__": app = create_qapp() editor = CodeEditor() - editor.open_editor() - editor.showMaximized() + editor.show() app.exec_() diff --git a/vnpy/trader/ui/ico/editor.ico b/vnpy/trader/ui/ico/editor.ico index e5227376..c0f1ae00 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 3f293401..1e95e097 100644 --- a/vnpy/trader/ui/mainwindow.py +++ b/vnpy/trader/ui/mainwindow.py @@ -24,6 +24,7 @@ from .widget import ( AboutDialog, GlobalDialog ) +from .editor import CodeEditor from ..engine import MainEngine from ..utility import get_icon_path, TRADER_DIR @@ -138,6 +139,18 @@ class MainWindow(QtWidgets.QMainWindow): partial(self.open_widget, ContractManager, "contract") ) + self.add_menu_action( + help_menu, + "代码编辑", + "editor.ico", + partial(self.open_widget, CodeEditor, "editor"), + ) + self.add_toolbar_action( + "代码编辑", + "editor.ico", + partial(self.open_widget, CodeEditor, "editor") + ) + self.add_menu_action( help_menu, "还原窗口", "restore.ico", self.restore_window_setting )