本文整理匯總了Python中PyQt5.QtCore.QDate方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QDate方法的具體用法?Python QtCore.QDate怎麽用?Python QtCore.QDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QDate方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDate [as 別名]
def __init__(self, title="Calendar"):
super(CalendarWidget, self).__init__()
self.setWindowTitle(title)
layout = qt_widgets.QGridLayout()
layout.setColumnStretch(1, 1)
self.cal = qt_widgets.QCalendarWidget(self)
self.cal.setGridVisible(True)
self.cal.clicked[QtCore.QDate].connect(self.show_date)
layout.addWidget(self.cal, 0, 0, 1, 2)
self.date_label = qt_widgets.QLabel()
self.date = self.cal.selectedDate()
self.date_label.setText(self.date.toString())
layout.addWidget(self.date_label, 1, 0)
button_box = qt_widgets.QDialogButtonBox()
confirm_button = button_box.addButton(qt_widgets.QDialogButtonBox.Ok)
confirm_button.clicked.connect(self.confirm)
layout.addWidget(button_box, 1, 1)
self.setLayout(layout)
self.show()
self.raise_()
示例2: initUI
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDate [as 別名]
def initUI(self):
vbox = QVBoxLayout(self)
cal = QCalendarWidget(self)
cal.setGridVisible(True)
cal.clicked[QDate].connect(self.showDate)
vbox.addWidget(cal)
self.lbl = QLabel(self)
date = cal.selectedDate()
self.lbl.setText(date.toString())
vbox.addWidget(self.lbl)
self.setLayout(vbox)
self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('Calendar')
self.show()
示例3: set_time_limits
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDate [as 別名]
def set_time_limits(self):
selected_date = self.calendar_widget.selectedDate()
if selected_date == QDate(*self.creation_date):
self.time_edit.setMinimumTime(QTime(*self.creation_time))
else:
self.time_edit.clearMinimumTime()
if selected_date == QDate(*self.now_date):
self.time_edit.setMaximumTime(QTime(*self.now_time))
else:
self.time_edit.clearMaximumTime()
示例4: enable_with_timestamp
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDate [as 別名]
def enable_with_timestamp(self):
creation = self.limits_job.ret.in_timezone("local")
self.limits_job = None
self.creation_date = (creation.year, creation.month, creation.day)
self.creation_time = (creation.hour, creation.minute, creation.second)
now = pendulum.now().in_timezone("local")
self.now_date = (now.year, now.month, now.day)
self.now_time = (now.hour, now.minute, now.second)
self.calendar_widget.setMinimumDate(QDate(*self.creation_date))
self.calendar_widget.setMaximumDate(QDate(*self.now_date))
self.calendar_widget.selectionChanged.connect(self.set_time_limits)
self.set_time_limits()
self.time_edit.setDisplayFormat("h:mm:ss")
示例5: init_shares_tab_ui
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDate [as 別名]
def init_shares_tab_ui(self):
"""Shares."""
self.shares_tab = QtGui.QWidget()
self.shares_layout = QtGui.QFormLayout(self.shares_tab)
today = datetime.today()
self.shares_date_from = QtGui.QDateEdit()
self.shares_date_from.setMinimumDate(QtCore.QDate(1900, 1, 1))
self.shares_date_from.setMaximumDate(QtCore.QDate(2030, 12, 31))
self.shares_date_from.setDate(QtCore.QDate(today.year, 1, 1))
self.shares_date_from.setDisplayFormat('dd.MM.yyyy')
self.shares_date_to = QtGui.QDateEdit()
self.shares_date_to.setMinimumDate(QtCore.QDate(1900, 1, 1))
self.shares_date_to.setMaximumDate(QtCore.QDate(2030, 12, 31))
self.shares_date_to.setDate(
QtCore.QDate(today.year, today.month, today.day)
)
self.shares_date_to.setDisplayFormat('dd.MM.yyyy')
self.shares_symbol_list = QtGui.QComboBox()
self.shares_symbol_list.setFocusPolicy(QtCore.Qt.StrongFocus)
self.shares_symbol_list.setMaxVisibleItems(20)
self.shares_symbol_list.setEditable(True)
self.shares_show_btn = QtGui.QPushButton('Load')
self.shares_show_btn.clicked.connect(self.update_data)
self.shares_layout.addRow('From', self.shares_date_from)
self.shares_layout.addRow('To', self.shares_date_to)
self.shares_layout.addRow('Symbol', self.shares_symbol_list)
self.shares_layout.addRow(None, self.shares_show_btn)
self.select_source.addTab(self.shares_tab, 'Shares/Futures/ETFs')