Python qtpy.QtWidgets.QAction() Examples
The following are 23
code examples of qtpy.QtWidgets.QAction().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qtpy.QtWidgets
, or try the search function
.
Example #1
Source File: viewer.py From pydiq with MIT License | 6 votes |
def build_menu(self): self.file_menu = QtWidgets.QMenu('&File', self) self.file_menu.addAction('&Open directory', self.open_directory, QtCore.Qt.CTRL + QtCore.Qt.Key_O) self.file_menu.addAction('&Export image', self.export_image, QtCore.Qt.CTRL + QtCore.Qt.Key_S) self.file_menu.addAction('&Quit', self.close, QtCore.Qt.CTRL + QtCore.Qt.Key_Q) self.view_menu = QtWidgets.QMenu('&View', self) self.view_menu.addAction('Zoom In', self.pix_label.increase_zoom, QtCore.Qt.CTRL + QtCore.Qt.Key_Plus) self.view_menu.addAction('Zoom Out', self.pix_label.decrease_zoom, QtCore.Qt.CTRL + QtCore.Qt.Key_Minus) self.view_menu.addAction('Zoom 1:1', self.pix_label.reset_zoom, QtCore.Qt.CTRL + QtCore.Qt.Key_0) fullscreen = QtWidgets.QAction('&Full Screen', self) fullscreen.setCheckable(True) fullscreen.setShortcut(QtCore.Qt.Key_F11) fullscreen.toggled.connect(self.toggle_full_screen) self.view_menu.addAction(fullscreen) self.tools_menu = QtWidgets.QMenu("&Tools", self) self.tools_menu.addAction('&Show DICOM structure', self.show_structure, QtCore.Qt.Key_F2) self.menuBar().addMenu(self.file_menu) self.menuBar().addMenu(self.view_menu) self.menuBar().addMenu(self.tools_menu)
Example #2
Source File: qthelpers.py From conda-manager with MIT License | 6 votes |
def add_actions(target, actions, insert_before=None): """Add actions to a menu""" previous_action = None target_actions = list(target.actions()) if target_actions: previous_action = target_actions[-1] if previous_action.isSeparator(): previous_action = None for action in actions: if (action is None) and (previous_action is not None): if insert_before is None: target.addSeparator() else: target.insertSeparator(insert_before) elif isinstance(action, QMenu): if insert_before is None: target.addMenu(action) else: target.insertMenu(insert_before, action) elif isinstance(action, QAction): if insert_before is None: target.addAction(action) else: target.insertAction(insert_before, action) previous_action = action
Example #3
Source File: pyrpl_widget.py From pyrpl with GNU General Public License v3.0 | 6 votes |
def add_dock_widget(self, create_widget, name): dock_widget = MyDockWidget(create_widget, name + ' (%s)' % self.parent.name) self.dock_widgets[name] = dock_widget self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock_widget) if self.last_docked is not None: self.tabifyDockWidget(self.last_docked, dock_widget) # put tabs on top self.setTabPosition(dock_widget.allowedAreas(), QtWidgets.QTabWidget.North) self.last_docked = dock_widget self.last_docked.hide() # by default no widget is created... action = QtWidgets.QAction(name, self.menu_modules) action.setCheckable(True) self.module_actions.append(action) self.menu_modules.addAction(action) # make sure menu and widget are in sync action.changed.connect(lambda: dock_widget.setVisible(action.isChecked())) dock_widget.visibilityChanged.connect(lambda:action.setChecked(dock_widget.isVisible())) dock_widget.visibilityChanged.connect(self.hide_centralbutton) self.set_background_color(dock_widget)
Example #4
Source File: actions.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 6 votes |
def __enable_point_context(self) -> None: """Adjust the status of QActions. What ever we have least one point or not, need to enable / disable QAction. """ selection = self.entities_point.selected_rows() # Set grounded state if selection: self.action_p_lock.setChecked(all( VLink.FRAME in self.vpoint_list[row].links for row in selection )) self.context.point_enable(len(selection)) def mj_func(order: int) -> Callable[[], None]: """Generate a merge function.""" @Slot() def func() -> None: self.__to_multiple_joint(order, selection) return func for i, p in enumerate(selection): action = QAction(f"Base on Point{p}", self) action.triggered.connect(mj_func(i)) self.pop_point_m.addAction(action)
Example #5
Source File: actions.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 6 votes |
def __enable_link_context(self) -> None: """Enable / disable link's QAction, same as point table.""" selection = self.entities_link.selected_rows() row = self.entities_link.currentRow() self.context.link_enable(len(selection), row) def ml_func(order: int) -> Callable[[], None]: """Generate a merge function.""" @Slot(int) def func() -> None: self.__merge_link(order, selection) return func for i, row in enumerate(selection): action = QAction(f"Base on \"{self.vlink_list[row].name}\"", self) action.triggered.connect(ml_func(i)) self.pop_link_m.addAction(action)
Example #6
Source File: main.py From TuChart with MIT License | 5 votes |
def openWidgetMenu(self,position): indexes = self.ui.treeWidget_2.selectedIndexes() item = self.ui.treeWidget_2.itemAt(position) if item == None: return #item = self.ui.listWidget.itemAt(position) if len(indexes) > 0: menu = QMenu() menu.addAction(QAction("Delete", menu,checkable = True))#This function is perhaps useless #menu.triggered.connect(self.eraseItem) item = self.ui.treeWidget_2.itemAt(position) #collec = str(item.text()) menu.triggered.connect(lambda action: self.ListMethodSelected(action, item)) menu.exec_(self.ui.treeWidget_2.viewport().mapToGlobal(position))
Example #7
Source File: qthelpers.py From conda-manager with MIT License | 5 votes |
def create_action(parent, text, shortcut=None, icon=None, tip=None, toggled=None, triggered=None, data=None, menurole=None, context=Qt.WindowShortcut): """Create a QAction""" action = QAction(text, parent) if triggered is not None: action.triggered.connect(triggered) if toggled is not None: action.toggled.connect(toggled) action.setCheckable(True) if icon is not None: action.setIcon(icon) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if data is not None: action.setData(to_qvariant(data)) if menurole is not None: action.setMenuRole(menurole) #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut # (this will avoid calling shortcuts from another dockwidget # since the context thing doesn't work quite well with these widgets) action.setShortcutContext(context) return action
Example #8
Source File: qthelpers.py From conda-manager with MIT License | 5 votes |
def action2button(action, autoraise=True, text_beside_icon=False, parent=None): """Create a QToolButton directly from a QAction object""" if parent is None: parent = action.parent() button = QToolButton(parent) button.setDefaultAction(action) button.setAutoRaise(autoraise) if text_beside_icon: button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) return button
Example #9
Source File: module_manager_widget.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def contextMenuEvent(self, event): for widget in self.module_widgets: if widget.geometry().contains(event.pos()): if widget.module.owner is not None: act = QtWidgets.QAction('Free %s'%widget.module.name, self) act.triggered.connect(widget.module.free) menu = QtWidgets.QMenu() menu.addAction(act) menu.exec_(event.globalPos())
Example #10
Source File: base_module_widget.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def get_menu(self): menu = super(EditLabel, self).get_menu() action_current = QtWidgets.QAction('<Current>', self) action_current.triggered.connect(functools.partial(self.func, None)) others = menu.actions() if len(others)>0: other = others[0] menu.insertAction(other, action_current) else: menu.addAction(action_current) # will append the action at the end return menu
Example #11
Source File: base_module_widget.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def get_menu(self): menu = super(SaveLabel, self).get_menu() action_new = QtWidgets.QAction('<New...>', self) action_new.triggered.connect(self.new_state) menu.addAction(action_new) return menu
Example #12
Source File: base_module_widget.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def get_menu(self): menu = QtWidgets.QMenu(self) self.actions = [] for state in self.module.states: action = QtWidgets.QAction(state, self) self.actions.append(action) action.triggered.connect(functools.partial(self.func, state)) menu.addAction(action) return menu
Example #13
Source File: mainwindow.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_help_menu(self): # please keep the Help menu in Mac Os even if empty. It will # automatically contain a search field to search inside menus and # please keep it spelled in English, as long as Qt Doesn't support # a QAction.MenuRole like HelpMenuRole otherwise it will lose # this search field functionality self.help_menu = self.menuBar().addMenu("&Help") # Help Menu self.help_action = QtWidgets.QAction("Show &QtConsole help", self, triggered=self._show_help) self.online_help_action = QtWidgets.QAction("Open online &help", self, triggered=self._open_online_help) self.add_menu_action(self.help_menu, self.help_action) self.add_menu_action(self.help_menu, self.online_help_action)
Example #14
Source File: mainwindow.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_kernel_menu(self): self.kernel_menu = self.menuBar().addMenu("&Kernel") # Qt on OSX maps Ctrl to Cmd, and Meta to Ctrl # keep the signal shortcuts to ctrl, rather than # platform-default like we do elsewhere. ctrl = "Meta" if sys.platform == 'darwin' else "Ctrl" self.interrupt_kernel_action = QtWidgets.QAction("&Interrupt current Kernel", self, triggered=self.interrupt_kernel_active_frontend, shortcut=ctrl+"+C", ) self.add_menu_action(self.kernel_menu, self.interrupt_kernel_action) self.restart_kernel_action = QtWidgets.QAction("&Restart current Kernel", self, triggered=self.restart_kernel_active_frontend, shortcut=ctrl+"+.", ) self.add_menu_action(self.kernel_menu, self.restart_kernel_action) self.kernel_menu.addSeparator() self.confirm_restart_kernel_action = QtWidgets.QAction("&Confirm kernel restart", self, checkable=True, checked=self.active_frontend.confirm_restart, triggered=self.toggle_confirm_restart_active_frontend ) self.add_menu_action(self.kernel_menu, self.confirm_restart_kernel_action) self.tab_widget.currentChanged.connect(self.update_restart_checkbox)
Example #15
Source File: qt_debug_menu.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _add_stop(self): """Add Stop Recording action. """ stop = QAction('Stop Recording', self.main_window._qt_window) stop.setShortcut('Shift+Alt+T') stop.setStatusTip('Stop recording a trace file') stop.triggered.connect(self._stop_trace) self.sub_menu.addAction(stop) return stop
Example #16
Source File: qt_debug_menu.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _add_start(self): """Add Start Recording action. """ start = QAction('Start Recording...', self.main_window._qt_window) start.setShortcut('Alt+T') start.setStatusTip('Start recording a trace file') start.triggered.connect(self._start_trace) self.sub_menu.addAction(start) return start
Example #17
Source File: main.py From TuChart with MIT License | 5 votes |
def openWidgetMenu(self,position): indexes = self.ui.treeWidget_2.selectedIndexes() item = self.ui.treeWidget_2.itemAt(position) if item == None: return #item = self.ui.listWidget.itemAt(position) if len(indexes) > 0: menu = QMenu() menu.addAction(QAction("Delete", menu,checkable = True))#This function is perhaps useless #menu.triggered.connect(self.eraseItem) item = self.ui.treeWidget_2.itemAt(position) #collec = str(item.text()) menu.triggered.connect(lambda action: self.ListMethodSelected(action, item)) menu.exec_(self.ui.treeWidget_2.viewport().mapToGlobal(position))
Example #18
Source File: frontend_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 4 votes |
def __init__(self, local_kernel=_local_kernel, *args, **kw): super(FrontendWidget, self).__init__(*args, **kw) # FrontendWidget protected variables. self._bracket_matcher = BracketMatcher(self._control) self._call_tip_widget = CallTipWidget(self._control) self._copy_raw_action = QtWidgets.QAction('Copy (Raw Text)', None) self._hidden = False self._highlighter = FrontendHighlighter(self, lexer=self.lexer) self._kernel_manager = None self._kernel_client = None self._request_info = {} self._request_info['execute'] = {} self._callback_dict = {} self._display_banner = True # Configure the ConsoleWidget. self.tab_width = 4 self._set_continuation_prompt('... ') # Configure the CallTipWidget. self._call_tip_widget.setFont(self.font) self.font_changed.connect(self._call_tip_widget.setFont) # Configure actions. action = self._copy_raw_action key = QtCore.Qt.CTRL | QtCore.Qt.SHIFT | QtCore.Qt.Key_C action.setEnabled(False) action.setShortcut(QtGui.QKeySequence(key)) action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) action.triggered.connect(self.copy_raw) self.copy_available.connect(action.setEnabled) self.addAction(action) # Connect signal handlers. document = self._control.document() document.contentsChange.connect(self._document_contents_change) # Set flag for whether we are connected via localhost. self._local_kernel = local_kernel # Whether or not a clear_output call is pending new output. self._pending_clearoutput = False #--------------------------------------------------------------------------- # 'ConsoleWidget' public interface #---------------------------------------------------------------------------
Example #19
Source File: mainwindow.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 4 votes |
def init_window_menu(self): self.window_menu = self.menuBar().addMenu("&Window") if sys.platform == 'darwin': # add min/maximize actions to OSX, which lacks default bindings. self.minimizeAct = QtWidgets.QAction("Mini&mize", self, shortcut="Ctrl+m", statusTip="Minimize the window/Restore Normal Size", triggered=self.toggleMinimized) # maximize is called 'Zoom' on OSX for some reason self.maximizeAct = QtWidgets.QAction("&Zoom", self, shortcut="Ctrl+Shift+M", statusTip="Maximize the window/Restore Normal Size", triggered=self.toggleMaximized) self.add_menu_action(self.window_menu, self.minimizeAct) self.add_menu_action(self.window_menu, self.maximizeAct) self.window_menu.addSeparator() prev_key = "Ctrl+Alt+Left" if sys.platform == 'darwin' else "Ctrl+PgUp" self.prev_tab_act = QtWidgets.QAction("Pre&vious Tab", self, shortcut=prev_key, statusTip="Select previous tab", triggered=self.prev_tab) self.add_menu_action(self.window_menu, self.prev_tab_act) next_key = "Ctrl+Alt+Right" if sys.platform == 'darwin' else "Ctrl+PgDown" self.next_tab_act = QtWidgets.QAction("Ne&xt Tab", self, shortcut=next_key, statusTip="Select next tab", triggered=self.next_tab) self.add_menu_action(self.window_menu, self.next_tab_act) self.rename_window_act = QtWidgets.QAction("Rename &Window", self, shortcut="Alt+R", statusTip="Rename window", triggered=self.set_window_title) self.add_menu_action(self.window_menu, self.rename_window_act) self.rename_current_tab_act = QtWidgets.QAction("&Rename Current Tab", self, shortcut="Ctrl+R", statusTip="Rename current tab", triggered=self.set_tab_title) self.add_menu_action(self.window_menu, self.rename_current_tab_act)
Example #20
Source File: mainwindow.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 4 votes |
def init_edit_menu(self): self.edit_menu = self.menuBar().addMenu("&Edit") self.undo_action = QtWidgets.QAction("&Undo", self, shortcut=QtGui.QKeySequence.Undo, statusTip="Undo last action if possible", triggered=self.undo_active_frontend ) self.add_menu_action(self.edit_menu, self.undo_action) self.redo_action = QtWidgets.QAction("&Redo", self, shortcut=QtGui.QKeySequence.Redo, statusTip="Redo last action if possible", triggered=self.redo_active_frontend) self.add_menu_action(self.edit_menu, self.redo_action) self.edit_menu.addSeparator() self.cut_action = QtWidgets.QAction("&Cut", self, shortcut=QtGui.QKeySequence.Cut, triggered=self.cut_active_frontend ) self.add_menu_action(self.edit_menu, self.cut_action, True) self.copy_action = QtWidgets.QAction("&Copy", self, shortcut=QtGui.QKeySequence.Copy, triggered=self.copy_active_frontend ) self.add_menu_action(self.edit_menu, self.copy_action, True) self.copy_raw_action = QtWidgets.QAction("Copy (&Raw Text)", self, shortcut="Ctrl+Shift+C", triggered=self.copy_raw_active_frontend ) self.add_menu_action(self.edit_menu, self.copy_raw_action, True) self.paste_action = QtWidgets.QAction("&Paste", self, shortcut=QtGui.QKeySequence.Paste, triggered=self.paste_active_frontend ) self.add_menu_action(self.edit_menu, self.paste_action, True) self.edit_menu.addSeparator() selectall = QtGui.QKeySequence(QtGui.QKeySequence.SelectAll) if selectall.matches("Ctrl+A") and sys.platform != 'darwin': # Only override the default if there is a collision. # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX. selectall = "Ctrl+Shift+A" self.select_all_action = QtWidgets.QAction("Select Cell/&All", self, shortcut=selectall, triggered=self.select_all_active_frontend ) self.add_menu_action(self.edit_menu, self.select_all_action, True)
Example #21
Source File: main.py From TuChart with MIT License | 4 votes |
def openMenu(self,position): indexes = self.ui.treeWidget.selectedIndexes() item = self.ui.treeWidget.itemAt(position) db_origin = "" #if item.parent(): # db_origin = item.parent().text(0) collec = str(item.text(0).encode("utf-8")) if len(indexes) > 0: level = 0 index = indexes[0] while index.parent().isValid(): index = index.parent() level = level + 1 menu = QMenu() #print((collec, db_origin)) if level ==0: pass else: #keyarray = GetKeys(collec, db_origin) #if "Open" in keyarray: if self.ui.combobox.currentText()==u"K线": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True))#open up different menu with different kind of graphs menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) #menu.addAction(QAction("P_change", menu, checkable=True)) #menu.addAction(QAction("Turnover",menu,checkable=True)) if self.ui.combobox.currentText()==u"复权": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True)) menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) menu.addAction(QAction("Amount", menu, checkable=True)) if self.ui.combobox.currentText()==u"分笔数据": menu.addAction(QAction("分笔", menu, checkable=True)) if self.ui.combobox.currentText()==u"历史分钟": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True)) menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) menu.addAction(QAction("Amount", menu, checkable=True)) if self.ui.combobox.currentText()==u"十大股东": menu.addAction(QAction("季度饼图", menu, checkable=True)) #menu.addAction(QAction("持股比例", menu, checkable=True)) #for g in keyarray: #menu.addAction(QAction(g, menu, checkable=True)) menu.triggered.connect(lambda action: self.methodSelected(action, collec)) menu.exec_(self.ui.treeWidget.viewport().mapToGlobal(position))
Example #22
Source File: main.py From TuChart with MIT License | 4 votes |
def openMenu(self,position): indexes = self.ui.treeWidget.selectedIndexes() item = self.ui.treeWidget.itemAt(position) db_origin = "" #if item.parent(): # db_origin = item.parent().text(0) collec = str(item.text(0).encode("utf-8")) if len(indexes) > 0: level = 0 index = indexes[0] while index.parent().isValid(): index = index.parent() level = level + 1 menu = QMenu() #print((collec, db_origin)) if level ==0: pass else: #keyarray = GetKeys(collec, db_origin) #if "Open" in keyarray: if self.ui.combobox.currentText()==u"K线": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True))#open up different menu with different kind of graphs menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) #menu.addAction(QAction("P_change", menu, checkable=True)) #menu.addAction(QAction("Turnover",menu,checkable=True)) if self.ui.combobox.currentText()==u"复权": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True)) menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) menu.addAction(QAction("Amount", menu, checkable=True)) if self.ui.combobox.currentText()==u"分笔数据": menu.addAction(QAction("分笔", menu, checkable=True)) if self.ui.combobox.currentText()==u"历史分钟": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True)) menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) menu.addAction(QAction("Amount", menu, checkable=True)) if self.ui.combobox.currentText()==u"十大股东": menu.addAction(QAction("季度饼图", menu, checkable=True)) #menu.addAction(QAction("持股比例", menu, checkable=True)) #for g in keyarray: #menu.addAction(QAction(g, menu, checkable=True)) menu.triggered.connect(lambda action: self.methodSelected(action, collec)) menu.exec_(self.ui.treeWidget.viewport().mapToGlobal(position))
Example #23
Source File: main.py From TuChart with MIT License | 4 votes |
def openMenu(self,position): indexes = self.ui.treeWidget.selectedIndexes() item = self.ui.treeWidget.itemAt(position) db_origin = "" #if item.parent(): # db_origin = item.parent().text(0) collec = item.text(0) if len(indexes) > 0: level = 0 index = indexes[0] while index.parent().isValid(): index = index.parent() level = level + 1 menu = QMenu() #print((collec, db_origin)) if level ==0: pass else: #keyarray = GetKeys(collec, db_origin) #if "Open" in keyarray: if self.ui.combobox.currentText()==u"K线": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True))#open up different menu with different kind of graphs menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) #menu.addAction(QAction("P_change", menu, checkable=True)) #menu.addAction(QAction("Turnover",menu,checkable=True)) if self.ui.combobox.currentText()==u"复权": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True)) menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) menu.addAction(QAction("Amount", menu, checkable=True)) if self.ui.combobox.currentText()==u"分笔数据": menu.addAction(QAction("分笔", menu, checkable=True)) if self.ui.combobox.currentText()==u"历史分钟": menu.addAction(QAction("Kline", menu, checkable=True)) menu.addAction(QAction("Open", menu, checkable=True)) menu.addAction(QAction("Close", menu, checkable=True)) menu.addAction(QAction("High", menu, checkable=True)) menu.addAction(QAction("Low", menu, checkable=True)) menu.addAction(QAction("Volume", menu, checkable=True)) menu.addAction(QAction("Amount", menu, checkable=True)) if self.ui.combobox.currentText()==u"十大股东": menu.addAction(QAction("季度饼图", menu, checkable=True)) #menu.addAction(QAction("持股比例", menu, checkable=True)) #for g in keyarray: #menu.addAction(QAction(g, menu, checkable=True)) menu.triggered.connect(lambda action: self.methodSelected(action, collec)) menu.exec_(self.ui.treeWidget.viewport().mapToGlobal(position))