def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.diary_control = DiaryControl() self.diary_widget = DiaryWidget() self.model = DiaryDataModel() self.diary_widget.setModel(self.model) layout = QtGui.QHBoxLayout(self) layout.setMargin(0) layout.setSpacing(0) layout.addWidget(self.diary_control) layout.addWidget(self.diary_widget) self.connect_signals()
class DiaryInterface(QtGui.QWidget): ''' A composite widget containing all elements for viewing a patient record ''' def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.diary_control = DiaryControl() self.diary_widget = DiaryWidget() self.model = DiaryDataModel() self.diary_widget.setModel(self.model) layout = QtGui.QHBoxLayout(self) layout.setMargin(0) layout.setSpacing(0) layout.addWidget(self.diary_control) layout.addWidget(self.diary_widget) self.connect_signals() def sizeHint(self): return QtCore.QSize(500, 400) def connect_signals(self): self.diary_control.date_changed.connect(self.diary_widget.set_date) self.diary_control.view_changed.connect(self.diary_widget.setViewStyle) def refresh(self): ''' usually called when the database has connected/changed ''' QtGui.QApplication.instance().setOverrideCursor(QtCore.Qt.WaitCursor) self.diary_control.refresh() self.model.load() self.diary_control.set_limits(self.model.start_date, self.model.end_date) QtGui.QApplication.instance().restoreOverrideCursor() def Advise(self, *args): if __name__ == "__main__": print args self.emit(QtCore.SIGNAL("Advise"), *args)