本文整理汇总了Python中spyder.utils.qthelpers.create_toolbutton函数的典型用法代码示例。如果您正苦于以下问题:Python create_toolbutton函数的具体用法?Python create_toolbutton怎么用?Python create_toolbutton使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_toolbutton函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_top_toolbar
def setup_top_toolbar(self, layout):
toolbar = []
movetop_button = create_toolbutton(self,
text=_("Move to top"),
icon=ima.icon('2uparrow'),
triggered=lambda: self.move_to(absolute=0),
text_beside_icon=True)
toolbar.append(movetop_button)
moveup_button = create_toolbutton(self,
text=_("Move up"),
icon=ima.icon('1uparrow'),
triggered=lambda: self.move_to(relative=-1),
text_beside_icon=True)
toolbar.append(moveup_button)
movedown_button = create_toolbutton(self,
text=_("Move down"),
icon=ima.icon('1downarrow'),
triggered=lambda: self.move_to(relative=1),
text_beside_icon=True)
toolbar.append(movedown_button)
movebottom_button = create_toolbutton(self,
text=_("Move to bottom"),
icon=ima.icon('2downarrow'),
triggered=lambda: self.move_to(absolute=1),
text_beside_icon=True)
toolbar.append(movebottom_button)
self.selection_widgets.extend(toolbar)
self._add_widgets_to_layout(layout, toolbar)
return toolbar
示例2: get_toolbar_buttons
def get_toolbar_buttons(self):
"""Return toolbar buttons list"""
buttons = []
# Code to add the stop button
if self.stop_button is None:
self.stop_button = create_toolbutton(self, text=_("Stop"),
icon=self.stop_icon,
tip=_("Stop the current command"))
self.disable_stop_button()
# set click event handler
self.stop_button.clicked.connect(self.stop_button_click_handler)
if self.stop_button is not None:
buttons.append(self.stop_button)
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self,
text=_('Options'), icon=ima.icon('tooloptions'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, options)
self.options_button.setMenu(menu)
if self.options_button is not None:
buttons.append(self.options_button)
return buttons
示例3: get_toolbar_buttons
def get_toolbar_buttons(self):
if self.run_button is None:
self.run_button = create_toolbutton(self, text=_("Run"),
icon=ima.icon('run'),
tip=_("Run again this program"),
triggered=self.start_shell)
if self.kill_button is None:
self.kill_button = create_toolbutton(self, text=_("Kill"),
icon=ima.icon('kill'),
tip=_("Kills the current process, "
"causing it to exit immediately"))
buttons = [self.run_button]
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self, text=_('Options'),
icon=ima.icon('tooloptions'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, options)
self.options_button.setMenu(menu)
if self.options_button is not None:
buttons.append(self.options_button)
buttons.append(self.kill_button)
return buttons
示例4: setup_toolbar
def setup_toolbar(self, exclude_private, exclude_uppercase,
exclude_capitalized, exclude_unsupported):
"""Setup toolbar"""
self.setup_in_progress = True
toolbar = []
load_button = create_toolbutton(self, text=_('Import data'),
icon=ima.icon('fileimport'),
triggered=lambda: self.import_data())
self.save_button = create_toolbutton(self, text=_("Save data"),
icon=ima.icon('filesave'),
triggered=lambda: self.save_data(self.filename))
self.save_button.setEnabled(False)
save_as_button = create_toolbutton(self,
text=_("Save data as..."),
icon=ima.icon('filesaveas'),
triggered=self.save_data)
reset_namespace_button = create_toolbutton(
self, text=_("Reset the namespace"),
icon=ima.icon('editclear'), triggered=self.reset_namespace)
toolbar += [load_button, self.save_button, save_as_button,
reset_namespace_button]
self.exclude_private_action = create_action(self,
_("Exclude private references"),
tip=_("Exclude references which name starts"
" with an underscore"),
toggled=lambda state:
self.sig_option_changed.emit('exclude_private', state))
self.exclude_private_action.setChecked(exclude_private)
self.exclude_uppercase_action = create_action(self,
_("Exclude all-uppercase references"),
tip=_("Exclude references which name is uppercase"),
toggled=lambda state:
self.sig_option_changed.emit('exclude_uppercase', state))
self.exclude_uppercase_action.setChecked(exclude_uppercase)
self.exclude_capitalized_action = create_action(self,
_("Exclude capitalized references"),
tip=_("Exclude references which name starts with an "
"uppercase character"),
toggled=lambda state:
self.sig_option_changed.emit('exclude_capitalized', state))
self.exclude_capitalized_action.setChecked(exclude_capitalized)
self.exclude_unsupported_action = create_action(self,
_("Exclude unsupported data types"),
tip=_("Exclude references to unsupported data types"
" (i.e. which won't be handled/saved correctly)"),
toggled=lambda state:
self.sig_option_changed.emit('exclude_unsupported', state))
self.exclude_unsupported_action.setChecked(exclude_unsupported)
self.setup_in_progress = False
return toolbar
示例5: setup_buttons
def setup_buttons(self):
fromcursor_btn = create_toolbutton(self,
icon=ima.icon('fromcursor'),
tip=_('Go to cursor position'),
triggered=self.treewidget.go_to_cursor_position)
collapse_btn = create_toolbutton(self)
collapse_btn.setDefaultAction(self.treewidget.collapse_selection_action)
expand_btn = create_toolbutton(self)
expand_btn.setDefaultAction(self.treewidget.expand_selection_action)
restore_btn = create_toolbutton(self)
restore_btn.setDefaultAction(self.treewidget.restore_action)
return (fromcursor_btn, collapse_btn, expand_btn, restore_btn)
示例6: setup_buttons
def setup_buttons(self):
"""Setup the buttons of the outline explorer widget toolbar."""
self.fromcursor_btn = create_toolbutton(
self, icon=ima.icon('fromcursor'), tip=_('Go to cursor position'),
triggered=self.treewidget.go_to_cursor_position)
buttons = [self.fromcursor_btn]
for action in [self.treewidget.collapse_all_action,
self.treewidget.expand_all_action,
self.treewidget.restore_action,
self.treewidget.collapse_selection_action,
self.treewidget.expand_selection_action]:
buttons.append(create_toolbutton(self))
buttons[-1].setDefaultAction(action)
return buttons
示例7: __init__
def __init__(self, parent, actions=None, menu=None,
corner_widgets=None, menu_use_tooltips=False):
QTabWidget.__init__(self, parent)
self.setUsesScrollButtons(True)
# To style tabs on Mac
if sys.platform == 'darwin':
self.setObjectName('plugin-tab')
self.corner_widgets = {}
self.menu_use_tooltips = menu_use_tooltips
if menu is None:
self.menu = QMenu(self)
if actions:
add_actions(self.menu, actions)
else:
self.menu = menu
# Corner widgets
if corner_widgets is None:
corner_widgets = {}
corner_widgets.setdefault(Qt.TopLeftCorner, [])
corner_widgets.setdefault(Qt.TopRightCorner, [])
self.browse_button = create_toolbutton(self,
icon=ima.icon('browse_tab'),
tip=_("Browse tabs"))
self.browse_tabs_menu = QMenu(self)
self.browse_button.setMenu(self.browse_tabs_menu)
self.browse_button.setPopupMode(self.browse_button.InstantPopup)
self.browse_tabs_menu.aboutToShow.connect(self.update_browse_tabs_menu)
corner_widgets[Qt.TopLeftCorner] += [self.browse_button]
self.set_corner_widgets(corner_widgets)
示例8: get_toolbar_buttons
def get_toolbar_buttons(self):
"""Return toolbar buttons list."""
buttons = []
# Code to add the stop button
if self.stop_button is None:
self.stop_button = create_toolbutton(
self,
text=_("Stop"),
icon=self.stop_icon,
tip=_("Stop the current command"))
self.disable_stop_button()
# set click event handler
self.stop_button.clicked.connect(self.stop_button_click_handler)
if is_dark_interface():
self.stop_button.setStyleSheet("QToolButton{padding: 3px;}")
if self.stop_button is not None:
buttons.append(self.stop_button)
# Reset namespace button
if self.reset_button is None:
self.reset_button = create_toolbutton(
self,
text=_("Remove"),
icon=ima.icon('editdelete'),
tip=_("Remove all variables"),
triggered=self.reset_namespace)
if is_dark_interface():
self.reset_button.setStyleSheet("QToolButton{padding: 3px;}")
if self.reset_button is not None:
buttons.append(self.reset_button)
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self,
text=_('Options'), icon=ima.icon('tooloptions'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, options)
self.options_button.setMenu(menu)
if self.options_button is not None:
buttons.append(self.options_button)
return buttons
示例9: setup_toolbar
def setup_toolbar(self):
"""Setup the toolbar."""
self.savefig_btn = create_toolbutton(
self, icon=ima.icon('filesave'),
tip=_("Save Image As..."),
triggered=self.emit_save_figure)
self.delfig_btn = create_toolbutton(
self, icon=ima.icon('editclear'),
tip=_("Delete image"),
triggered=self.emit_remove_figure)
toolbar = QVBoxLayout()
toolbar.setContentsMargins(0, 0, 0, 0)
toolbar.setSpacing(1)
toolbar.addWidget(self.savefig_btn)
toolbar.addWidget(self.delfig_btn)
toolbar.addStretch(2)
return toolbar
示例10: setup_toolbar
def setup_toolbar(self):
"""Setup toolbar"""
load_button = create_toolbutton(self, text=_('Import data'),
icon=ima.icon('fileimport'),
triggered=lambda: self.import_data())
self.save_button = create_toolbutton(self, text=_("Save data"),
icon=ima.icon('filesave'),
triggered=lambda: self.save_data(self.filename))
self.save_button.setEnabled(False)
save_as_button = create_toolbutton(self,
text=_("Save data as..."),
icon=ima.icon('filesaveas'),
triggered=self.save_data)
reset_namespace_button = create_toolbutton(
self, text=_("Remove all variables"),
icon=ima.icon('editdelete'), triggered=self.reset_namespace)
return [load_button, self.save_button, save_as_button,
reset_namespace_button]
示例11: get_toolbar_buttons
def get_toolbar_buttons(self):
ExternalShellBase.get_toolbar_buttons(self)
if self.namespacebrowser_button is None \
and self.stand_alone is not None:
self.namespacebrowser_button = create_toolbutton(self,
text=_("Variables"), icon=ima.icon('dictedit'),
tip=_("Show/hide global variables explorer"),
toggled=self.toggle_globals_explorer, text_beside_icon=True)
if self.terminate_button is None:
self.terminate_button = create_toolbutton(self,
text=_("Terminate"), icon=ima.icon('stop'),
tip=_("Attempts to stop the process. The process\n"
"may not exit as a result of clicking this\n"
"button (it is given the chance to prompt\n"
"the user for any unsaved files, etc)."))
buttons = []
if self.namespacebrowser_button is not None:
buttons.append(self.namespacebrowser_button)
buttons += [self.run_button, self.terminate_button, self.kill_button,
self.options_button]
return buttons
示例12: setup_bottom_toolbar
def setup_bottom_toolbar(self, layout, sync=True):
toolbar = []
add_button = create_toolbutton(self, text=_('Add path'),
icon=ima.icon('edit_add'),
triggered=self.add_path,
text_beside_icon=True)
toolbar.append(add_button)
remove_button = create_toolbutton(self, text=_('Remove path'),
icon=ima.icon('edit_remove'),
triggered=self.remove_path,
text_beside_icon=True)
toolbar.append(remove_button)
self.selection_widgets.append(remove_button)
self._add_widgets_to_layout(layout, toolbar)
layout.addStretch(1)
if os.name == 'nt' and sync:
self.sync_button = create_toolbutton(self,
text=_("Synchronize..."),
icon=ima.icon('fileimport'), triggered=self.synchronize,
tip=_("Synchronize Spyder's path list with PYTHONPATH "
"environment variable"),
text_beside_icon=True)
layout.addWidget(self.sync_button)
return toolbar
示例13: __init__
def __init__(self, parent):
self.tabwidget = None
self.menu_actions = None
self.dockviewer = None
self.wrap_action = None
self.editors = []
self.filenames = []
if PYQT5:
SpyderPluginWidget.__init__(self, parent, main = parent)
else:
SpyderPluginWidget.__init__(self, parent)
# Initialize plugin
self.initialize_plugin()
layout = QVBoxLayout()
self.tabwidget = Tabs(self, self.menu_actions)
self.tabwidget.currentChanged.connect(self.refresh_plugin)
self.tabwidget.move_data.connect(self.move_tab)
if sys.platform == 'darwin':
tab_container = QWidget()
tab_container.setObjectName('tab-container')
tab_layout = QHBoxLayout(tab_container)
tab_layout.setContentsMargins(0, 0, 0, 0)
tab_layout.addWidget(self.tabwidget)
layout.addWidget(tab_container)
else:
layout.addWidget(self.tabwidget)
# Menu as corner widget
options_button = create_toolbutton(self, text=_('Options'),
icon=ima.icon('tooloptions'))
options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, self.menu_actions)
options_button.setMenu(menu)
self.tabwidget.setCornerWidget(options_button)
# Find/replace widget
self.find_widget = FindReplace(self)
self.find_widget.hide()
self.register_widget_shortcuts(self.find_widget)
layout.addWidget(self.find_widget)
self.setLayout(layout)
示例14: setup_options_button
def setup_options_button(self):
"""Add the cog menu button to the toolbar."""
if not self.options_button:
self.options_button = create_toolbutton(
self, text=_('Options'), icon=ima.icon('tooloptions'))
actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions
self.options_menu = QMenu(self)
add_actions(self.options_menu, actions)
self.options_button.setMenu(self.options_menu)
if self.tools_layout.itemAt(self.tools_layout.count() - 1) is None:
self.tools_layout.insertWidget(
self.tools_layout.count() - 1, self.options_button)
else:
self.tools_layout.addWidget(self.options_button)
示例15: set_close_function
def set_close_function(self, func):
"""Setting Tabs close function
None -> tabs are not closable"""
state = func is not None
if state:
self.sig_close_tab.connect(func)
try:
# Assuming Qt >= 4.5
QTabWidget.setTabsClosable(self, state)
self.tabCloseRequested.connect(func)
except AttributeError:
# Workaround for Qt < 4.5
close_button = create_toolbutton(self, triggered=func,
icon=ima.icon('fileclose'),
tip=_("Close current tab"))
self.setCornerWidget(close_button if state else None)