本文整理汇总了Python中PyQt4.QtCore.QDate类的典型用法代码示例。如果您正苦于以下问题:Python QDate类的具体用法?Python QDate怎么用?Python QDate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reset_button
def test_reset_button(self):
self.test_browser.lowerDate.setDate(QDate(2013, 3, 3))
self.test_browser.upperDate.setDate(QDate(2013, 5, 5))
self.test_browser.upperCount.setValue(0.5)
self.test_browser.lowerCount.setValue(0.5)
self.test_browser.lowerZoom.setValue(60)
self.test_browser.upperZoom.setValue(60)
self.test_browser.slideID.setText('Test!')
self.test_browser.otherComments.setText('')
self.test_browser.saveLocation.setText('Something')
self.test_browser.dropdowns[0].setCurrentIndex(1)
self.test_browser.dropdowns[1].setCurrentIndex(1)
self.test_browser.dropdowns[2].setCurrentIndex(1)
self.test_browser.dropdowns[3].setCurrentIndex(1)
self.assertTrue(self.test_browser.imageSearch())
self.test_browser.resetFields()
self.assertEqual(QDate.toString(self.test_browser.lowerDate.date(), "dd-MM-yyyy"), "01-01-2013")
self.assertEqual(QDate.toString(self.test_browser.upperDate.date(), "dd-MM-yyyy"), "13-03-2014")
self.assertEqual(self.test_browser.dropdowns[0].currentText(), '<Please select one>')
self.assertEqual(self.test_browser.dropdowns[1].currentText(), '<Please select one>')
self.assertEqual(self.test_browser.dropdowns[2].currentText(), '<Please select one>')
self.assertEqual(self.test_browser.dropdowns[3].currentText(), '<Please select one>')
self.assertEqual(self.test_browser.upperCount.value(), 1.0)
self.assertEqual(self.test_browser.lowerCount.value(), 0.0)
self.assertEqual(self.test_browser.lowerZoom.value(), 0)
self.assertEqual(self.test_browser.upperZoom.value(), 1000000)
self.assertEqual(self.test_browser.slideID.text(), '')
self.assertEqual(self.test_browser.otherComments.toPlainText(), '')
self.assertEqual(self.test_browser.saveLocation.text(), '<Download Location>')
示例2: __init__
def __init__( self, ganttWidget ):
super(XGanttWidgetItem, self).__init__()
# set default properties
self.setFixedHeight(ganttWidget.cellHeight())
for i in range(1, 20):
self.setTextAlignment(i, Qt.AlignCenter)
# define custom properties
self._blockedAdjustments = {}
self._viewItem = self.createViewItem()
self._dateStart = QDate.currentDate()
self._dateEnd = QDate.currentDate()
self._allDay = True
self._timeStart = QTime(0, 0, 0)
self._timeEnd = QTime(23, 59, 59)
self._name = "NONE"
self._properties = {}
self._itemStyle = XGanttWidgetItem.ItemStyle.Normal
self._useGroupStyleWithChildren = True
self._dependencies = {}
self._reverseDependencies = {}
self._dbEntry = None
self._workdays = 0
self._ganttWidget = ganttWidget
#self._calculateWeekdays = 0
#self._dbDepartmentAssignment = ''
self.setPrivelages()
示例3: __init__
def __init__(self,parent,ide=-1):
QDialog.__init__(self)
self.setupUi(self)
self.cursor=parent.cursor
self.curser=parent.curser
self.parent=parent
self.ide=ide
self.banderas={'edicion':False}
self.matriz={'productos':[],'familias':[],'departamentos':[]}
self.lista=[]
self.menuAdd = QMenu(self)
#Menu contextual de tipos de impresion
self.menuAdd.addAction("Productos",self.listarProds)
self.menuAdd.addAction("Familias",self.listarFams)
self.menuAdd.addAction("Departamentos",self.listarDeps)
self.tbMas.setMenu(self.menuAdd)
self.tbMas.setPopupMode(2)
self.CP=CalculaPrecio(self)
#self.connect(self.rbDepa, SIGNAL("clicked ()"), self.listarDeps)
#self.connect(self.rbFam, SIGNAL("clicked ()"), self.listarFams)
#self.connect(self.rbProd, SIGNAL("clicked ()"), self.listarProds)
self.connect(self.tbPublicar, SIGNAL("clicked ( )"), self.terminar)
self.connect(self.tbCerrar, SIGNAL("clicked ()"), self.close)
self.connect(self.tbMenos, SIGNAL("clicked ()"), self.quitar)
self.connect(self.tbCalcDes, SIGNAL("clicked ()"), self.calcularPrecio)
self.connect(self.sbMinimo,SIGNAL("editingFinished ()"),self.checkMaximo)
self.connect(self.CP.dsbDescuento,SIGNAL("valueChanged ( double )"),lambda:self.dsDescuento.setValue(self.CP.dsbDescuento.value()))
self.deInicio.setDate(QDate.currentDate())
self.deFin.setDate(QDate.currentDate())
self.promo={'nombre':'','descuento':'','inicio':'','fin':'','minimo':''}
self.iniciar()
示例4: test_value_date
def test_value_date(self):
test_property = DateProperty("test name", QDate.currentDate(), "gco:Date")
test_property.value = QDate.fromString("2015-06-07")
with self.assertRaises(TypeError):
test_property.value = 20150607
示例5: setDateEnd
def setDateEnd( self, date, ignoreDuration = False ):
"""
Sets the date start value for this item.
:param dateStart | <QDate>
"""
date = QDate(date)
delta = self._dateEnd.daysTo(date)
if ( not delta ):
return
if ( self.itemStyle() != self.ItemStyle.Group ):
self._dateEnd = date
else:
duration = self.duration()
if ignoreDuration is False:
self._dateStart = date.addDays(-duration)
self._dateEnd = date
self.adjustChildren(delta)
self.adjustRange()
# sync the tree
self.sync()
示例6: _getCalendar
def _getCalendar(self, display_format, value = None):
'''
Get a combobox filled with the given values
:param values: The values as key = value, value = description or text
:type values: Dict
:returns: A combobox
:rtype: QWidget
'''
widget = QWidget()
calendar = QDateTimeEdit()
calendar.setCalendarPopup(True)
calendar.setDisplayFormat(display_format)
if value is not None:
calendar.setDate(QDate.fromString(value, display_format))
else:
calendar.setDate(QDate.currentDate())
layout = QHBoxLayout(widget)
layout.addWidget(calendar, 1);
layout.setAlignment(Qt.AlignCenter);
layout.setContentsMargins(5,0,5,0);
widget.setLayout(layout);
return widget
示例7: aceptar
def aceptar( self ):
fecha = QDate.currentDate()
fecha = QDate( fecha.year(), fecha.month(), fecha.daysInMonth() )
if self.dtPicker.date() > fecha:
QMessageBox.information( None, "Cuentas Bancarias", "La cuenta seleccionada ya fue conciliada" )
else:
return self.accept()
示例8: setDate
def setDate(self, date):
if isinstance(date, datetime.date):
date = QDate(date.year, date.month, date.day)
if date is not None and date.isValid():
self._line_edit.setText(str(date.toString("yyyy-MM-dd")))
else:
self._line_edit.setText("")
示例9: readDates
def readDates(self, tree):
"""
Lese die Daten aus (Geburtsdatum, Verwandlungsdatum, aktuelles Datum im Spiel).
"""
dates = tree.find("dates")
self.__character.dateBirth = QDate.fromString(dates.attrib["birth"], Config.DATE_FORMAT)
self.__character.dateBecoming = QDate.fromString(dates.attrib["becoming"], Config.DATE_FORMAT)
self.__character.dateGame = QDate.fromString(dates.attrib["game"], Config.DATE_FORMAT)
示例10: __init__
def __init__(self, parent=None, testing=False, participantId=None):
# Initialize object using ui_addParticipant
super(EditParticipantDialog, self).__init__(parent)
self.ui = Ui_AddParticipantDialog()
self.ui.setupUi(self)
# Initialize class variables
self.testing = testing
if participantId is None:
QMessageBox.critical(self, 'Invalid Participant', "An invalid participant was chosen.", QMessageBox.Ok)
self.reject()
# if participantId[0] == 's':
# self.participantId = participantId[1:]
# else:
# self.participantId = participantId
self.participantId = participantId
self.participant = dbInteractionInstance.getParticipantFromId(participantId)
# Set up the contact
self.contactId = self.participant.contact
if self.contactId:
c = dbInteractionInstance.getTeacherFromId(self.contactId)
if c is not None:
self.ui.contactPersonLineEdit.setText("{0} {1}".format(c.first, c.last))
# Initialize ui with variables
self.ui.addParticipantBtn.setText("&Update Participant")
self.setWindowTitle("Edit Participant")
self.ui.firstNameLineEdit.setText(self.participant.first)
self.ui.lastNameLineEdit.setText(self.participant.last)
self.ui.addressLineEdit.setText(self.participant.address)
self.ui.cityLineEdit.setText(self.participant.city)
self.ui.postalCodeLineEdit.setText(humanPostalCodeFormat(self.participant.postal))
self.ui.homePhoneLineEdit.setText(humanPhoneNumberFormat(self.participant.home))
self.ui.cellPhoneLineEdit.setText(humanPhoneNumberFormat(self.participant.cell))
self.ui.emailLineEdit.setText(self.participant.email)
self.ui.dateOfBirthDateEdit.setDate(QDate.fromString(self.participant.dob, "yyyy-MM-dd"))
self.ui.ageLabel.setText("Age as of Jan. 1 {0}".format(QDate.currentDate().year()))
self.ui.schoolAttendingLineEdit.setText(self.participant.schoolAttending)
self.ui.parentLineEdit.setText(self.participant.parent)
self.ui.schoolGradeLineEdit.setText(self.participant.schoolGrade)
self.ui.groupNameLineEdit.setText(self.participant.groupName)
self.ui.numberParticipantsLineEdit.setText(self.participant.numberParticipants)
self.ui.schoolGradeLineEdit.setText(self.participant.schoolGrade)
self.ui.averageAgeLineEdit.setText(self.participant.averageAge)
if self.participant.earliestPerformanceTime != "":
self.ui.timeConstraintsGroupBox.setChecked(True)
self.ui.earliestPerformanceTimeTimeEdit.setTime(QTime.fromString(self.participant.earliestPerformanceTime, "h:mm A"))
self.ui.latestPerformanceTimeTimeEdit.setTime(QTime.fromString(self.participant.latestPerformanceTime, "h:mm A"))
self.ui.participantsTextEdit.setText(self.participant.participants)
# Set the age display
self.dob_changed()
# Make the buttons do things
self.connectSlots()
示例11: test_value_date
def test_value_date(self):
test_property = DateProperty(
'test name',
QDate.currentDate(),
'gco:Date'
)
test_property.value = QDate.fromString('2015-06-07')
with self.assertRaises(TypeError):
test_property.value = 20150607
示例12: __init__
def __init__( self, parent = None ):
"""
Constructor
"""
super( FrmEstadoResultado, self ).__init__( parent )
self.setupUi( self )
self.parentWindow = parent
# self.editmodel = None
self.user = user.LoggedUser
self.status = True
self.dtPicker.setMaximumDate( QDate.currentDate() )
self.dtPicker.setDate( QDate.currentDate() )
示例13: AddProject
def AddProject(self):
self._myXGanttWidgetItem = XGanttWidgetItem(self._myXGanttWidget)
#self._myXGanttViewItem = self._myXGanttWidgetItem.createViewItem()
self._myXGanttWidgetItem.setName("test")
self._myXGanttWidgetItem.setDateEnd(QDate.currentDate().addMonths(+1))
self._myXGanttWidgetItem.setDateStart(QDate.currentDate().addDays(+1))
self._myXGanttWidgetItem.setProperty("Start",QDate(2014,10,1))
self._myXGanttWidgetItem.setProperty("End",QDate(2014,10,2))
self._myXGanttWidgetItem.setProperty("Calendar Days",2)
self._myXGanttWidgetItem.setProperty("Work Days",2)
self._myXGanttWidget.addTopLevelItem(self._myXGanttWidgetItem)
self._myXGanttWidget.show()
示例14: printDocument1
def printDocument1(self):
html = u""
date = QDate.currentDate().toString(self.DATE_FORMAT)
address = Qt.escape("Bario francisco mesa").replace(",","<br>")
contact = Qt.escape("Luis Mejia")
balance = 5000
html += ("<p align=right><img src=':/logo.png'></p>"
"<p> align = right>Greasy hands ltd."
"<br>New Lombard Street"
"<br>London<br>WC13 4PX<br>%s</p>"
"<p>%s</p><p>Dear %s, </p>"
"<p>The balance of your account is %s.")% (
date, address, contact, QString("$ %L1").arg(float(balance),0,"f",2))
if balance <0 :
html += ("<p><font color =red><b> Please remit the amount owing immediately.</b></font>")
else:
html += "We are delighted to have done business with you."
html += ("</p><p> </p><p>"
"<table border=1 cellpadding=2 cellspacing=2><tr><td colspan=3>Transaction</td></tr>")
transactions = [
(QDate.currentDate(),500),
(QDate.currentDate(),500),
(QDate.currentDate(),-500),
(QDate.currentDate(),500)
]
for date, amount in transactions:
color, status = "black", "Credit"
if amount <0:
color, status = "red", "Debid"
html += ("<tr>"
"<td align= right>%s</td>"
"<td>%s</td><td align=right><font color=%s>%s</font></td></tr>" % (
date.toString(self.DATE_FORMAT), status,color, QString("$ %L1").arg(float(abs(amount)), 0, "f",2)))
html += ("</table></p><p style='page-break-after=always;'>"
"We hope to continue doing business with you</p>")
pdialog = QPrintDialog()
if pdialog.exec_() == QDialog.Accepted:
printer = pdialog.printer()
document = QTextDocument()
document.setHtml(html)
document.print_(printer)
示例15: date_from_string
def date_from_string(s):
s = s.strip()
if not s:
return None
from PyQt4.QtCore import QDate
import string
f = local_date_format()
dt = QDate.fromString(s, f)
if not dt.isValid():
#
# if there is a mismatch of 1 in length between format and
# string, prepend a 0, to handle the case of 1/11/2011
#
if len(f) == len(s) + 1:
s = '0' + s
dt = QDate.fromString(s, f)
if not dt.isValid():
#
# try alternative separators
#
separators = u''.join([c for c in f if c not in string.ascii_letters])
if separators:
alternative_string = u''.join([(c if c in string.digits else separators[0]) for c in s])
dt = QDate.fromString(alternative_string, f)
if not dt.isValid():
# try parsing without separators
# attention : using non ascii letters will fail on windows
# string.letters then contains non ascii letters of which we don't know the
# encoding, so we cannot convert them to unicode to compare them
only_letters_format = u''.join([c for c in f if c in string.ascii_letters])
only_letters_string = u''.join([c for c in s if c in (string.ascii_letters+string.digits)])
dt = QDate.fromString(only_letters_string, only_letters_format)
if not dt.isValid():
# try parsing without the year, and take the current year by default
only_letters_format = u''.join([c for c in only_letters_format if c not in ['y']])
dt = QDate.fromString(only_letters_string, only_letters_format)
if not dt.isValid():
raise ParsingError()
# # try parsing without year and month, and take the current year and month by default
# only_letters_format = u''.join([c for c in only_letters_format if c not in ['M']])
# dt = QDate.fromString(only_letters_string, only_letters_format)
# if not dt.isValid():
# raise ParsingError()
# else:
# today = date.today()
# return date(today.year, today.month, dt.day())
else:
return date(date.today().year, dt.month(), dt.day())
return date(dt.year(), dt.month(), dt.day())