def __init__(self, parent): super(GanttDialog, self).__init__(parent) self.ui = Ui_ganttDialog() self.ui.setupUi(self) self.update() self.ui.generateBtn.clicked.connect(self.generateDiagram)
class GanttDialog(QtGui.QDialog): def __init__(self, parent): super(GanttDialog, self).__init__(parent) self.ui = Ui_ganttDialog() self.ui.setupUi(self) self.update() self.ui.generateBtn.clicked.connect(self.generateDiagram) def update(self): self.ui.projectsComboBox.clear() self.ui.webView.setHtml('<html><body></body></html>') projects = appInst.getNotEmptyProjects() for project in projects: self.ui.projectsComboBox.addItem(project.name, project.id) def generateDiagram(self): if not self.ui.projectsComboBox.currentText(): raise DBException("There aren't projects in db") return projectId = self.ui.projectsComboBox.itemData(self.ui.projectsComboBox.currentIndex()).toInt()[0] ganttDiagram = GanttChart(dbi.query(Task).filter(Task.projectId == projectId).all()) self.ui.webView.setHtml(ganttDiagram.generateDiagram())