예제 #1
0
    def printMessage(self, txt, showDateTime = False, autoPopup = True, end = '\n'):
        if txt == ' ':
            txt = ' '
        else:
            txt = ('%s%s' % (txt, end)).replace('\n', '<br>')
            if showDateTime:
                txt = '%s %s' % (DateTime.now().strftime('%Y-%m-%d %H:%M:%S'), txt)
        tc = self.textEdit.textCursor()
        tc.movePosition(QtGui.QTextCursor.End)
        self.textEdit.setTextCursor(tc)
        self.textEdit.insertHtml(txt)
        self.textEdit.ensureCursorVisible() # scroll to the new message
#        if autoPopup:
#            self.show()
        self.setVisible(autoPopup)
예제 #2
0
파일: __init__.py 프로젝트: warvariuc/wic
 def fillItemFromForm(self):
     """Automatically fill the item field values from the corresponding form widgets.
     """
     catalogItem = self._catalogItem
     for field in catalogItem.__class__:
         fieldName = field.name
         widget = getattr(self, fieldName, None)
         if widget:
             fieldValue = forms.getValue(widget)
             if isinstance(field, orm.IdField) and not fieldValue: # if nothing is entered into Id field - treat it as NULL
                 fieldValue = None
             elif isinstance(field, orm.DateTimeField):
                 if any(char.isdigit() for char in fieldValue):
                     fieldValue = DateTime.strptime(fieldValue, '%Y-%m-%d %H:%M:%S.%f')
                 else:
                     fieldValue = None
             setattr(catalogItem, fieldName, fieldValue)
예제 #3
0
 def date(self):
     """Return the date entered in the field. If it is empty or invalid - `None` is returned."""
     try:
         return DateTime.strptime(self.text(), '%d.%m.%Y').date()
     except ValueError:
         return None