本文整理汇总了Python中spyderlib.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=get_icon('2uparrow.png'),
triggered=lambda: self.move_to(absolute=0),
text_beside_icon=True)
toolbar.append(movetop_button)
moveup_button = create_toolbutton(self,
text=_("Move up"),
icon=get_icon('1uparrow.png'),
triggered=lambda: self.move_to(relative=-1),
text_beside_icon=True)
toolbar.append(moveup_button)
movedown_button = create_toolbutton(self,
text=_("Move down"),
icon=get_icon('1downarrow.png'),
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=get_icon('2downarrow.png'),
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: setup_bottom_toolbar
def setup_bottom_toolbar(self, layout, sync=True):
toolbar = []
add_button = create_toolbutton(
self, text=_("Add path"), icon=get_icon("edit_add.png"), triggered=self.add_path, text_beside_icon=True
)
toolbar.append(add_button)
remove_button = create_toolbutton(
self,
text=_("Remove path"),
icon=get_icon("edit_remove.png"),
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=get_icon("synchronize.png"),
triggered=self.synchronize,
tip=_("Synchronize Spyder's path list with PYTHONPATH " "environment variable"),
text_beside_icon=True,
)
layout.addWidget(self.sync_button)
return toolbar
示例3: get_toolbar_buttons
def get_toolbar_buttons(self):
ExternalShellBase.get_toolbar_buttons(self)
if self.namespacebrowser_button is None and self.stand_alone:
self.namespacebrowser_button = create_toolbutton(self,
get_icon('dictedit.png'), self.tr("Variables"),
tip=self.tr("Show/hide global variables explorer"),
toggled=self.toggle_globals_explorer)
if self.cwd_button is None:
self.cwd_button = create_toolbutton(self,
get_std_icon('DirOpenIcon'), self.tr("Working directory"),
tip=self.tr("Set current working directory"),
triggered=self.set_current_working_directory)
if self.terminate_button is None:
self.terminate_button = create_toolbutton(self,
get_icon('terminate.png'), self.tr("Terminate"),
tip=self.tr("Attempts to terminate the process.\n"
"The process may not exit as a result of "
"clicking this button\n"
"(it is given the chance to prompt "
"the user for any unsaved files, etc)."))
buttons = [self.cwd_button]
if self.namespacebrowser_button is not None:
buttons.append(self.namespacebrowser_button)
buttons += [self.run_button, self.options_button,
self.terminate_button, self.kill_button]
return buttons
示例4: 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
示例5: get_toolbar_buttons
def get_toolbar_buttons(self):
"""Return toolbar buttons list"""
#TODO: Eventually add some buttons (Empty for now)
# (see for example: spyderlib/widgets/externalshell/baseshell.py)
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
示例6: 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=get_icon("dictedit.png"),
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=get_icon("stop.png"),
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
示例7: get_toolbar_buttons
def get_toolbar_buttons(self):
if self.run_button is None:
self.run_button = create_toolbutton(self, get_icon('run.png'),
translate('ExternalShellBase', "Run"),
tip=translate('ExternalShellBase',
"Run again this program"),
triggered=self.start)
if self.kill_button is None:
self.kill_button = create_toolbutton(self, get_icon('kill.png'),
translate('ExternalShellBase', "Kill"),
tip=translate('ExternalShellBase',
"Kills the current process, "
"causing it to exit immediately"))
buttons = [self.run_button, self.kill_button]
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self,
text=self.tr("Options"),
icon=get_icon('tooloptions.png'))
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.insert(1, self.options_button)
return buttons
示例8: __init__
def __init__(self, parent,
search_text = r"# ?TODO|# ?FIXME|# ?XXX",
search_text_regexp=True, search_path=None,
include=[".", ".py"], include_idx=None, include_regexp=True,
exclude=r"\.pyc$|\.orig$|\.hg|\.svn", exclude_idx=None,
exclude_regexp=True,
supported_encodings=("utf-8", "iso-8859-1", "cp1252"),
in_python_path=False, more_options=False):
QWidget.__init__(self, parent)
self.setWindowTitle(_('Find in files'))
self.search_thread = None
self.get_pythonpath_callback = None
self.find_options = FindOptions(self, search_text, search_text_regexp,
search_path,
include, include_idx, include_regexp,
exclude, exclude_idx, exclude_regexp,
supported_encodings, in_python_path,
more_options)
self.connect(self.find_options, SIGNAL('find()'), self.find)
self.connect(self.find_options, SIGNAL('stop()'),
self.stop_and_reset_thread)
self.result_browser = ResultsBrowser(self)
collapse_btn = create_toolbutton(self)
collapse_btn.setDefaultAction(self.result_browser.collapse_all_action)
expand_btn = create_toolbutton(self)
expand_btn.setDefaultAction(self.result_browser.expand_all_action)
restore_btn = create_toolbutton(self)
restore_btn.setDefaultAction(self.result_browser.restore_action)
# collapse_sel_btn = create_toolbutton(self)
# collapse_sel_btn.setDefaultAction(
# self.result_browser.collapse_selection_action)
# expand_sel_btn = create_toolbutton(self)
# expand_sel_btn.setDefaultAction(
# self.result_browser.expand_selection_action)
btn_layout = QVBoxLayout()
btn_layout.setAlignment(Qt.AlignTop)
for widget in [collapse_btn, expand_btn, restore_btn]:
# collapse_sel_btn, expand_sel_btn]:
btn_layout.addWidget(widget)
hlayout = QHBoxLayout()
hlayout.addWidget(self.result_browser)
hlayout.addLayout(btn_layout)
layout = QVBoxLayout()
left, _x, right, bottom = layout.getContentsMargins()
layout.setContentsMargins(left, 0, right, bottom)
layout.addWidget(self.find_options)
layout.addLayout(hlayout)
self.setLayout(layout)
示例9: get_toolbar_buttons
def get_toolbar_buttons(self):
self.run_button = create_toolbutton(self, get_icon('run.png'),
self.tr("Run"),
tip=self.tr("Run again this program"),
triggered=self.start)
self.kill_button = create_toolbutton(self, get_icon('kill.png'),
self.tr("Kill"),
tip=self.tr("Kills the current process, "
"causing it to exit immediately"))
return [self.run_button, self.kill_button]
示例10: __init__
def __init__(self, parent):
ReadOnlyEditor.__init__(self, parent)
self.shell = None
self.external_console = None
# locked = disable link with Console
self.locked = False
self._last_text = None
# Object name
layout_edit = QHBoxLayout()
layout_edit.addWidget(QLabel(self.tr("Object")))
self.combo = ObjectComboBox(self)
layout_edit.addWidget(self.combo)
self.combo.setMaxCount(CONF.get(self.ID, 'max_history_entries'))
self.combo.addItems( self.load_history() )
self.connect(self.combo, SIGNAL("valid(bool)"),
lambda valid: self.force_refresh())
# Doc/source option
help_or_doc = create_action(self, self.tr("Show source"),
toggled=self.toggle_help)
help_or_doc.setChecked(False)
self.docstring = True
# Automatic import option
auto_import = create_action(self, self.tr("Automatic import"),
toggled=self.toggle_auto_import)
auto_import_state = CONF.get('inspector', 'automatic_import')
auto_import.setChecked(auto_import_state)
# Lock checkbox
self.locked_button = create_toolbutton(self,
triggered=self.toggle_locked)
layout_edit.addWidget(self.locked_button)
self._update_lock_icon()
# Option menu
options_button = create_toolbutton(self, text=self.tr("Options"),
icon=get_icon('tooloptions.png'))
options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, [help_or_doc, auto_import])
options_button.setMenu(menu)
layout_edit.addWidget(options_button)
# Main layout
layout = QVBoxLayout()
layout.addLayout(layout_edit)
layout.addWidget(self.editor)
layout.addWidget(self.find_widget)
self.setLayout(layout)
示例11: setup_buttons
def setup_buttons(self):
fromcursor_btn = create_toolbutton(self, get_icon("fromcursor.png"),
tip=translate('ClassBrowser', 'Go to cursor position'),
triggered=self.treewidget.go_to_cursor_position)
collapse_btn = create_toolbutton(self, text_beside_icon=False)
collapse_btn.setDefaultAction(self.treewidget.collapse_selection_action)
expand_btn = create_toolbutton(self, text_beside_icon=False)
expand_btn.setDefaultAction(self.treewidget.expand_selection_action)
restore_btn = create_toolbutton(self, text_beside_icon=False)
restore_btn.setDefaultAction(self.treewidget.restore_action)
return (fromcursor_btn, collapse_btn, expand_btn, restore_btn)
示例12: setup_buttons
def setup_buttons(self):
fromcursor_btn = create_toolbutton(self,
icon=get_icon("fromcursor.png"),
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)
示例13: __init__
def __init__(self, parent, actions=None, menu=None,
corner_widgets=None, menu_use_tooltips=False):
QTabWidget.__init__(self, parent)
self.setUsesScrollButtons(True)
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=get_icon("browse_tab.png"),
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)
示例14: __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)
示例15: __init__
def __init__(self, parent):
self.tabwidget = None
self.menu_actions = None
self.dockviewer = None
self.editors = []
self.filenames = []
self.icons = []
SpyderPluginWidget.__init__(self, parent)
layout = QVBoxLayout()
self.tabwidget = Tabs(self, self.menu_actions)
self.connect(self.tabwidget, SIGNAL('currentChanged(int)'),
self.refresh_plugin)
self.connect(self.tabwidget, SIGNAL('move_data(int,int)'),
self.move_tab)
layout.addWidget(self.tabwidget)
# Menu as corner widget
options_button = create_toolbutton(self, text=self.tr("Options"),
icon=get_icon('tooloptions.png'))
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()
layout.addWidget(self.find_widget)
self.setLayout(layout)