本文整理汇总了Python中PyQt5.Qt.QDateTimeEdit.setDisplayFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QDateTimeEdit.setDisplayFormat方法的具体用法?Python QDateTimeEdit.setDisplayFormat怎么用?Python QDateTimeEdit.setDisplayFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QDateTimeEdit
的用法示例。
在下文中一共展示了QDateTimeEdit.setDisplayFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DownQDialog
# 需要导入模块: from PyQt5.Qt import QDateTimeEdit [as 别名]
# 或者: from PyQt5.Qt.QDateTimeEdit import setDisplayFormat [as 别名]
class DownQDialog(QDialog):
"""
Class who create Downtime QDialog for hosts/services
"""
def __init__(self, parent=None):
super(DownQDialog, self).__init__(parent)
self.setWindowTitle(_('Request a Downtime'))
self.setWindowFlags(Qt.FramelessWindowHint)
self.setStyleSheet(settings.css_style)
self.setWindowIcon(QIcon(settings.get_image('icon')))
self.setMinimumSize(360, 460)
self.setObjectName('dialog')
# Fields
self.fixed = True
self.fixed_toggle_btn = ToggleQWidgetButton()
self.duration = QTimeEdit()
self.start_time = QDateTimeEdit()
self.end_time = QDateTimeEdit()
self.comment_edit = QTextEdit()
self.offset = None
def initialize(self, item_type, item_name, comment): # pylint: disable=too-many-locals
"""
Initialize Downtime QDialog
:param item_type: type of item to acknowledge : host | service
:type item_type: str
:param item_name: name of the item to acknowledge
:type item_name: str
:param comment: the default comment of action
:type comment: str
"""
logger.debug("Create Downtime QDialog...")
# Main status_layout
center_widget(self)
main_layout = QVBoxLayout(self)
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.addWidget(get_logo_widget(self, _('Request Downtime')))
downtime_widget = QWidget()
downtime_widget.setObjectName('dialog')
downtime_layout = QGridLayout(downtime_widget)
downtime_title = QLabel(_('Request a downtime'))
downtime_title.setObjectName('itemtitle')
downtime_layout.addWidget(downtime_title, 0, 0, 1, 3)
host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name))
downtime_layout.addWidget(host_label, 1, 0, 1, 1)
options_label = QLabel(_('Downtime options:'))
options_label.setObjectName('subtitle')
downtime_layout.addWidget(options_label, 2, 0, 1, 1)
self.fixed_toggle_btn.initialize()
self.fixed_toggle_btn.update_btn_state(self.fixed)
downtime_layout.addWidget(self.fixed_toggle_btn, 2, 1, 1, 1)
fixed_label = QLabel(_('Fixed'))
downtime_layout.addWidget(fixed_label, 2, 2, 1, 1)
fixed_info = QLabel(
_(
'If checked, downtime will start and end at the times specified'
' by the “start time” and “end time” fields.'
)
)
fixed_info.setWordWrap(True)
downtime_layout.addWidget(fixed_info, 3, 0, 1, 3)
duration_label = QLabel(_('Duration'))
duration_label.setObjectName('subtitle')
downtime_layout.addWidget(duration_label, 4, 0, 1, 1)
duration_clock = QLabel()
duration_clock.setPixmap(QPixmap(settings.get_image('time')))
downtime_layout.addWidget(duration_clock, 4, 1, 1, 1)
duration_clock.setFixedSize(16, 16)
duration_clock.setScaledContents(True)
self.duration.setTime(QTime(4, 00))
self.duration.setDisplayFormat("HH'h'mm")
downtime_layout.addWidget(self.duration, 4, 2, 1, 1)
duration_info = QLabel(
_('Sets the duration if it is a non-fixed downtime.')
)
downtime_layout.addWidget(duration_info, 5, 0, 1, 3)
date_range_label = QLabel(_('Downtime date range'))
date_range_label.setObjectName('subtitle')
downtime_layout.addWidget(date_range_label, 6, 0, 1, 1)
calendar_label = QLabel()
calendar_label.setPixmap(QPixmap(settings.get_image('calendar')))
calendar_label.setFixedSize(16, 16)
#.........这里部分代码省略.........
示例2: HistoryWidget
# 需要导入模块: from PyQt5.Qt import QDateTimeEdit [as 别名]
# 或者: from PyQt5.Qt.QDateTimeEdit import setDisplayFormat [as 别名]
class HistoryWidget(QDialog):
"""
class HistonWidget
"""
_v_curve_colors = [Qt.white, Qt.gray, Qt.red, Qt.green, Qt.blue, Qt.cyan, Qt.magenta, Qt.darkYellow]
_v_curve_checked = [True, True, True, True, True, True, True, True]
def __init__(self, parent=None):
super(HistoryWidget, self).__init__(parent)
self.setObjectName("HistoryWidget")
self.resize(800, 480)
self.setWindowTitle("历史数据查看")
# layout - top
horiLayoutTop = QHBoxLayout()
buttonQuit = QPushButton(self)
buttonQuit.setObjectName("buttonQuit")
horiLayoutTop.addSpacing(25)
horiLayoutTop.addWidget(buttonQuit, 0, Qt.AlignLeft)
horiLayoutTop.addStretch()
# button-export
buttonExport = QPushButton(self)
buttonExport.setObjectName("buttonExport")
horiLayoutTop.addWidget(buttonExport)
horiLayoutTop.addStretch()
# button-open
buttonOpen = QPushButton(self)
buttonOpen.setObjectName("buttonOpen")
horiLayoutTop.addWidget(buttonOpen)
horiLayoutTop.addStretch()
formLayoutTime = QFormLayout()
formLayoutTime.setFormAlignment(Qt.AlignVCenter)
horiLayoutTop.addLayout(formLayoutTime)
horiLayoutTop.addStretch()
self.dateTimeEditStart = QDateTimeEdit(self)
self.dateTimeEditStart.setObjectName("dateTimeEditStart")
self.dateTimeEditStart.setDisplayFormat("yyyy-MM-dd HH:mm:ss")
formLayoutTime.addRow("起始时间:", self.dateTimeEditStart)
self.dateTimeEditEnd = QDateTimeEdit(self)
self.dateTimeEditEnd.setObjectName("dateTimeEditEnd")
self.dateTimeEditEnd.setDisplayFormat("yyyy-MM-dd HH:mm:ss")
formLayoutTime.addRow("结束时间:", self.dateTimeEditEnd)
# LBP
formLayoutLBP = QFormLayout()
formLayoutLBP.setFormAlignment(Qt.AlignVCenter)
formLayoutLBP.setLabelAlignment(Qt.AlignRight)
horiLayoutTop.addLayout(formLayoutLBP)
horiLayoutTop.addStretch()
self.checkBoxLBPMajor = QCheckBox("主", self)
self.checkBoxLBPMajor.setProperty("curveColor", "#101010")
self.checkBoxLBPMinor = QCheckBox("副", self)
self.checkBoxLBPMinor.setProperty("curveColor", "#101010")
formLayoutLBP.addRow("左刹车压力:", self.checkBoxLBPMajor)
formLayoutLBP.addRow("", self.checkBoxLBPMinor)
# RBP
formLayoutRBP = QFormLayout()
formLayoutRBP.setFormAlignment(Qt.AlignVCenter)
formLayoutRBP.setLabelAlignment(Qt.AlignRight)
horiLayoutTop.addLayout(formLayoutRBP)
horiLayoutTop.addStretch()
self.checkBoxRBPMajor = QCheckBox("主", self)
self.checkBoxRBPMajor.setProperty("curveColor", "#101010")
self.checkBoxRBPMinor = QCheckBox("副", self)
self.checkBoxRBPMinor.setProperty("curveColor", "#101010")
formLayoutRBP.addRow("右刹车压力:", self.checkBoxRBPMajor)
formLayoutRBP.addRow("", self.checkBoxRBPMinor)
# LRP
formLayoutLRP = QFormLayout()
formLayoutLRP.setFormAlignment(Qt.AlignVCenter)
formLayoutLRP.setLabelAlignment(Qt.AlignRight)
horiLayoutTop.addLayout(formLayoutLRP)
horiLayoutTop.addStretch()
self.checkBoxLRPTheory = QCheckBox("理论", self)
self.checkBoxLRPTheory.setProperty("curveColor", "#101010")
self.checkBoxLRPReal = QCheckBox("实际", self)
self.checkBoxLRPReal.setProperty("curveColor", "#101010")
formLayoutLRP.addRow("左转速:", self.checkBoxLRPTheory)
formLayoutLRP.addRow("", self.checkBoxLRPReal)
# RRP
formLayoutRRP = QFormLayout()
formLayoutRRP.setFormAlignment(Qt.AlignVCenter)
formLayoutRRP.setLabelAlignment(Qt.AlignRight)
horiLayoutTop.addLayout(formLayoutRRP)
horiLayoutTop.addStretch()
self.checkBoxRRPTheory = QCheckBox("理论", self)
self.checkBoxRRPTheory.setProperty("curveColor", "#101010")
self.checkBoxRRPReal = QCheckBox("实际", self)
self.checkBoxRRPReal.setProperty("curveColor", "#101010")
formLayoutRRP.addRow("右转速:", self.checkBoxRRPTheory)
#.........这里部分代码省略.........