Best Python code snippet using fMBT_python
datetimeedit.pyw
Source:datetimeedit.pyw
1#!/usr/bin/env python2#============================================================================#3# (Re)Implementation of QDateEdit and QDateTimeEdit. These classes force the #4# use of the calendar popup. #5#----------------------------------------------------------------------------#6# Copyright (c) 2008 by Denviso GmbH, <ulrich.berning@denviso.de> #7# #8# All Rights Reserved #9# #10# Permission to use, copy, modify, and distribute this software and its #11# documentation for any purpose and without fee is hereby granted, #12# provided that the above copyright notice appear in all copies and that #13# both that copyright notice and this permission notice appear in #14# supporting documentation. #15# #16# DENVISO DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS #17# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY #18# AND FITNESS, IN NO EVENT SHALL DENVISO BE LIABLE FOR ANY #19# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES #20# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, #21# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER #22# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE #23# OR PERFORMANCE OF THIS SOFTWARE. #24#----------------------------------------------------------------------------#25from PyQt4 import QtCore, QtGui26#============================================================================#27# PyDateEdit #28#----------------------------------------------------------------------------#29class PyDateEdit(QtGui.QDateEdit):30 #31 # Initialize base class32 # Force use of the calendar popup33 # Set default values for calendar properties34 #35 def __init__(self, *args):36 super(PyDateEdit, self).__init__(*args)37 self.setCalendarPopup(True)38 self.__cw = None39 self.__firstDayOfWeek = QtCore.Qt.Monday40 self.__gridVisible = False41 self.__horizontalHeaderFormat = QtGui.QCalendarWidget.ShortDayNames42 self.__verticalHeaderFormat = QtGui.QCalendarWidget.ISOWeekNumbers43 self.__navigationBarVisible = True44 #45 # Call event handler of base class46 # Get the calendar widget, if not already done47 # Set the calendar properties48 #49 def mousePressEvent(self, event):50 super(PyDateEdit, self).mousePressEvent(event)51 if not self.__cw:52 self.__cw = self.findChild(QtGui.QCalendarWidget)53 if self.__cw:54 self.__cw.setFirstDayOfWeek(self.__firstDayOfWeek)55 self.__cw.setGridVisible(self.__gridVisible)56 self.__cw.setHorizontalHeaderFormat(self.__horizontalHeaderFormat)57 self.__cw.setVerticalHeaderFormat(self.__verticalHeaderFormat)58 self.__cw.setNavigationBarVisible(self.__navigationBarVisible)59 #60 # Make sure, the calendarPopup property is invisible in Designer61 #62 def getCalendarPopup(self):63 return True64 calendarPopup = QtCore.pyqtProperty(bool, fget=getCalendarPopup)65 #66 # Property firstDayOfWeek: Qt::DayOfWeek67 # Get: getFirstDayOfWeek()68 # Set: setFirstDayOfWeek()69 # Reset: resetFirstDayOfWeek()70 #71 def getFirstDayOfWeek(self):72 return self.__firstDayOfWeek73 def setFirstDayOfWeek(self, dayOfWeek):74 if dayOfWeek != self.__firstDayOfWeek:75 self.__firstDayOfWeek = dayOfWeek76 if self.__cw:77 self.__cw.setFirstDayOfWeek(dayOfWeek)78 def resetFirstDayOfWeek(self):79 if self.__firstDayOfWeek != QtCore.Qt.Monday:80 self.__firstDayOfWeek = QtCore.Qt.Monday81 if self.__cw:82 self.__cw.setFirstDayOfWeek(QtCore.Qt.Monday)83 firstDayOfWeek = QtCore.pyqtProperty(QtCore.Qt.DayOfWeek,84 fget=getFirstDayOfWeek,85 fset=setFirstDayOfWeek,86 freset=resetFirstDayOfWeek)87 #88 # Property gridVisible: bool89 # Get: isGridVisible()90 # Set: setGridVisible()91 # Reset: resetGridVisible()92 #93 def isGridVisible(self):94 return self.__gridVisible95 def setGridVisible(self, show):96 if show != self.__gridVisible:97 self.__gridVisible = show98 if self.__cw:99 self.__cw.setGridVisible(show)100 def resetGridVisible(self):101 if self.__gridVisible != False:102 self.__gridVisible = False103 if self.__cw:104 self.__cw.setGridVisible(False)105 gridVisible = QtCore.pyqtProperty(bool,106 fget=isGridVisible,107 fset=setGridVisible,108 freset=resetGridVisible)109 #110 # Property horizontalHeaderFormat: QCalendarWidget::HorizontalHeaderFormat111 # Get: getHorizontalHeaderFormat()112 # Set: setHorizontalHeaderFormat()113 # Reset: resetHorizontalHeaderFormat()114 #115 def getHorizontalHeaderFormat(self):116 return self.__horizontalHeaderFormat117 def setHorizontalHeaderFormat(self, format):118 if format != self.__horizontalHeaderFormat:119 self.__horizontalHeaderFormat = format120 if self.__cw:121 self.__cw.setHorizontalHeaderFormat(format)122 def resetHorizontalHeaderFormat(self):123 if self.__horizontalHeaderFormat != QtGui.QCalendarWidget.ShortDayNames:124 self.__horizontalHeaderFormat = QtGui.QCalendarWidget.ShortDayNames125 if self.__cw:126 self.__cw.setHorizontalHeaderFormat(QtGui.QCalendarWidget.ShortDayNames)127 horizontalHeaderFormat = QtCore.pyqtProperty(QtGui.QCalendarWidget.HorizontalHeaderFormat,128 fget=getHorizontalHeaderFormat,129 fset=setHorizontalHeaderFormat,130 freset=resetHorizontalHeaderFormat)131 #132 # Property verticalHeaderFormat: QCalendarWidget::VerticalHeaderFormat133 # Get: getVerticalHeaderFormat()134 # Set: setVerticalHeaderFormat()135 # Reset: resetVerticalHeaderFormat()136 #137 def getVerticalHeaderFormat(self):138 return self.__verticalHeaderFormat139 def setVerticalHeaderFormat(self, format):140 if format != self.__verticalHeaderFormat:141 self.__verticalHeaderFormat = format142 if self.__cw:143 self.__cw.setVerticalHeaderFormat(format)144 def resetVerticalHeaderFormat(self):145 if self.__verticalHeaderFormat != QtGui.QCalendarWidget.ISOWeekNumbers:146 self.__verticalHeaderFormat = QtGui.QCalendarWidget.ISOWeekNumbers147 if self.__cw:148 self.__cw.setVerticalHeaderFormat(QtGui.QCalendarWidget.ISOWeekNumbers)149 verticalHeaderFormat = QtCore.pyqtProperty(QtGui.QCalendarWidget.VerticalHeaderFormat,150 fget=getVerticalHeaderFormat,151 fset=setVerticalHeaderFormat,152 freset=resetVerticalHeaderFormat)153 #154 # Property navigationBarVisible: bool155 # Get: isNavigationBarVisible()156 # Set: setNavigationBarVisible()157 # Reset: resetNavigationBarVisible()158 #159 def isNavigationBarVisible(self):160 return self.__navigationBarVisible161 def setNavigationBarVisible(self, visible):162 if visible != self.__navigationBarVisible:163 self.__navigationBarVisible = visible164 if self.__cw:165 self.__cw.setNavigationBarVisible(visible)166 def resetNavigationBarVisible(self):167 if self.__navigationBarVisible != True:168 self.__navigationBarVisible = True169 if self.__cw:170 self.__cw.setNavigationBarVisible(True)171 navigationBarVisible = QtCore.pyqtProperty(bool,172 fget=isNavigationBarVisible,173 fset=setNavigationBarVisible,174 freset=resetNavigationBarVisible)175#============================================================================#176# PyDateTimeEdit #177#----------------------------------------------------------------------------#178class PyDateTimeEdit(QtGui.QDateTimeEdit):179 #180 # Initialize base class181 # Force use of the calendar popup182 # Set default values for calendar properties183 #184 def __init__(self, *args):185 super(PyDateTimeEdit, self).__init__(*args)186 self.setCalendarPopup(True)187 self.__cw = None188 self.__firstDayOfWeek = QtCore.Qt.Monday189 self.__gridVisible = False190 self.__horizontalHeaderFormat = QtGui.QCalendarWidget.ShortDayNames191 self.__verticalHeaderFormat = QtGui.QCalendarWidget.ISOWeekNumbers192 self.__navigationBarVisible = True193 #194 # Call event handler of base class195 # Get the calendar widget, if not already done196 # Set the calendar properties197 #198 def mousePressEvent(self, event):199 super(PyDateTimeEdit, self).mousePressEvent(event)200 if not self.__cw:201 self.__cw = self.findChild(QtGui.QCalendarWidget)202 if self.__cw:203 self.__cw.setFirstDayOfWeek(self.__firstDayOfWeek)204 self.__cw.setGridVisible(self.__gridVisible)205 self.__cw.setHorizontalHeaderFormat(self.__horizontalHeaderFormat)206 self.__cw.setVerticalHeaderFormat(self.__verticalHeaderFormat)207 self.__cw.setNavigationBarVisible(self.__navigationBarVisible)208 #209 # Make sure, the calendarPopup property is invisible in Designer210 #211 def getCalendarPopup(self):212 return True213 calendarPopup = QtCore.pyqtProperty(bool, fget=getCalendarPopup)214 #215 # Property firstDayOfWeek: Qt::DayOfWeek216 # Get: getFirstDayOfWeek()217 # Set: setFirstDayOfWeek()218 # Reset: resetFirstDayOfWeek()219 #220 def getFirstDayOfWeek(self):221 return self.__firstDayOfWeek222 def setFirstDayOfWeek(self, dayOfWeek):223 if dayOfWeek != self.__firstDayOfWeek:224 self.__firstDayOfWeek = dayOfWeek225 if self.__cw:226 self.__cw.setFirstDayOfWeek(dayOfWeek)227 def resetFirstDayOfWeek(self):228 if self.__firstDayOfWeek != QtCore.Qt.Monday:229 self.__firstDayOfWeek = QtCore.Qt.Monday230 if self.__cw:231 self.__cw.setFirstDayOfWeek(QtCore.Qt.Monday)232 firstDayOfWeek = QtCore.pyqtProperty(QtCore.Qt.DayOfWeek,233 fget=getFirstDayOfWeek,234 fset=setFirstDayOfWeek,235 freset=resetFirstDayOfWeek)236 #237 # Property gridVisible: bool238 # Get: isGridVisible()239 # Set: setGridVisible()240 # Reset: resetGridVisible()241 #242 def isGridVisible(self):243 return self.__gridVisible244 def setGridVisible(self, show):245 if show != self.__gridVisible:246 self.__gridVisible = show247 if self.__cw:248 self.__cw.setGridVisible(show)249 def resetGridVisible(self):250 if self.__gridVisible != False:251 self.__gridVisible = False252 if self.__cw:253 self.__cw.setGridVisible(False)254 gridVisible = QtCore.pyqtProperty(bool,255 fget=isGridVisible,256 fset=setGridVisible,257 freset=resetGridVisible)258 #259 # Property horizontalHeaderFormat: QCalendarWidget::HorizontalHeaderFormat260 # Get: getHorizontalHeaderFormat()261 # Set: setHorizontalHeaderFormat()262 # Reset: resetHorizontalHeaderFormat()263 #264 def getHorizontalHeaderFormat(self):265 return self.__horizontalHeaderFormat266 def setHorizontalHeaderFormat(self, format):267 if format != self.__horizontalHeaderFormat:268 self.__horizontalHeaderFormat = format269 if self.__cw:270 self.__cw.setHorizontalHeaderFormat(format)271 def resetHorizontalHeaderFormat(self):272 if self.__horizontalHeaderFormat != QtGui.QCalendarWidget.ShortDayNames:273 self.__horizontalHeaderFormat = QtGui.QCalendarWidget.ShortDayNames274 if self.__cw:275 self.__cw.setHorizontalHeaderFormat(QtGui.QCalendarWidget.ShortDayNames)276 horizontalHeaderFormat = QtCore.pyqtProperty(QtGui.QCalendarWidget.HorizontalHeaderFormat,277 fget=getHorizontalHeaderFormat,278 fset=setHorizontalHeaderFormat,279 freset=resetHorizontalHeaderFormat)280 #281 # Property verticalHeaderFormat: QCalendarWidget::VerticalHeaderFormat282 # Get: getVerticalHeaderFormat()283 # Set: setVerticalHeaderFormat()284 # Reset: resetVerticalHeaderFormat()285 #286 def getVerticalHeaderFormat(self):287 return self.__verticalHeaderFormat288 def setVerticalHeaderFormat(self, format):289 if format != self.__verticalHeaderFormat:290 self.__verticalHeaderFormat = format291 if self.__cw:292 self.__cw.setVerticalHeaderFormat(format)293 def resetVerticalHeaderFormat(self):294 if self.__verticalHeaderFormat != QtGui.QCalendarWidget.ISOWeekNumbers:295 self.__verticalHeaderFormat = QtGui.QCalendarWidget.ISOWeekNumbers296 if self.__cw:297 self.__cw.setVerticalHeaderFormat(QtGui.QCalendarWidget.ISOWeekNumbers)298 verticalHeaderFormat = QtCore.pyqtProperty(QtGui.QCalendarWidget.VerticalHeaderFormat,299 fget=getVerticalHeaderFormat,300 fset=setVerticalHeaderFormat,301 freset=resetVerticalHeaderFormat)302 #303 # Property navigationBarVisible: bool304 # Get: isNavigationBarVisible()305 # Set: setNavigationBarVisible()306 # Reset: resetNavigationBarVisible()307 #308 def isNavigationBarVisible(self):309 return self.__navigationBarVisible310 def setNavigationBarVisible(self, visible):311 if visible != self.__navigationBarVisible:312 self.__navigationBarVisible = visible313 if self.__cw:314 self.__cw.setNavigationBarVisible(visible)315 def resetNavigationBarVisible(self):316 if self.__navigationBarVisible != True:317 self.__navigationBarVisible = True318 if self.__cw:319 self.__cw.setNavigationBarVisible(True)320 navigationBarVisible = QtCore.pyqtProperty(bool,321 fget=isNavigationBarVisible,322 fset=setNavigationBarVisible,323 freset=resetNavigationBarVisible)324if __name__ == "__main__":325 import sys326 app = QtGui.QApplication(sys.argv)327 w = QtGui.QWidget()328 lay = QtGui.QHBoxLayout()329 lay.addWidget(PyDateEdit())330 lay.addWidget(PyDateTimeEdit())331 w.setLayout(lay)332 w.show()333 sys.exit(app.exec_())334#============================================================================#335# EOF #...
datetimeedit.py
Source:datetimeedit.py
1#!/usr/bin/env python2#============================================================================#3# (Re)Implementation of QDateEdit and QDateTimeEdit. These classes force the #4# use of the calendar popup. #5#----------------------------------------------------------------------------#6# Copyright (c) 2008 by Denviso GmbH, <ulrich.berning@denviso.de> #7# #8# All Rights Reserved #9# #10# Permission to use, copy, modify, and distribute this software and its #11# documentation for any purpose and without fee is hereby granted, #12# provided that the above copyright notice appear in all copies and that #13# both that copyright notice and this permission notice appear in #14# supporting documentation. #15# #16# DENVISO DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS #17# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY #18# AND FITNESS, IN NO EVENT SHALL DENVISO BE LIABLE FOR ANY #19# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES #20# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, #21# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER #22# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE #23# OR PERFORMANCE OF THIS SOFTWARE. #24#----------------------------------------------------------------------------#25from PyQt5.QtCore import pyqtProperty, Qt26from PyQt5.QtWidgets import (QApplication, QCalendarWidget, QDateEdit,27 QDateTimeEdit, QHBoxLayout, QWidget)28#============================================================================#29# PyDateEdit #30#----------------------------------------------------------------------------#31class PyDateEdit(QDateEdit):32 #33 # Initialize base class34 # Force use of the calendar popup35 # Set default values for calendar properties36 #37 def __init__(self, *args):38 super(PyDateEdit, self).__init__(*args)39 self.setCalendarPopup(True)40 self.__cw = None41 self.__firstDayOfWeek = Qt.Monday42 self.__gridVisible = False43 self.__horizontalHeaderFormat = QCalendarWidget.ShortDayNames44 self.__verticalHeaderFormat = QCalendarWidget.ISOWeekNumbers45 self.__navigationBarVisible = True46 #47 # Call event handler of base class48 # Get the calendar widget, if not already done49 # Set the calendar properties50 #51 def mousePressEvent(self, event):52 super(PyDateEdit, self).mousePressEvent(event)53 if not self.__cw:54 self.__cw = self.findChild(QCalendarWidget)55 if self.__cw:56 self.__cw.setFirstDayOfWeek(self.__firstDayOfWeek)57 self.__cw.setGridVisible(self.__gridVisible)58 self.__cw.setHorizontalHeaderFormat(self.__horizontalHeaderFormat)59 self.__cw.setVerticalHeaderFormat(self.__verticalHeaderFormat)60 self.__cw.setNavigationBarVisible(self.__navigationBarVisible)61 #62 # Make sure, the calendarPopup property is invisible in Designer63 #64 def getCalendarPopup(self):65 return True66 calendarPopup = pyqtProperty(bool, fget=getCalendarPopup)67 #68 # Property firstDayOfWeek: Qt::DayOfWeek69 # Get: getFirstDayOfWeek()70 # Set: setFirstDayOfWeek()71 # Reset: resetFirstDayOfWeek()72 #73 def getFirstDayOfWeek(self):74 return self.__firstDayOfWeek75 def setFirstDayOfWeek(self, dayOfWeek):76 if dayOfWeek != self.__firstDayOfWeek:77 self.__firstDayOfWeek = dayOfWeek78 if self.__cw:79 self.__cw.setFirstDayOfWeek(dayOfWeek)80 def resetFirstDayOfWeek(self):81 if self.__firstDayOfWeek != Qt.Monday:82 self.__firstDayOfWeek = Qt.Monday83 if self.__cw:84 self.__cw.setFirstDayOfWeek(Qt.Monday)85 firstDayOfWeek = pyqtProperty(Qt.DayOfWeek,86 fget=getFirstDayOfWeek,87 fset=setFirstDayOfWeek,88 freset=resetFirstDayOfWeek)89 #90 # Property gridVisible: bool91 # Get: isGridVisible()92 # Set: setGridVisible()93 # Reset: resetGridVisible()94 #95 def isGridVisible(self):96 return self.__gridVisible97 def setGridVisible(self, show):98 if show != self.__gridVisible:99 self.__gridVisible = show100 if self.__cw:101 self.__cw.setGridVisible(show)102 def resetGridVisible(self):103 if self.__gridVisible != False:104 self.__gridVisible = False105 if self.__cw:106 self.__cw.setGridVisible(False)107 gridVisible = pyqtProperty(bool,108 fget=isGridVisible,109 fset=setGridVisible,110 freset=resetGridVisible)111 #112 # Property horizontalHeaderFormat: QCalendarWidget::HorizontalHeaderFormat113 # Get: getHorizontalHeaderFormat()114 # Set: setHorizontalHeaderFormat()115 # Reset: resetHorizontalHeaderFormat()116 #117 def getHorizontalHeaderFormat(self):118 return self.__horizontalHeaderFormat119 def setHorizontalHeaderFormat(self, format):120 if format != self.__horizontalHeaderFormat:121 self.__horizontalHeaderFormat = format122 if self.__cw:123 self.__cw.setHorizontalHeaderFormat(format)124 def resetHorizontalHeaderFormat(self):125 if self.__horizontalHeaderFormat != QCalendarWidget.ShortDayNames:126 self.__horizontalHeaderFormat = QCalendarWidget.ShortDayNames127 if self.__cw:128 self.__cw.setHorizontalHeaderFormat(QCalendarWidget.ShortDayNames)129 horizontalHeaderFormat = pyqtProperty(QCalendarWidget.HorizontalHeaderFormat,130 fget=getHorizontalHeaderFormat,131 fset=setHorizontalHeaderFormat,132 freset=resetHorizontalHeaderFormat)133 #134 # Property verticalHeaderFormat: QCalendarWidget::VerticalHeaderFormat135 # Get: getVerticalHeaderFormat()136 # Set: setVerticalHeaderFormat()137 # Reset: resetVerticalHeaderFormat()138 #139 def getVerticalHeaderFormat(self):140 return self.__verticalHeaderFormat141 def setVerticalHeaderFormat(self, format):142 if format != self.__verticalHeaderFormat:143 self.__verticalHeaderFormat = format144 if self.__cw:145 self.__cw.setVerticalHeaderFormat(format)146 def resetVerticalHeaderFormat(self):147 if self.__verticalHeaderFormat != QCalendarWidget.ISOWeekNumbers:148 self.__verticalHeaderFormat = QCalendarWidget.ISOWeekNumbers149 if self.__cw:150 self.__cw.setVerticalHeaderFormat(QCalendarWidget.ISOWeekNumbers)151 verticalHeaderFormat = pyqtProperty(QCalendarWidget.VerticalHeaderFormat,152 fget=getVerticalHeaderFormat,153 fset=setVerticalHeaderFormat,154 freset=resetVerticalHeaderFormat)155 #156 # Property navigationBarVisible: bool157 # Get: isNavigationBarVisible()158 # Set: setNavigationBarVisible()159 # Reset: resetNavigationBarVisible()160 #161 def isNavigationBarVisible(self):162 return self.__navigationBarVisible163 def setNavigationBarVisible(self, visible):164 if visible != self.__navigationBarVisible:165 self.__navigationBarVisible = visible166 if self.__cw:167 self.__cw.setNavigationBarVisible(visible)168 def resetNavigationBarVisible(self):169 if self.__navigationBarVisible != True:170 self.__navigationBarVisible = True171 if self.__cw:172 self.__cw.setNavigationBarVisible(True)173 navigationBarVisible = pyqtProperty(bool,174 fget=isNavigationBarVisible,175 fset=setNavigationBarVisible,176 freset=resetNavigationBarVisible)177#============================================================================#178# PyDateTimeEdit #179#----------------------------------------------------------------------------#180class PyDateTimeEdit(QDateTimeEdit):181 #182 # Initialize base class183 # Force use of the calendar popup184 # Set default values for calendar properties185 #186 def __init__(self, *args):187 super(PyDateTimeEdit, self).__init__(*args)188 self.setCalendarPopup(True)189 self.__cw = None190 self.__firstDayOfWeek = Qt.Monday191 self.__gridVisible = False192 self.__horizontalHeaderFormat = QCalendarWidget.ShortDayNames193 self.__verticalHeaderFormat = QCalendarWidget.ISOWeekNumbers194 self.__navigationBarVisible = True195 #196 # Call event handler of base class197 # Get the calendar widget, if not already done198 # Set the calendar properties199 #200 def mousePressEvent(self, event):201 super(PyDateTimeEdit, self).mousePressEvent(event)202 if not self.__cw:203 self.__cw = self.findChild(QCalendarWidget)204 if self.__cw:205 self.__cw.setFirstDayOfWeek(self.__firstDayOfWeek)206 self.__cw.setGridVisible(self.__gridVisible)207 self.__cw.setHorizontalHeaderFormat(self.__horizontalHeaderFormat)208 self.__cw.setVerticalHeaderFormat(self.__verticalHeaderFormat)209 self.__cw.setNavigationBarVisible(self.__navigationBarVisible)210 #211 # Make sure, the calendarPopup property is invisible in Designer212 #213 def getCalendarPopup(self):214 return True215 calendarPopup = pyqtProperty(bool, fget=getCalendarPopup)216 #217 # Property firstDayOfWeek: Qt::DayOfWeek218 # Get: getFirstDayOfWeek()219 # Set: setFirstDayOfWeek()220 # Reset: resetFirstDayOfWeek()221 #222 def getFirstDayOfWeek(self):223 return self.__firstDayOfWeek224 def setFirstDayOfWeek(self, dayOfWeek):225 if dayOfWeek != self.__firstDayOfWeek:226 self.__firstDayOfWeek = dayOfWeek227 if self.__cw:228 self.__cw.setFirstDayOfWeek(dayOfWeek)229 def resetFirstDayOfWeek(self):230 if self.__firstDayOfWeek != Qt.Monday:231 self.__firstDayOfWeek = Qt.Monday232 if self.__cw:233 self.__cw.setFirstDayOfWeek(Qt.Monday)234 firstDayOfWeek = pyqtProperty(Qt.DayOfWeek,235 fget=getFirstDayOfWeek,236 fset=setFirstDayOfWeek,237 freset=resetFirstDayOfWeek)238 #239 # Property gridVisible: bool240 # Get: isGridVisible()241 # Set: setGridVisible()242 # Reset: resetGridVisible()243 #244 def isGridVisible(self):245 return self.__gridVisible246 def setGridVisible(self, show):247 if show != self.__gridVisible:248 self.__gridVisible = show249 if self.__cw:250 self.__cw.setGridVisible(show)251 def resetGridVisible(self):252 if self.__gridVisible != False:253 self.__gridVisible = False254 if self.__cw:255 self.__cw.setGridVisible(False)256 gridVisible = pyqtProperty(bool,257 fget=isGridVisible,258 fset=setGridVisible,259 freset=resetGridVisible)260 #261 # Property horizontalHeaderFormat: QCalendarWidget::HorizontalHeaderFormat262 # Get: getHorizontalHeaderFormat()263 # Set: setHorizontalHeaderFormat()264 # Reset: resetHorizontalHeaderFormat()265 #266 def getHorizontalHeaderFormat(self):267 return self.__horizontalHeaderFormat268 def setHorizontalHeaderFormat(self, format):269 if format != self.__horizontalHeaderFormat:270 self.__horizontalHeaderFormat = format271 if self.__cw:272 self.__cw.setHorizontalHeaderFormat(format)273 def resetHorizontalHeaderFormat(self):274 if self.__horizontalHeaderFormat != QCalendarWidget.ShortDayNames:275 self.__horizontalHeaderFormat = QCalendarWidget.ShortDayNames276 if self.__cw:277 self.__cw.setHorizontalHeaderFormat(QCalendarWidget.ShortDayNames)278 horizontalHeaderFormat = pyqtProperty(QCalendarWidget.HorizontalHeaderFormat,279 fget=getHorizontalHeaderFormat,280 fset=setHorizontalHeaderFormat,281 freset=resetHorizontalHeaderFormat)282 #283 # Property verticalHeaderFormat: QCalendarWidget::VerticalHeaderFormat284 # Get: getVerticalHeaderFormat()285 # Set: setVerticalHeaderFormat()286 # Reset: resetVerticalHeaderFormat()287 #288 def getVerticalHeaderFormat(self):289 return self.__verticalHeaderFormat290 def setVerticalHeaderFormat(self, format):291 if format != self.__verticalHeaderFormat:292 self.__verticalHeaderFormat = format293 if self.__cw:294 self.__cw.setVerticalHeaderFormat(format)295 def resetVerticalHeaderFormat(self):296 if self.__verticalHeaderFormat != QCalendarWidget.ISOWeekNumbers:297 self.__verticalHeaderFormat = QCalendarWidget.ISOWeekNumbers298 if self.__cw:299 self.__cw.setVerticalHeaderFormat(QCalendarWidget.ISOWeekNumbers)300 verticalHeaderFormat = pyqtProperty(QCalendarWidget.VerticalHeaderFormat,301 fget=getVerticalHeaderFormat,302 fset=setVerticalHeaderFormat,303 freset=resetVerticalHeaderFormat)304 #305 # Property navigationBarVisible: bool306 # Get: isNavigationBarVisible()307 # Set: setNavigationBarVisible()308 # Reset: resetNavigationBarVisible()309 #310 def isNavigationBarVisible(self):311 return self.__navigationBarVisible312 def setNavigationBarVisible(self, visible):313 if visible != self.__navigationBarVisible:314 self.__navigationBarVisible = visible315 if self.__cw:316 self.__cw.setNavigationBarVisible(visible)317 def resetNavigationBarVisible(self):318 if self.__navigationBarVisible != True:319 self.__navigationBarVisible = True320 if self.__cw:321 self.__cw.setNavigationBarVisible(True)322 navigationBarVisible = pyqtProperty(bool,323 fget=isNavigationBarVisible,324 fset=setNavigationBarVisible,325 freset=resetNavigationBarVisible)326if __name__ == "__main__":327 import sys328 app = QApplication(sys.argv)329 w = QWidget()330 lay = QHBoxLayout()331 lay.addWidget(PyDateEdit())332 lay.addWidget(PyDateTimeEdit())333 w.setLayout(lay)334 w.show()335 sys.exit(app.exec_())336#============================================================================#337# EOF #...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!