本文整理汇总了Python中guidata.qt.QtGui.QPushButton类的典型用法代码示例。如果您正苦于以下问题:Python QPushButton类的具体用法?Python QPushButton怎么用?Python QPushButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPushButton类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
QWidget.__init__(self)
self.setWindowTitle( 'Biofeedback' )
self.button_start = QPushButton()
self.button_start.setText("START")
self.button_stop = QPushButton()
self.button_stop.setText("STOP")
layout = QHBoxLayout(self)
layout.addWidget(self.button_start)
layout.addWidget(self.button_stop)
self.connect(self.button_start, SIGNAL("clicked(bool)"), self.start_session)
self.connect(self.button_stop, SIGNAL("clicked(bool)"), self.stop_session)
self.setLayout(layout)
self.setGeometry(300,100,250,100)
self.show()
#self.datastorage = DataStorage()
#settings = {'db_host':'amber','db_user':'root','db_pwd':'dbrootpass','db_dbname':'biodb'}
#self.datastorage.enableDbStorage(settings)
self.thread = ConnectionThread()
示例2: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
info_icon = QLabel()
icon = get_std_icon("MessageBoxInformation").pixmap(24, 24)
info_icon.setPixmap(icon)
info_icon.setFixedWidth(32)
info_icon.setAlignment(Qt.AlignTop)
self.service_status_label = QLabel()
self.service_status_label.setWordWrap(True)
self.service_status_label.setAlignment(Qt.AlignTop)
self.service_status_label.setFont(font)
self.desc_label = QLabel()
self.desc_label.setWordWrap(True)
self.desc_label.setAlignment(Qt.AlignTop)
self.desc_label.setFont(font)
self.group_desc = QGroupBox("Description", self)
layout = QHBoxLayout()
layout.addWidget(info_icon)
layout.addWidget(self.desc_label)
layout.addStretch()
layout.addWidget(self.service_status_label)
self.group_desc.setLayout(layout)
self.editor = CodeEditor(self)
self.editor.setup_editor(linenumbers=True, font=font)
self.editor.setReadOnly(False)
self.group_code = QGroupBox("Source code", self)
layout = QVBoxLayout()
layout.addWidget(self.editor)
self.group_code.setLayout(layout)
self.enable_button = QPushButton(get_icon("apply.png"), "Enable", self)
self.save_button = QPushButton(get_icon("filesave.png"), "Save", self)
self.disable_button = QPushButton(get_icon("delete.png"), "Disable", self)
self.refresh_button = QPushButton(get_icon("restart.png"), "Refresh", self)
hlayout = QHBoxLayout()
hlayout.addWidget(self.save_button)
hlayout.addWidget(self.enable_button)
hlayout.addWidget(self.disable_button)
hlayout.addWidget(self.refresh_button)
vlayout = QVBoxLayout()
vlayout.addWidget(self.group_desc)
vlayout.addWidget(self.group_code)
self.html_window = HTMLWindow()
vlayout.addWidget(self.html_window)
vlayout.addLayout(hlayout)
self.setLayout(vlayout)
self.current_file = None
示例3: ColorWidget
class ColorWidget(HLayoutMixin, LineEditWidget):
"""
ColorItem widget
"""
def __init__(self, item, parent_layout):
super(ColorWidget, self).__init__(item, parent_layout)
self.button = QPushButton("")
self.button.setMaximumWidth(32)
self.button.clicked.connect(self.select_color)
self.group.addWidget(self.button)
def update(self, value):
"""Reimplement LineEditWidget method"""
LineEditWidget.update(self, value)
color = text_to_qcolor(value)
if color.isValid():
bitmap = QPixmap(16, 16)
bitmap.fill(color)
icon = QIcon(bitmap)
else:
icon = get_icon("not_found")
self.button.setIcon(icon)
def select_color(self):
"""Open a color selection dialog box"""
color = text_to_qcolor(self.edit.text())
if not color.isValid():
color = Qt.gray
color = QColorDialog.getColor(color, self.parent_layout.parent)
if color.isValid():
value = color.name()
self.edit.setText(value)
self.update(value)
示例4: __init__
def __init__(self, item, parent_layout):
super(FloatArrayWidget, self).__init__(item, parent_layout)
_label = item.get_prop_value("display", "label")
self.groupbox = self.group = QGroupBox(_label)
self.layout = QGridLayout()
self.layout.setAlignment(Qt.AlignLeft)
self.groupbox.setLayout(self.layout)
self.first_line, self.dim_label = get_image_layout("shape.png",
_("Number of rows x Number of columns"))
edit_button = QPushButton(get_icon("arredit.png"), "")
edit_button.setToolTip(_("Edit array contents"))
edit_button.setMaximumWidth(32)
self.first_line.addWidget(edit_button)
self.layout.addLayout(self.first_line, 0, 0)
self.min_line, self.min_label = get_image_layout("min.png",
_("Smallest element in array"))
self.layout.addLayout(self.min_line, 1, 0)
self.max_line, self.max_label = get_image_layout("max.png",
_("Largest element in array"))
self.layout.addLayout(self.max_line, 2, 0)
edit_button.clicked.connect(self.edit_array)
self.arr = None # le tableau si il a été modifié
self.instance = None
示例5: create_autofit_group
def create_autofit_group(self):
auto_button = QPushButton(get_icon('apply.png'), _("Run"), self)
auto_button.clicked.connect(self.autofit)
autoprm_button = QPushButton(get_icon('settings.png'), _("Settings"),
self)
autoprm_button.clicked.connect(self.edit_parameters)
xrange_button = QPushButton(get_icon('xrange.png'), _("Bounds"), self)
xrange_button.setCheckable(True)
xrange_button.toggled.connect(self.toggle_xrange)
auto_layout = QVBoxLayout()
auto_layout.addWidget(auto_button)
auto_layout.addWidget(autoprm_button)
auto_layout.addWidget(xrange_button)
self.button_list += [auto_button, autoprm_button, xrange_button]
return create_groupbox(self, _("Automatic fit"), layout=auto_layout)
示例6: MainWindow
class MainWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setWindowTitle( 'Biofeedback' )
self.button_start = QPushButton()
self.button_start.setText("START")
self.button_stop = QPushButton()
self.button_stop.setText("STOP")
layout = QHBoxLayout(self)
layout.addWidget(self.button_start)
layout.addWidget(self.button_stop)
self.connect(self.button_start, SIGNAL("clicked(bool)"), self.start_session)
self.connect(self.button_stop, SIGNAL("clicked(bool)"), self.stop_session)
self.setLayout(layout)
self.setGeometry(300,100,250,100)
self.show()
#self.datastorage = DataStorage()
#settings = {'db_host':'amber','db_user':'root','db_pwd':'dbrootpass','db_dbname':'biodb'}
#self.datastorage.enableDbStorage(settings)
self.thread = ConnectionThread()
def start_session(self):
self.thread.tsc.clearContainer()
if VIRTUAL_SERIAL is True:
self.thread.zephyr_connect.resume()
#self.datastorage.timeseries = self.thread.tsc
self.thread.start()
self.thread.timer.start(1000)
def stop_session(self):
self.thread.stop()
self.store_session()
示例7: install_button_layout
def install_button_layout(self):
#install new button on the ImageDialog
ResetButton = QPushButton("Reset Seg.")
ResetButton.setDefault(False)
ResetPointsButton = QPushButton("Delete all Points")
ResetPointsButton.setDefault(False)
ResetRectangleButton = QPushButton("Delete all Rectangle")
ResetRectangleButton.setDefault(False)
buttonBox = QDialogButtonBox()
buttonBox.addButton(ResetButton, QDialogButtonBox.ActionRole)
buttonBox.addButton(ResetPointsButton, QDialogButtonBox.ActionRole)
buttonBox.addButton(ResetRectangleButton, QDialogButtonBox.ActionRole)
#Define event according to button pressed
ResetButton.clicked.connect(self.reset_seg)
ResetPointsButton.clicked.connect(self.reset_pts)
ResetRectangleButton.clicked.connect(self.reset_rec)
self.button_layout.addWidget(buttonBox)
示例8: create_widgets
def create_widgets(self, parent, refresh_callback):
self._refresh_callback = refresh_callback
self.prefix_label = QLabel()
font = self.prefix_label.font()
font.setPointSize(font.pointSize()+self._size_offset)
self.prefix_label.setFont(font)
self.button = QPushButton()
self.button.setIcon(get_icon('settings.png'))
self.button.setToolTip(
_("Edit '%s' fit parameter properties") % self.name)
self.button.clicked.connect(lambda: self.edit_param(parent))
self.lineedit = QLineEdit()
self.lineedit.editingFinished.connect(self.line_editing_finished)
self.unit_label = QLabel(self.unit)
self.slider = QSlider()
self.slider.setOrientation(Qt.Horizontal)
self.slider.setRange(0, self.steps-1)
self.slider.valueChanged.connect(self.slider_value_changed)
self.update(refresh=False)
self.add_widgets([self.prefix_label, self.lineedit, self.unit_label,
self.slider, self.button])
示例9: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
info_icon = QLabel()
icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
info_icon.setPixmap(icon)
info_icon.setFixedWidth(32)
info_icon.setAlignment(Qt.AlignTop)
self.service_status_label = QLabel()
self.service_status_label.setWordWrap(True)
self.service_status_label.setAlignment(Qt.AlignTop)
self.service_status_label.setFont(font)
self.desc_label = QLabel()
self.desc_label.setWordWrap(True)
self.desc_label.setAlignment(Qt.AlignTop)
self.desc_label.setFont(font)
group_desc = QGroupBox("Description", self)
layout = QHBoxLayout()
layout.addWidget(info_icon)
layout.addWidget(self.desc_label)
layout.addStretch()
layout.addWidget(self.service_status_label )
group_desc.setLayout(layout)
self.editor = CodeEditor(self)
self.editor.setup_editor(linenumbers=True, font=font)
self.editor.setReadOnly(False)
group_code = QGroupBox("Source code", self)
layout = QVBoxLayout()
layout.addWidget(self.editor)
group_code.setLayout(layout)
self.enable_button = QPushButton(get_icon("apply.png"),
"Enable", self)
self.save_button = QPushButton(get_icon("filesave.png"),
"Save", self)
self.edit_datadog_conf_button = QPushButton(get_icon("edit.png"),
"Edit agent settings", self)
self.disable_button = QPushButton(get_icon("delete.png"),
"Disable", self)
self.view_log_button = QPushButton(get_icon("txt.png"),
"View log", self)
self.menu_button = QPushButton(get_icon("settings.png"),
"Manager", self)
hlayout = QHBoxLayout()
hlayout.addWidget(self.save_button)
hlayout.addStretch()
hlayout.addWidget(self.enable_button)
hlayout.addStretch()
hlayout.addWidget(self.disable_button)
hlayout.addStretch()
hlayout.addWidget(self.edit_datadog_conf_button)
hlayout.addStretch()
hlayout.addWidget(self.view_log_button)
hlayout.addStretch()
hlayout.addWidget(self.menu_button)
vlayout = QVBoxLayout()
vlayout.addWidget(group_desc)
vlayout.addWidget(group_code)
vlayout.addLayout(hlayout)
self.setLayout(vlayout)
self.current_file = None
示例10: PropertiesWidget
class PropertiesWidget(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
info_icon = QLabel()
icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
info_icon.setPixmap(icon)
info_icon.setFixedWidth(32)
info_icon.setAlignment(Qt.AlignTop)
self.service_status_label = QLabel()
self.service_status_label.setWordWrap(True)
self.service_status_label.setAlignment(Qt.AlignTop)
self.service_status_label.setFont(font)
self.desc_label = QLabel()
self.desc_label.setWordWrap(True)
self.desc_label.setAlignment(Qt.AlignTop)
self.desc_label.setFont(font)
group_desc = QGroupBox("Description", self)
layout = QHBoxLayout()
layout.addWidget(info_icon)
layout.addWidget(self.desc_label)
layout.addStretch()
layout.addWidget(self.service_status_label )
group_desc.setLayout(layout)
self.editor = CodeEditor(self)
self.editor.setup_editor(linenumbers=True, font=font)
self.editor.setReadOnly(False)
group_code = QGroupBox("Source code", self)
layout = QVBoxLayout()
layout.addWidget(self.editor)
group_code.setLayout(layout)
self.enable_button = QPushButton(get_icon("apply.png"),
"Enable", self)
self.save_button = QPushButton(get_icon("filesave.png"),
"Save", self)
self.edit_datadog_conf_button = QPushButton(get_icon("edit.png"),
"Edit agent settings", self)
self.disable_button = QPushButton(get_icon("delete.png"),
"Disable", self)
self.view_log_button = QPushButton(get_icon("txt.png"),
"View log", self)
self.menu_button = QPushButton(get_icon("settings.png"),
"Manager", self)
hlayout = QHBoxLayout()
hlayout.addWidget(self.save_button)
hlayout.addStretch()
hlayout.addWidget(self.enable_button)
hlayout.addStretch()
hlayout.addWidget(self.disable_button)
hlayout.addStretch()
hlayout.addWidget(self.edit_datadog_conf_button)
hlayout.addStretch()
hlayout.addWidget(self.view_log_button)
hlayout.addStretch()
hlayout.addWidget(self.menu_button)
vlayout = QVBoxLayout()
vlayout.addWidget(group_desc)
vlayout.addWidget(group_code)
vlayout.addLayout(hlayout)
self.setLayout(vlayout)
self.current_file = None
def set_item(self, check):
self.current_file = check
self.desc_label.setText(check.get_description())
self.editor.set_text_from_file(check.file_path)
check.content = self.editor.toPlainText().__str__()
if check.enabled:
self.disable_button.setEnabled(True)
self.enable_button.setEnabled(False)
else:
self.disable_button.setEnabled(False)
self.enable_button.setEnabled(True)
def set_datadog_conf(self, datadog_conf):
self.current_file = datadog_conf
self.desc_label.setText(datadog_conf.get_description())
self.editor.set_text_from_file(datadog_conf.file_path)
datadog_conf.content = self.editor.toPlainText().__str__()
self.disable_button.setEnabled(False)
self.enable_button.setEnabled(False)
#.........这里部分代码省略.........
示例11: MainWindow
class MainWindow(QSplitter):
def __init__(self, parent=None):
prefix_conf = ''
if Platform.is_windows():
prefix_conf = 'windows_'
log_conf = get_logging_config()
QSplitter.__init__(self, parent)
self.setWindowTitle(MAIN_WINDOW_TITLE)
self.setWindowIcon(get_icon("agent.svg"))
self.sysTray = SystemTray(self)
self.connect(self.sysTray, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.__icon_activated)
checks = get_checks()
datadog_conf = DatadogConf(get_config_path())
self.create_logs_files_windows(log_conf, prefix_conf)
listwidget = QListWidget(self)
listwidget.addItems([osp.basename(check.module_name).replace("_", " ").title() for check in checks])
self.properties = PropertiesWidget(self)
self.setting_button = QPushButton(get_icon("info.png"),
"Logs and Status", self)
self.menu_button = QPushButton(get_icon("settings.png"),
"Actions", self)
self.settings = [
("Forwarder Logs", lambda: [self.properties.set_log_file(self.forwarder_log_file),
self.show_html(self.properties.group_code, self.properties.html_window, False)]),
("Collector Logs", lambda: [self.properties.set_log_file(self.collector_log_file),
self.show_html(self.properties.group_code, self.properties.html_window, False)]),
("Dogstatsd Logs", lambda: [self.properties.set_log_file(self.dogstatsd_log_file),
self.show_html(self.properties.group_code, self.properties.html_window, False)]),
("JMX Fetch Logs", lambda: [self.properties.set_log_file(self.jmxfetch_log_file),
self.show_html(self.properties.group_code, self.properties.html_window, False)]),
("Agent Status", lambda: [self.properties.html_window.setHtml(self.properties.html_window.latest_status()),
self.show_html(self.properties.group_code, self.properties.html_window, True),
self.properties.set_status()]),
]
self.agent_settings = QPushButton(get_icon("edit.png"),
"Settings", self)
self.connect(self.agent_settings, SIGNAL("clicked()"),
lambda: [self.properties.set_datadog_conf(datadog_conf),
self.show_html(self.properties.group_code, self.properties.html_window, False)])
self.setting_menu = SettingMenu(self.settings)
self.connect(self.setting_button, SIGNAL("clicked()"),
lambda: self.setting_menu.popup(self.setting_button.mapToGlobal(QPoint(0, 0))))
self.manager_menu = Menu(self)
self.connect(self.menu_button, SIGNAL("clicked()"),
lambda: self.manager_menu.popup(self.menu_button.mapToGlobal(QPoint(0, 0))))
holdingBox = QGroupBox("", self)
Box = QVBoxLayout(self)
Box.addWidget(self.agent_settings)
Box.addWidget(self.setting_button)
Box.addWidget(self.menu_button)
Box.addWidget(listwidget)
holdingBox.setLayout(Box)
self.addWidget(holdingBox)
self.addWidget(self.properties)
self.connect(self.properties.enable_button, SIGNAL("clicked()"),
lambda: enable_check(self.properties))
self.connect(self.properties.disable_button, SIGNAL("clicked()"),
lambda: disable_check(self.properties))
self.connect(self.properties.save_button, SIGNAL("clicked()"),
lambda: save_file(self.properties))
self.connect(self.properties.refresh_button, SIGNAL("clicked()"),
lambda: [self.properties.set_log_file(self.properties.current_file),
self.properties.html_window.setHtml(self.properties.html_window.latest_status())])
self.connect(listwidget, SIGNAL('currentRowChanged(int)'),
lambda row: [self.properties.set_item(checks[row]),
self.show_html(self.properties.group_code, self.properties.html_window, False)])
listwidget.setCurrentRow(0)
self.setSizes([150, 1])
self.setStretchFactor(1, 1)
self.resize(QSize(950, 600))
self.properties.set_datadog_conf(datadog_conf)
self.do_refresh()
def do_refresh(self):
try:
if self.isVisible():
service_status = agent_status()
self.properties.service_status_label.setText(HUMAN_SERVICE_STATUS[service_status])
#.........这里部分代码省略.........
示例12: FitParam
class FitParam(object):
def __init__(self, name, value, min, max, logscale=False,
steps=5000, format='%.3f', size_offset=0, unit=''):
self.name = name
self.value = value
self.min = min
self.max = max
self.logscale = logscale
self.steps = steps
self.format = format
self.unit = unit
self.prefix_label = None
self.lineedit = None
self.unit_label = None
self.slider = None
self.button = None
self._widgets = []
self._size_offset = size_offset
self._refresh_callback = None
self.dataset = FitParamDataSet(title=_("Curve fitting parameter"))
def copy(self):
"""Return a copy of this fitparam"""
return self.__class__(self.name, self.value, self.min, self.max,
self.logscale, self.steps, self.format,
self._size_offset, self.unit)
def create_widgets(self, parent, refresh_callback):
self._refresh_callback = refresh_callback
self.prefix_label = QLabel()
font = self.prefix_label.font()
font.setPointSize(font.pointSize()+self._size_offset)
self.prefix_label.setFont(font)
self.button = QPushButton()
self.button.setIcon(get_icon('settings.png'))
self.button.setToolTip(
_("Edit '%s' fit parameter properties") % self.name)
self.button.clicked.connect(lambda: self.edit_param(parent))
self.lineedit = QLineEdit()
self.lineedit.editingFinished.connect(self.line_editing_finished)
self.unit_label = QLabel(self.unit)
self.slider = QSlider()
self.slider.setOrientation(Qt.Horizontal)
self.slider.setRange(0, self.steps-1)
self.slider.valueChanged.connect(self.slider_value_changed)
self.update(refresh=False)
self.add_widgets([self.prefix_label, self.lineedit, self.unit_label,
self.slider, self.button])
def add_widgets(self, widgets):
self._widgets += widgets
def get_widgets(self):
return self._widgets
def set_scale(self, state):
self.logscale = state > 0
self.update_slider_value()
def set_text(self, fmt=None):
style = "<span style=\'color: #444444\'><b>%s</b></span>"
self.prefix_label.setText(style % self.name)
if self.value is None:
value_str = ''
else:
if fmt is None:
fmt = self.format
value_str = fmt % self.value
self.lineedit.setText(value_str)
self.lineedit.setDisabled(
self.value == self.min and self.max == self.min)
def line_editing_finished(self):
try:
self.value = float(self.lineedit.text())
except ValueError:
self.set_text()
self.update_slider_value()
self._refresh_callback()
def slider_value_changed(self, int_value):
if self.logscale:
total_delta = np.log10(1+self.max-self.min)
self.value = self.min+10**(total_delta*int_value/(self.steps-1))-1
else:
total_delta = self.max-self.min
self.value = self.min+total_delta*int_value/(self.steps-1)
self.set_text()
self._refresh_callback()
def update_slider_value(self):
if (self.value is None or self.min is None or self.max is None):
self.slider.setEnabled(False)
if self.slider.parent() and self.slider.parent().isVisible():
self.slider.show()
elif self.value == self.min and self.max == self.min:
self.slider.hide()
else:
self.slider.setEnabled(True)
if self.slider.parent() and self.slider.parent().isVisible():
#.........这里部分代码省略.........