当前位置: 首页>>代码示例>>Python>>正文


Python QDate.dayOfWeek方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QDate.dayOfWeek方法的典型用法代码示例。如果您正苦于以下问题:Python QDate.dayOfWeek方法的具体用法?Python QDate.dayOfWeek怎么用?Python QDate.dayOfWeek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QDate的用法示例。


在下文中一共展示了QDate.dayOfWeek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rebuildMonth

# 需要导入模块: from PyQt4.QtCore import QDate [as 别名]
# 或者: from PyQt4.QtCore.QDate import dayOfWeek [as 别名]
 def rebuildMonth( self ):
     """
     Rebuilds the month for this scene.
     """
     # make sure we start at 0 for sunday vs. 7 for sunday
     day_map     = dict([(i+1, i+1) for i in range(7)])
     day_map[7]  = 0
     
     today   = QDate.currentDate()
     curr    = self.currentDate()
     first   = QDate(curr.year(), curr.month(), 1)
     last    = QDate(curr.year(), curr.month(), curr.daysInMonth())
     first   = first.addDays(-day_map[first.dayOfWeek()])
     last    = last.addDays(6-day_map[last.dayOfWeek()])
     
     cols    = 7
     rows    = (first.daysTo(last) + 1) / cols
     
     hlines  = []
     vlines  = []
     
     padx    = 6
     pady    = 6
     header  = 24
     
     w       = self.width() - (2 * padx)
     h       = self.height() - (2 * pady)
     
     dw      = (w / cols) - 1
     dh      = ((h - header) / rows) - 1
     
     x0      = padx
     y0      = pady + header
     
     x       = x0
     y       = y0
     
     for row in range(rows + 1):
         hlines.append(QLine(x0, y, w, y))
         y += dh
     
     for col in range(cols + 1):
         vlines.append(QLine(x, y0, x, h))
         x += dw
     
     self._buildData['grid'] = hlines + vlines
     
     # draw the date fields
     date = first
     row  = 0
     col  = 0
     
     # draw the headers
     x = x0
     y = pady
     
     regular_text = []
     mid_text     = []
     self._buildData['regular_text'] = regular_text
     self._buildData['mid_text']     = mid_text
     
     for day in ('Sun', 'Mon','Tue','Wed','Thu','Fri','Sat'):
         regular_text.append((x + 5,
                              y,
                              dw,
                              y0,
                              Qt.AlignLeft | Qt.AlignVCenter,
                              day))
         x += dw
     
     for i in range(first.daysTo(last) + 1):
         top    = (y0 + (row * dh))
         left   = (x0 + (col * dw))
         rect   = QRectF(left - 1, top, dw, dh)
         
         # mark the current date on the calendar
         if ( date == curr ):
             self._buildData['curr_date'] = rect
         
         # mark today's date on the calendar
         elif ( date == today ):
             self._buildData['today'] = rect
         
         # determine how to draw the calendar
         format = 'd'
         if ( date.day() == 1 ):
             format = 'MMM d'
         
         # determine the color to draw the text
         if ( date.month() == curr.month() ):
             text = regular_text
         else:
             text = mid_text
         
         # draw the text
         text.append((left + 2,
                      top + 2,
                      dw - 4,
                      dh - 4,
                      Qt.AlignTop | Qt.AlignLeft,
#.........这里部分代码省略.........
开发者ID:satishgoda,项目名称:DPS_PIPELINE,代码行数:103,代码来源:xcalendarscene.py


注:本文中的PyQt4.QtCore.QDate.dayOfWeek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。