MCPcopy
hub / github.com/vnpy/vnpy / init_menu

Method init_menu

vnpy/trader/ui/mainwindow.py:101–188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

99 position_widget.itemDoubleClicked.connect(self.trading_widget.update_with_cell)
100
101 def init_menu(self) -> None:
102 """"""
103 bar: QtWidgets.QMenuBar = self.menuBar()
104 bar.setNativeMenuBar(False) # for mac and linux
105
106 # System menu
107 sys_menu: QtWidgets.QMenu = bar.addMenu(_("系统"))
108
109 gateway_names: list = self.main_engine.get_all_gateway_names()
110 for name in gateway_names:
111 func: Callable = partial(self.connect_gateway, name)
112 self.add_action(
113 sys_menu,
114 _("连接{}").format(name),
115 get_icon_path(__file__, "connect.ico"),
116 func
117 )
118
119 sys_menu.addSeparator()
120
121 self.add_action(
122 sys_menu,
123 _("退出"),
124 get_icon_path(__file__, "exit.ico"),
125 self.close
126 )
127
128 # App menu
129 app_menu: QtWidgets.QMenu = bar.addMenu(_("功能"))
130
131 all_apps: list[BaseApp] = self.main_engine.get_all_apps()
132 for app in all_apps:
133 ui_module: ModuleType = import_module(app.app_module + ".ui")
134 widget_class: type[QtWidgets.QWidget] = getattr(ui_module, app.widget_name)
135
136 func = partial(self.open_widget, widget_class, app.app_name)
137
138 self.add_action(app_menu, app.display_name, app.icon_name, func, True)
139
140 # Global setting editor
141 setting_action: QtGui.QAction = QtGui.QAction(_("配置"), self)
142 setting_action.triggered.connect(self.edit_global_setting)
143 bar.addAction(setting_action)
144
145 # Wechat notification
146 wechat_action: QtGui.QAction = QtGui.QAction(_("微信"), self)
147 wechat_action.triggered.connect(self.open_wechat_dialog)
148 bar.addAction(wechat_action)
149
150 # Help menu
151 help_menu: QtWidgets.QMenu = bar.addMenu(_("帮助"))
152
153 self.add_action(
154 help_menu,
155 _("查询合约"),
156 get_icon_path(__file__, "contract.ico"),
157 partial(self.open_widget, ContractManager, "contract"),
158 True

Callers 1

init_uiMethod · 0.95

Calls 5

add_actionMethod · 0.95
get_icon_pathFunction · 0.85
get_all_gateway_namesMethod · 0.80
get_all_appsMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected