Ejemplo n.º 1
0
    def check_select_status(self, editor, date, selected):
        from pyface.qt import QtCore, QtGui

        qdate = QtCore.QDate(date.year, date.month, date.day)
        textformat = editor.control.dateTextFormat(qdate)
        if selected:
            self.assertEqual(
                textformat.fontWeight(),
                QtGui.QFont.Weight.Bold,
                "{!r} is not selected.".format(date),
            )
            self.check_date_bgcolor(editor, date, (0, 128, 0))
        else:
            self.assertEqual(
                textformat.fontWeight(),
                QtGui.QFont.Weight.Normal,
                "{!r} is not unselected.".format(date),
            )
            self.assertEqual(
                textformat.background().style(),
                0,  # Qt.BrushStyle.NoBrush,
                "Expected brush to have been reset.",
            )
            self.check_date_bgcolor(editor, date, (0, 0, 0))
Ejemplo n.º 2
0
 def click_date_on_editor(self, editor, date):
     from pyface.qt import QtCore
     # QCalendarWidget.setSelectedDate modifies internal state
     # instead of triggering the click signal.
     # So we call update_object directly
     editor.update_object(QtCore.QDate(date.year, date.month, date.day))
Ejemplo n.º 3
0
 def apply_style(self, style, date):
     """ Apply a given style to a given date."""
     qdt = QtCore.QDate(date)
     textformat = self.control.dateTextFormat(qdt)
     _apply_cellformat(style, textformat)
     self.control.setDateTextFormat(qdt, textformat)
Ejemplo n.º 4
0
 def _reset_formatting(self, dates):
     # Resets the text format on the given dates
     for dt in dates:
         qdt = QtCore.QDate(dt)
         self.control.setDateTextFormat(qdt, QtGui.QTextCharFormat())