def setPriority(self, color): if color == 'Custom': self.priority = QtGui.QColorDialog.getColor() elif color == 'None' or color == 'Choose a Priority': self.priority = self.note.background else: self.priority = color if self.priority.isValid(): self.eventLabel.setStyleSheet("QWidget { background-color: % s }" % self.priority.name()) JSONfunctions.convert_all_events(self.note, NotesOnDisplay, NotesOnDisplayJSON) JSONfunctions.save(NotesOnDisplayJSON, SIZE, FONTSIZE)
def AddEvent(self): description = self.enterText.text() if description == '': self.warning = QtGui.QMessageBox.information(self, 'Warning', 'You must enter a description', QtGui.QMessageBox.Close) return priority = str(self.prioritySelector.currentText()) newEvent = Event(self.note, description, priority) self.note.events.append(newEvent) self.note.displayEvents() JSONfunctions.convert_all_events(self.note, NotesOnDisplay, NotesOnDisplayJSON) JSONfunctions.save(NotesOnDisplayJSON, SIZE, FONTSIZE) self.accept()
def finishEditAct(self): index = self.note.eventLayout.indexOf(self.eventLabel) text = self.eventLabel.text() if text == '': self.delete() return self.eventLabel.deleteLater() self.initLabelUI(text) self.description = text self.setPriority(self.priority) self.note.events[index] = self self.createActions() self.note.displayEvents() JSONfunctions.convert_all_events(self.note, NotesOnDisplay, NotesOnDisplayJSON) JSONfunctions.save(NotesOnDisplayJSON, SIZE, FONTSIZE)
def callback(): color = col if color == "Custom": color = QtGui.QColorDialog.getColor() if color.isValid(): for event in self.events: if self.background == event.priority: event.priority = color event.eventLabel.setStyleSheet("QWidget { background-color: % s }" % color.name()) self.background = color self.repaint() JSONfunctions.update_background(self, color, NotesOnDisplay, NotesOnDisplayJSON) JSONfunctions.convert_all_events(self, NotesOnDisplay, NotesOnDisplayJSON) JSONfunctions.save(NotesOnDisplayJSON, SIZE, FONTSIZE) self.setColorChecked()
def main(): NotesDisplayed = [] json_data = open('settings.txt') data = json.load(json_data) GUIClasses.SIZE = data['SIZE'] GUIClasses.FONTSIZE = data['FONTSIZE'] NotesToDisplay = data['days'] app = QtGui.QApplication(sys.argv) splash = GUIClasses.QuoteScreen() if len(NotesToDisplay) == 0: first = GUIClasses.Note() first.hide() for item in NotesToDisplay: new_note = GUIClasses.Note(item['day'], item['position'], item['background']) for event in item['events']: new_event = GUIClasses.Event(new_note, str(event['description']), JSONfunctions.convert_RGBList_to_Color(event['priority'])) new_note.events.append(new_event) new_note.displayEvents() new_note.hide() JSONfunctions.convert_all_events(new_note, GUIClasses.NotesOnDisplay, GUIClasses.NotesOnDisplayJSON) NotesDisplayed.append(new_note) sys.exit(app.exec_())
def delete(self): self.eventLabel.deleteLater() self.note.events.remove(self) self.note.displayEvents() JSONfunctions.convert_all_events(self.note, NotesOnDisplay, NotesOnDisplayJSON) JSONfunctions.save(NotesOnDisplayJSON, SIZE, FONTSIZE)