class ResultWindow(QtGui.QDialog): def __init__(self,parent=None): QtGui.QWidget.__init__(self, parent) self.ui= Ui_results() self.ui.setupUi(self) def show_results(self,prenoms): import rpvote import glob ballots = [] for f in glob.glob("ballots_*.txt"): b = Ballots(f) ballots.extend(b.ballots) contest = rpvote.Contest(prenoms) for winner,delim,loser,count in ballots: contest.addballot([[winner],[loser]]) contest.computemargins() #contest.printmargins() outcome = contest.compute() #outcome.printout() #outcome.printresult() table=self.ui.table table.setRowCount(len(prenoms)) for n,(rank,name,res) in enumerate(outcome.getresult()): table.setItem(n,0,NumericalTableItem(rank)) table.setItem(n,1,NumericalTableItem(name)) table.setItem(n,2,NumericalTableItem(str(res))) table.resizeColumnsToContents() self.exec_()
def openResults(self): def getGuess(qTableWidget, row): candidate = qTableWidget.cellWidget(row, 1) if(str(candidate).isdigit()): return int(candidate) else: return int((int(candidate.text().split("-")[0]) * int(candidate.text().split("-")[1])) ** (1.0/2.0)) def getName(qTableWidget, row): return str(qTableWidget.item(row, 0).text()) print "Attempting to open results" # Save Algae View as image for review later outImage = QPixmap(999, 400) painter = QPainter(outImage) self.scene.render(painter) mypath = os.getcwd()+"/TempSampleRenders" if not os.path.isdir(mypath): os.makedirs(mypath) if(not outImage.save(os.getcwd()+"/TempSampleRenders/Trial" + str(algaeTable.Get_Current_Round()+1) + ".png")): print "failed to save render" painter.end() ## Record user answers for z in xrange(self.ans_table.rowCount()): key = getName(self.ans_table, z) count = getGuess(self.ans_table, z) algaeTable.Set_User_Count(key,algaeTable.Get_Current_Round(),count) ## Only show results page after all trials are finished if (algaeTable.Get_Num_Trials() <= 1): print "All trials finished" resultsDialog=Ui_results() ui=QtGui.QDialog(); resultsDialog.setupUi(ui, algaeTable,self.ans_table) ui.setModal(True) ui.exec_() ## Start new session ##algaeTable.Set_Num_Trials(algaeTable.Total_Trials) self.openPreferences() else: print "More trials to go" algaeTable.Decrement_Trials() #after Results page closes generate new sample and reset forms self.resetForms() algaeTable.Generate_Sample() self.setUpScene(self.scene, self.view) print "Finished trying to open results."
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(999, 792) self.centralWidget = QtGui.QWidget(MainWindow) self.centralWidget.setObjectName(_fromUtf8("centralWidget")) self.glWidget = GLWidget(self.centralWidget) self.findButton = QtGui.QPushButton(self.centralWidget) self.findButton.setGeometry(QtCore.QRect(870, 430, 91, 31)) self.findButton.setObjectName(_fromUtf8("findButton")) self.groupBox_mag = QtGui.QGroupBox(self.centralWidget) self.groupBox_mag.setGeometry(QtCore.QRect(340, 430, 201, 271)) self.groupBox_mag.setTitle(_fromUtf8("")) self.groupBox_mag.setObjectName(_fromUtf8("groupBox_mag")) self.label = QtGui.QLabel(self.groupBox_mag) self.label.setGeometry(QtCore.QRect(60, 240, 101, 20)) self.label.setObjectName(_fromUtf8("label")) self.mag_dial = QtGui.QDial(self.groupBox_mag) self.mag_dial.setGeometry(QtCore.QRect(60, 70, 91, 101)) self.mag_dial.setMinimum(0) self.mag_dial.setMaximum(100) self.mag_dial.setInvertedAppearance(False) self.mag_dial.setInvertedControls(False) self.mag_dial.setWrapping(True) self.mag_dial.setNotchesVisible(False) self.mag_dial.setObjectName(_fromUtf8("mag_dial")) self.mag_dial.keyPressEvent = lambda event: event.ignore() self.label_4 = QtGui.QLabel(self.groupBox_mag) self.label_4.setGeometry(QtCore.QRect(90, 50, 66, 17)) self.label_4.setObjectName(_fromUtf8("label_4")) self.label_5 = QtGui.QLabel(self.groupBox_mag) self.label_5.setGeometry(QtCore.QRect(30, 110, 41, 17)) self.label_5.setObjectName(_fromUtf8("label_5")) self.label_6 = QtGui.QLabel(self.groupBox_mag) self.label_6.setGeometry(QtCore.QRect(150, 110, 71, 17)) self.label_6.setObjectName(_fromUtf8("label_6")) self.label_7 = QtGui.QLabel(self.groupBox_mag) self.label_7.setGeometry(QtCore.QRect(90, 170, 41, 17)) self.label_7.setObjectName(_fromUtf8("label_7")) self.input_species = QtGui.QLineEdit(self.centralWidget) self.input_species.setGeometry(QtCore.QRect(550, 430, 181, 31)) self.input_species.setText(_fromUtf8("")) self.input_species.setObjectName(_fromUtf8("input_species")) self.submit_button = QtGui.QPushButton(self.centralWidget) self.submit_button.setGeometry(QtCore.QRect(640, 660, 231, 41)) self.submit_button.setObjectName(_fromUtf8("submit_button")) self.groupBox_move = QtGui.QGroupBox(self.centralWidget) self.groupBox_move.setGeometry(QtCore.QRect(30, 430, 291, 271)) self.groupBox_move.setTitle(_fromUtf8("")) self.groupBox_move.setObjectName(_fromUtf8("groupBox_move")) self.up_button = QtGui.QPushButton(self.groupBox_move) self.up_button.setGeometry(QtCore.QRect(100, 40, 71, 28)) self.up_button.setObjectName(_fromUtf8("up_button")) self.pushButton_2 = QtGui.QPushButton(self.groupBox_move) self.pushButton_2.setGeometry(QtCore.QRect(20, 100, 61, 28)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.right_button = QtGui.QPushButton(self.groupBox_move) self.right_button.setGeometry(QtCore.QRect(192, 100, 71, 28)) self.right_button.setObjectName(_fromUtf8("right_button")) self.down_button = QtGui.QPushButton(self.groupBox_move) self.down_button.setGeometry(QtCore.QRect(100, 160, 71, 28)) self.down_button.setObjectName(_fromUtf8("down_button")) self.label_2 = QtGui.QLabel(self.groupBox_move) self.label_2.setGeometry(QtCore.QRect(120, 240, 71, 20)) self.label_2.setObjectName(_fromUtf8("label_2")) self.input_count = QtGui.QLineEdit(self.centralWidget) self.input_count.setGeometry(QtCore.QRect(750, 430, 111, 31)) self.input_count.setText(_fromUtf8("")) self.input_count.setObjectName(_fromUtf8("input_count")) self.ans_table = QtGui.QTableView(self.centralWidget) self.ans_table.setGeometry(QtCore.QRect(550, 470, 411, 181)) self.ans_table.setObjectName(_fromUtf8("ans_table")) MainWindow.setCentralWidget(self.centralWidget) self.menuBar = QtGui.QMenuBar(MainWindow) self.menuBar.setGeometry(QtCore.QRect(0, 0, 999, 26)) self.menuBar.setObjectName(_fromUtf8("menuBar")) self.menuFile = QtGui.QMenu(self.menuBar) self.menuFile.setObjectName(_fromUtf8("menuFile")) self.menuTools = QtGui.QMenu(self.menuBar) self.menuTools.setObjectName(_fromUtf8("menuTools")) MainWindow.setMenuBar(self.menuBar) self.mainToolBar = QtGui.QToolBar(MainWindow) self.mainToolBar.setObjectName(_fromUtf8("mainToolBar")) MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar) self.statusBar = QtGui.QStatusBar(MainWindow) self.statusBar.setObjectName(_fromUtf8("statusBar")) MainWindow.setStatusBar(self.statusBar) self.actionOpen = QtGui.QAction(MainWindow) self.actionOpen.setObjectName(_fromUtf8("actionOpen")) self.actionSave = QtGui.QAction(MainWindow) self.actionSave.setObjectName(_fromUtf8("actionSave")) self.actionAbout = QtGui.QAction(MainWindow) self.actionAbout.setObjectName(_fromUtf8("actionAbout")) self.actionControls = QtGui.QAction(MainWindow) self.actionControls.setObjectName(_fromUtf8("actionControls")) self.actionImport_Sample = QtGui.QAction(MainWindow) self.actionImport_Sample.setObjectName(_fromUtf8("actionImport_Sample")) self.actionCreate_New_Sample = QtGui.QAction(MainWindow) self.actionCreate_New_Sample.setObjectName(_fromUtf8("actionCreate_New_Sample")) self.menuFile.addAction(self.actionOpen) self.menuFile.addAction(self.actionSave) self.menuFile.addSeparator() self.menuFile.addAction(self.actionImport_Sample) self.menuFile.addAction(self.actionCreate_New_Sample) self.menuTools.addAction(self.actionAbout) self.menuTools.addAction(self.actionControls) self.menuBar.addAction(self.menuFile.menuAction()) self.menuBar.addAction(self.menuTools.menuAction()) self.resultsDialog=Ui_results() self.submit_button.clicked.connect(self.openResults) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self,parent=None): QtGui.QWidget.__init__(self, parent) self.ui= Ui_results() self.ui.setupUi(self)
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(999, 792) self.centralWidget = QtGui.QWidget(MainWindow) self.centralWidget.setObjectName(_fromUtf8("centralWidget")) self.glWidget = GLWidget(self.centralWidget) # Puts images in the glWidget!!!!! pic = QtGui.QLabel(self.glWidget) pic.setGeometry(10,10,79.5,62.75) pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/Assets/attempt001.png")) pic.setScaledContents(True) pic.setStyleSheet("background-color: rgba("+backGroundColorString+")" ) pic = QtGui.QLabel(self.glWidget) pic.setGeometry(350,277,79.5,62.75) pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/Assets/attempt001.png")) pic.setScaledContents(True) pic.setStyleSheet("background-color: rgba("+backGroundColorString+")" ) pic = QtGui.QLabel(self.glWidget) pic.setGeometry(115,347,79.5,62.75) pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/Assets/attempt001.png")) pic.setScaledContents(True) pic.setStyleSheet("background-color: rgba("+backGroundColorString+")" ) pic = QtGui.QLabel(self.glWidget) pic.setGeometry(377,100,79.5,62.75) pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/Assets/attempt001.png")) pic.setScaledContents(True) pic.setStyleSheet("background-color: rgba("+backGroundColorString+")" ) # Controls self.findButton = QtGui.QPushButton(self.centralWidget) self.findButton.setGeometry(QtCore.QRect(870, 430, 91, 31)) self.findButton.setObjectName(_fromUtf8("findButton")) self.groupBox_mag = QtGui.QGroupBox(self.centralWidget) self.groupBox_mag.setGeometry(QtCore.QRect(340, 430, 201, 271)) self.groupBox_mag.setTitle(_fromUtf8("")) self.groupBox_mag.setObjectName(_fromUtf8("groupBox_mag")) self.label = QtGui.QLabel(self.groupBox_mag) self.label.setGeometry(QtCore.QRect(60, 240, 101, 20)) self.label.setObjectName(_fromUtf8("label")) self.mag_dial = QtGui.QDial(self.groupBox_mag) self.mag_dial.setGeometry(QtCore.QRect(60, 70, 91, 101)) self.mag_dial.setMinimum(0) self.mag_dial.setMaximum(100) self.mag_dial.setInvertedAppearance(False) self.mag_dial.setInvertedControls(False) self.mag_dial.setWrapping(True) self.mag_dial.setNotchesVisible(False) self.mag_dial.setObjectName(_fromUtf8("mag_dial")) self.mag_dial.keyPressEvent = lambda event: event.ignore() self.label_4 = QtGui.QLabel(self.groupBox_mag) self.label_4.setGeometry(QtCore.QRect(90, 50, 66, 17)) self.label_4.setObjectName(_fromUtf8("label_4")) self.label_5 = QtGui.QLabel(self.groupBox_mag) self.label_5.setGeometry(QtCore.QRect(30, 110, 41, 17)) self.label_5.setObjectName(_fromUtf8("label_5")) self.label_6 = QtGui.QLabel(self.groupBox_mag) self.label_6.setGeometry(QtCore.QRect(150, 110, 71, 17)) self.label_6.setObjectName(_fromUtf8("label_6")) self.label_7 = QtGui.QLabel(self.groupBox_mag) self.label_7.setGeometry(QtCore.QRect(90, 170, 41, 17)) self.label_7.setObjectName(_fromUtf8("label_7")) self.input_species = QtGui.QLineEdit(self.centralWidget) self.input_species.setGeometry(QtCore.QRect(550, 430, 181, 31)) self.input_species.setText(_fromUtf8("")) self.input_species.setObjectName(_fromUtf8("input_species")) self.submit_button = QtGui.QPushButton(self.centralWidget) self.submit_button.setGeometry(QtCore.QRect(640, 660, 231, 41)) self.submit_button.setObjectName(_fromUtf8("submit_button")) self.groupBox_move = QtGui.QGroupBox(self.centralWidget) self.groupBox_move.setGeometry(QtCore.QRect(30, 430, 291, 271)) self.groupBox_move.setTitle(_fromUtf8("")) self.groupBox_move.setObjectName(_fromUtf8("groupBox_move")) self.groupBox_move.keyPressEvent = lambda event: event.ignore() self.up_button = QtGui.QPushButton(self.groupBox_move) self.up_button.setGeometry(QtCore.QRect(100, 40, 71, 28)) self.up_button.setObjectName(_fromUtf8("up_button")) self.pushButton_2 = QtGui.QPushButton(self.groupBox_move) self.pushButton_2.setGeometry(QtCore.QRect(20, 100, 61, 28)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.right_button = QtGui.QPushButton(self.groupBox_move) self.right_button.setGeometry(QtCore.QRect(192, 100, 71, 28)) self.right_button.setObjectName(_fromUtf8("right_button")) self.down_button = QtGui.QPushButton(self.groupBox_move) self.down_button.setGeometry(QtCore.QRect(100, 160, 71, 28)) self.down_button.setObjectName(_fromUtf8("down_button")) self.label_2 = QtGui.QLabel(self.groupBox_move) self.label_2.setGeometry(QtCore.QRect(120, 240, 71, 20)) self.label_2.setObjectName(_fromUtf8("label_2")) self.input_count = QtGui.QLineEdit(self.centralWidget) self.input_count.setGeometry(QtCore.QRect(750, 430, 111, 31)) self.input_count.setText(_fromUtf8("")) self.input_count.setObjectName(_fromUtf8("input_count")) self.ans_table = QtGui.QTableView(self.centralWidget) self.ans_table.setGeometry(QtCore.QRect(550, 470, 411, 181)) self.ans_table.setObjectName(_fromUtf8("ans_table")) MainWindow.setCentralWidget(self.centralWidget) self.menuBar = QtGui.QMenuBar(MainWindow) self.menuBar.setGeometry(QtCore.QRect(0, 0, 999, 26)) self.menuBar.setObjectName(_fromUtf8("menuBar")) self.menuFile = QtGui.QMenu(self.menuBar) self.menuFile.setObjectName(_fromUtf8("menuFile")) self.menuTools = QtGui.QMenu(self.menuBar) self.menuTools.setObjectName(_fromUtf8("menuTools")) MainWindow.setMenuBar(self.menuBar) self.mainToolBar = QtGui.QToolBar(MainWindow) self.mainToolBar.setObjectName(_fromUtf8("mainToolBar")) MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar) self.statusBar = QtGui.QStatusBar(MainWindow) self.statusBar.setObjectName(_fromUtf8("statusBar")) MainWindow.setStatusBar(self.statusBar) self.actionOpen = QtGui.QAction(MainWindow) self.actionOpen.setObjectName(_fromUtf8("actionOpen")) self.actionSave = QtGui.QAction(MainWindow) self.actionSave.setObjectName(_fromUtf8("actionSave")) self.actionAbout = QtGui.QAction(MainWindow) self.actionAbout.setObjectName(_fromUtf8("actionAbout")) self.actionControls = QtGui.QAction(MainWindow) self.actionControls.setObjectName(_fromUtf8("actionControls")) .5 self.actionImport_Sample = QtGui.QAction(MainWindow) self.actionImport_Sample.setObjectName(_fromUtf8("actionImport_Sample")) self.actionCreate_New_Sample = QtGui.QAction(MainWindow) self.actionCreate_New_Sample.setObjectName(_fromUtf8("actionCreate_New_Sample")) self.menuFile.addAction(self.actionOpen) self.menuFile.addAction(self.actionSave) self.menuFile.addSeparator() self.menuFile.addAction(self.actionImport_Sample) self.menuFile.addAction(self.actionCreate_New_Sample) self.menuTools.addAction(self.actionAbout) self.menuTools.addAction(self.actionControls) self.menuBar.addAction(self.menuFile.menuAction()) self.menuBar.addAction(self.menuTools.menuAction()) self.resultsDialog=Ui_results() self.submit_button.clicked.connect(self.openResults) self.right_button.clicked.connect(self.RTrans) self.pushButton_2.clicked.connect(self.LTrans) self.up_button.clicked.connect(self.UTrans) self.down_button.clicked.connect(self.DTrans) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.findButton.setText(_translate("MainWindow", "Add", None)) self.label.setText(_translate("MainWindow", "Magnification", None)) self.label_4.setText(_translate("MainWindow", "200X", None)) self.label_5.setText(_translate("MainWindow", "100X", None)) self.label_6.setText(_translate("MainWindow", "400X", None)) self.label_7.setText(_translate("MainWindow", "600X", None)) self.submit_button.setText(_translate("MainWindow", "Submit", None)) self.up_button.setText(_translate("MainWindow", "UP", None)) self.pushButton_2.setText(_translate("MainWindow", "Left", None)) self.right_button.setText(_translate("MainWindow", "Right", None)) self.down_button.setText(_translate("MainWindow", "Down", None)) self.label_2.setText(_translate("MainWindow", "Movement", None)) self.menuFile.setTitle(_translate("MainWindow", "File", None)) self.menuTools.setTitle(_translate("MainWindow", "Help", None)) self.actionOpen.setText(_translate("MainWindow", "Open", None)) self.actionSave.setText(_translate("MainWindow", "Save", None)) self.actionAbout.setText(_translate("MainWindow", "About...", None)) self.actionControls.setText(_translate("MainWindow", "Controls", None)) self.actionImport_Sample.setText(_translate("MainWindow", "Import Existing Sample", None)) self.actionCreate_New_Sample.setText(_translate("MainWindow", "Create New Sample", None)) def openResults(self,val): ui=QtGui.QDialog(); self.resultsDialog.setupUi(ui) ui.show() ui.exec_() def RTrans(self): self.glWidget.setXTrans(.5) def LTrans(self): self.glWidget.setXTrans(-.5) def DTrans(self): self.glWidget.setYTrans(.5) def UTrans(self): self.glWidget.setYTrans(-.5)