本文整理汇总了Python中python_qt_binding.QtGui.QPushButton.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setIcon方法的具体用法?Python QPushButton.setIcon怎么用?Python QPushButton.setIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setIcon方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MasterSyncButtonHelper
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setIcon [as 别名]
class MasterSyncButtonHelper(QObject):
'''
This is helper class to which contains a button and can emit signals. The
MasterSyncItem can not emit signals, but is used in QStandardModel.
'''
clicked = Signal(bool, str)
NOT_SYNC = 0
SWITCHED = 1
SYNC = 2
ICON_PREFIX = 'irondevil'
# ICON_PREFIX = 'crystal_clear'
def __init__(self, master):
QObject.__init__(self)
self.name = master.name
self._master = master
self._syncronized = MasterSyncButtonHelper.NOT_SYNC
self.ICONS = {MasterSyncButtonHelper.SYNC: QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
MasterSyncButtonHelper.NOT_SYNC: QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
MasterSyncButtonHelper.SWITCHED: QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)}
self.widget = QPushButton()
# self.widget.setFlat(True)
self.widget.setIcon(self.ICONS[MasterSyncButtonHelper.NOT_SYNC])
self.widget.setMaximumSize(48, 48)
self.widget.setCheckable(True)
self.widget.clicked.connect(self.on_sync_clicked)
def on_sync_clicked(self, checked):
self.set_sync_state(MasterSyncButtonHelper.SWITCHED)
self.clicked.emit(checked, self._master.uri)
def master(self):
return self._master
def get_sync_state(self):
return self._syncronized
def set_sync_state(self, value):
if self._syncronized != value:
self._syncronized = value
if value in self.ICONS:
self.widget.setIcon(self.ICONS[value])
self.widget.setChecked(value == MasterSyncButtonHelper.SYNC)
def __eq__(self, item):
if isinstance(item, str) or isinstance(item, unicode):
return self.master.name.lower() == item.lower()
elif not (item is None):
return self.master.name.lower() == item.master.name.lower()
return False
def __gt__(self, item):
if isinstance(item, str) or isinstance(item, unicode):
return self.master.name.lower() > item.lower()
elif not (item is None):
return self.master.name.lower() > item.master.name.lower()
return False
示例2: __init__
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setIcon [as 别名]
def __init__(self, parent = None, topic_type = str(), is_action_topic = False):
QWidget.__init__(self, parent)
if is_action_topic:
self.topic_type = topic_type + "Goal"
else:
self.topic_type = topic_type
self.is_action_topic = is_action_topic
# start widget
hbox = QHBoxLayout()
hbox.setMargin(0)
hbox.setContentsMargins(0, 0, 0, 0)
# topic combo box
self.topic_combo_box = QComboBox()
self.topic_combo_box.setEnabled(False)
self.topic_combo_box.blockSignals(True)
self.topic_combo_box.setValidator(QRegExpValidator(QRegExp('((\d|\w|/)(?!//))*'), self))
self.topic_combo_box.currentIndexChanged[str].connect(self.topic_changed)
hbox.addWidget(self.topic_combo_box)
# get system icon
icon = QIcon.fromTheme("view-refresh")
size = icon.actualSize(QSize(32, 32))
# add refresh button
refresh_topics_button = QPushButton()
refresh_topics_button.clicked.connect(self.update_topic_list)
refresh_topics_button.setIcon(icon)
refresh_topics_button.setFixedSize(size.width()+2, size.height()+2)
hbox.addWidget(refresh_topics_button)
# end widget
self.setLayout(hbox)
# init widget
self.update_topic_list()
示例3: __init__
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setIcon [as 别名]
def __init__(self, parent=None):
super(VisualizerWidget, self).__init__(parent)
self.setWindowTitle('Graph Profiler Visualizer')
vbox = QVBoxLayout()
self.setLayout(vbox)
toolbar_layout = QHBoxLayout()
refresh_button = QPushButton()
refresh_button.setIcon(QIcon.fromTheme('view-refresh'))
auto_refresh_checkbox = QCheckBox("Auto Refresh")
hide_disconnected_topics = QCheckBox("Hide Disconnected Topics")
topic_blacklist_button = QPushButton("Topic Blacklist")
node_blacklist_button = QPushButton("Node Blacklist")
refresh_button.clicked.connect(self._refresh)
topic_blacklist_button.clicked.connect(self._edit_topic_blacklist)
node_blacklist_button.clicked.connect(self._edit_node_blacklist)
auto_refresh_checkbox.setCheckState(2)
auto_refresh_checkbox.stateChanged.connect(self._autorefresh_changed)
hide_disconnected_topics.setCheckState(2)
hide_disconnected_topics.stateChanged.connect(self._hidedisconnectedtopics_changed)
toolbar_layout.addWidget(refresh_button)
toolbar_layout.addWidget(auto_refresh_checkbox)
toolbar_layout.addStretch(0)
toolbar_layout.addWidget(hide_disconnected_topics)
toolbar_layout.addWidget(topic_blacklist_button)
toolbar_layout.addWidget(node_blacklist_button)
vbox.addLayout(toolbar_layout)
# Initialize the Visualizer
self._view = qt_view.QtView()
self._adapter = rosprofiler_adapter.ROSProfileAdapter(self._view)
self._adapter.set_topic_quiet_list(TOPIC_BLACKLIST)
self._adapter.set_node_quiet_list(NODE_BLACKLIST)
vbox.addWidget(self._view)
示例4: PlotWidget
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setIcon [as 别名]
class PlotWidget(QWidget):
def __init__(self, timeline, parent, topic):
super(PlotWidget, self).__init__(parent)
self.setObjectName('PlotWidget')
self.timeline = timeline
msg_type = self.timeline.get_datatype(topic)
self.msgtopic = topic
self.start_stamp = self.timeline._get_start_stamp()
self.end_stamp = self.timeline._get_end_stamp()
# the current region-of-interest for our bag file
# all resampling and plotting is done with these limits
self.limits = [0,(self.end_stamp-self.start_stamp).to_sec()]
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('rqt_bag_plugins'), 'resource', 'plot.ui')
loadUi(ui_file, self)
self.message_tree = MessageTree(msg_type, self)
self.data_tree_layout.addWidget(self.message_tree)
# TODO: make this a dropdown with choices for "Auto", "Full" and
# "Custom"
# I continue to want a "Full" option here
self.auto_res.stateChanged.connect(self.autoChanged)
self.resolution.editingFinished.connect(self.settingsChanged)
self.resolution.setValidator(QDoubleValidator(0.0,1000.0,6,self.resolution))
self.timeline.selected_region_changed.connect(self.region_changed)
self.recompute_timestep()
self.plot = DataPlot(self)
self.plot.set_autoscale(x=False)
self.plot.set_autoscale(y=DataPlot.SCALE_VISIBLE)
self.plot.autoscroll(False)
self.plot.set_xlim(self.limits)
self.data_plot_layout.addWidget(self.plot)
self._home_button = QPushButton()
self._home_button.setToolTip("Reset View")
self._home_button.setIcon(QIcon.fromTheme('go-home'))
self._home_button.clicked.connect(self.home)
self.plot_toolbar_layout.addWidget(self._home_button)
self._config_button = QPushButton("Configure Plot")
self._config_button.clicked.connect(self.plot.doSettingsDialog)
self.plot_toolbar_layout.addWidget(self._config_button)
self.set_cursor(0)
self.paths_on = set()
self._lines = None
# get bag from timeline
bag = None
start_time = self.start_stamp
while bag is None:
bag,entry = self.timeline.get_entry(start_time, topic)
if bag is None:
start_time = self.timeline.get_entry_after(start_time)[1].time
self.bag = bag
# get first message from bag
msg = bag._read_message(entry.position)
self.message_tree.set_message(msg[1])
# state used by threaded resampling
self.resampling_active = False
self.resample_thread = None
self.resample_fields = set()
def set_cursor(self, position):
self.plot.vline(position, color=DataPlot.RED)
self.plot.redraw()
def add_plot(self, path):
self.resample_data([path])
def update_plot(self):
if len(self.paths_on)>0:
self.resample_data(self.paths_on)
def remove_plot(self, path):
self.plot.remove_curve(path)
self.paths_on.remove(path)
self.plot.redraw()
def load_data(self):
"""get a generator for the specified time range on our bag"""
return self.bag.read_messages(self.msgtopic,
self.start_stamp+rospy.Duration.from_sec(self.limits[0]),
self.start_stamp+rospy.Duration.from_sec(self.limits[1]))
def resample_data(self, fields):
if self.resample_thread:
# cancel existing thread and join
self.resampling_active = False
#.........这里部分代码省略.........
示例5: QParameterSetSelectionWidget
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setIcon [as 别名]
class QParameterSetSelectionWidget(QWidgetWithLogger):
NO_PARAM_SET_TEXT = "No parameters available!"
SELECT_TEXT = "<Select>"
param_cleared_signal = Signal()
param_changed_signal = Signal(str)
def __init__(self, parent = None, logger = Logger()):
QWidgetWithLogger.__init__(self, parent, logger)
# start widget
hbox = QHBoxLayout()
hbox.setMargin(0)
hbox.setContentsMargins(0, 0, 0, 0)
# get system icon
icon = QIcon.fromTheme("view-refresh")
size = icon.actualSize(QSize(32, 32))
# add combo box
self.parameter_set_names_combo_box = QComboBox()
self.parameter_set_names_combo_box.currentIndexChanged[str].connect(self.param_changed)
hbox.addWidget(self.parameter_set_names_combo_box)
# add refresh button
self.get_all_parameter_set_names_button = QPushButton()
self.get_all_parameter_set_names_button.clicked.connect(self._get_all_parameter_set_names)
self.get_all_parameter_set_names_button.setIcon(icon)
self.get_all_parameter_set_names_button.setFixedSize(size.width()+2, size.height()+2)
hbox.addWidget(self.get_all_parameter_set_names_button)
# end widget
self.setLayout(hbox)
# init widget
self.reset_parameter_set_selection()
def _init_action_client(self, topic_name):
self.get_parameter_set_names_client = actionlib.SimpleActionClient(topic_name, GetParameterSetNamesAction)
print "Parameter set topic changed: " + topic_name
@Slot(str)
def set_topic_name(self, topic_name):
if (len(topic_name) > 0):
self._init_action_client(topic_name)
self._get_all_parameter_set_names()
else:
self.reset_parameter_set_selection()
def reset_parameter_set_selection(self):
self.parameter_set_names_combo_box.setEnabled(False)
self.parameter_set_names_combo_box.blockSignals(True)
self.parameter_set_names_combo_box.clear()
self.parameter_set_names_combo_box.addItem(self.NO_PARAM_SET_TEXT)
self.get_all_parameter_set_names_button.setEnabled(False)
self.param_cleared_signal.emit()
def current_parameter_set_name(self):
if self.parameter_set_names_combo_box.currentText() == self.NO_PARAM_SET_TEXT:
return str()
else:
return self.parameter_set_names_combo_box.currentText()
@Slot(str)
def param_changed(self, name):
self.param_changed_signal.emit(name)
# parameter set names handler
def _get_all_parameter_set_names(self):
if (self.get_parameter_set_names_client.wait_for_server(rospy.Duration(0.5))):
self.logger.log_info("Requesting current list of parameter set names.")
goal = GetParameterSetNamesGoal()
self.get_parameter_set_names_client.send_goal(goal)
# waiting for getting list of parameter set names
if (self.get_parameter_set_names_client.wait_for_result(rospy.Duration(1.0))):
result = self.get_parameter_set_names_client.get_result()
self.logger.log_info("Received " + str(len(result.names)) + " parameter set names.")
self.parameter_set_names_combo_box.blockSignals(True)
self.parameter_set_names_combo_box.clear()
self.parameter_set_names_combo_box.addItem(self.SELECT_TEXT)
self.parameter_set_names_combo_box.setItemData(0, 0, Qt.UserRole-1)
self.param_cleared_signal.emit()
for name in result.names:
self.parameter_set_names_combo_box.addItem(name.data)
self.parameter_set_names_combo_box.setEnabled(True)
self.parameter_set_names_combo_box.blockSignals(False)
self.get_all_parameter_set_names_button.setEnabled(True)
else:
self.logger.log_error("Didn't received any results. Check communcation!")
self.reset_parameter_set_selection()
else:
self.logger.log_error("Can't connect to footstep planner parameter action server!")
#.........这里部分代码省略.........
示例6: Editor
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setIcon [as 别名]
class Editor(QMainWindow):
'''
Creates a dialog to edit a launch file.
'''
finished_signal = Signal(list)
'''
finished_signal has as parameter the filenames of the initialization and is emitted, if this
dialog was closed.
'''
def __init__(self, filenames, search_text='', parent=None):
'''
@param filenames: a list with filenames. The last one will be activated.
@type filenames: C{[str, ...]}
@param search_text: if not empty, searches in new document for first occurrence of the given text
@type search_text: C{str} (Default: C{Empty String})
'''
QMainWindow.__init__(self, parent)
self.setObjectName('Editor - %s' % utf8(filenames))
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setWindowFlags(Qt.Window)
self.mIcon = QIcon(":/icons/crystal_clear_edit_launch.png")
self._error_icon = QIcon(":/icons/crystal_clear_warning.png")
self._empty_icon = QIcon()
self.setWindowIcon(self.mIcon)
window_title = "ROSLaunch Editor"
if filenames:
window_title = self.__getTabName(filenames[0])
self.setWindowTitle(window_title)
self.init_filenames = list(filenames)
self._search_thread = None
# list with all open files
self.files = []
# create tabs for files
self.main_widget = QWidget(self)
self.verticalLayout = QVBoxLayout(self.main_widget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(1)
self.verticalLayout.setObjectName("verticalLayout")
self.tabWidget = EditorTabWidget(self)
self.tabWidget.setTabPosition(QTabWidget.North)
self.tabWidget.setDocumentMode(True)
self.tabWidget.setTabsClosable(True)
self.tabWidget.setMovable(False)
self.tabWidget.setObjectName("tabWidget")
self.tabWidget.tabCloseRequested.connect(self.on_close_tab)
self.tabWidget.currentChanged.connect(self.on_tab_changed)
self.verticalLayout.addWidget(self.tabWidget)
self.buttons = self._create_buttons()
self.verticalLayout.addWidget(self.buttons)
self.setCentralWidget(self.main_widget)
self.find_dialog = TextSearchFrame(self.tabWidget, self)
self.find_dialog.search_result_signal.connect(self.on_search_result)
self.find_dialog.replace_signal.connect(self.on_replace)
self.addDockWidget(Qt.RightDockWidgetArea, self.find_dialog)
self.graph_view = GraphViewWidget(self.tabWidget, self)
self.graph_view.load_signal.connect(self.on_graph_load_file)
self.graph_view.goto_signal.connect(self.on_graph_goto)
self.addDockWidget(Qt.RightDockWidgetArea, self.graph_view)
# open the files
for f in filenames:
if f:
self.on_load_request(os.path.normpath(f), search_text)
self.readSettings()
self.find_dialog.setVisible(False)
self.graph_view.setVisible(False)
# def __del__(self):
# print "******** destroy", self.objectName()
def _create_buttons(self):
# create the buttons line
self.buttons = QWidget(self)
self.horizontalLayout = QHBoxLayout(self.buttons)
self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
# add open upper launchfile button
self.upperButton = QPushButton(self)
self.upperButton.setObjectName("upperButton")
self.upperButton.clicked.connect(self.on_upperButton_clicked)
self.upperButton.setIcon(QIcon(":/icons/up.png"))
self.upperButton.setShortcut("Ctrl+U")
self.upperButton.setToolTip('Open the file which include the current file (Ctrl+U)')
self.upperButton.setFlat(True)
self.horizontalLayout.addWidget(self.upperButton)
# add the goto button
self.gotoButton = QPushButton(self)
self.gotoButton.setObjectName("gotoButton")
self.gotoButton.clicked.connect(self.on_shortcut_goto)
self.gotoButton.setText(self._translate("&Goto line"))
self.gotoButton.setShortcut("Ctrl+G")
self.gotoButton.setToolTip('Open a goto dialog (Ctrl+G)')
self.gotoButton.setFlat(True)
self.horizontalLayout.addWidget(self.gotoButton)
# add a tag button
#.........这里部分代码省略.........