def __init__(self): QWidget.__init__(self) self.setFixedSize(200, 120) lcd = QLCDNumber(self) lcd.setSegmentStyle(QLCDNumber.Flat) lcd.move(60, 20) slider = QSlider(Qt.Horizontal, self) slider.setGeometry(10, 70, 150, 20) qApp = QCoreApplication.instance() self.connect(slider, SIGNAL("valueChanged(int)"), lcd, SLOT("display(int)"))
class Ui_Form (QWidget): ''' Ui class. Generated with pyuic4. ''' def __init__ (self, parent=None): QWidget.__init__(self, parent) self.timer = QTimer (self) self.image = QImage (720, 450, QImage.Format_RGB888) self.__engine = REngineThread () self.__model = Model () self.__fsm = DebugStateMachine (self) def wireEngineUp (self): ''' this method connects the REngine's signals. ''' self.connect (self.__engine, SIGNAL ("update (float)"), self.updateImage) self.connect (self.__engine, SIGNAL ("thread_completed()"), self.__fsm.finaliseRender) self.connect (self.__engine, SIGNAL ("inters_created (PyQt_PyObject, PyQt_PyObject)"), self.widget.addIntersection) self.connect (self.__engine, SIGNAL ("vector_created (PyQt_PyObject, PyQt_PyObject, QString)"), self.widget.addArrow) self.connect (self.__engine, SIGNAL ("line_created (PyQt_PyObject, PyQt_PyObject, QString)"), self.widget.addLine) def wireOGLViewerUp (self): ''' this method connects the REngine's signals. ''' self.widget.setModel (self.__model) QObject.connect (self.widget, SIGNAL ("MatrixChanged (PyQt_PyObject)"), self.displayGLMatrix) # call the function run regularly when the focus is on it. (60 FPS if interval = 20) QObject.connect (self.timer, SIGNAL ('timeout()'), self.widget.run) def freezeGLFrameRate (self): self.timer.stop () def speedUpGLFrameRate (self): self.timer.start () self.timer.setInterval (20) def setupUi (self, Form): font = QFont () font.setPointSize (9) font.setBold (False) font.setWeight (50) sizePolicy = QSizePolicy (QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch (0) sizePolicy.setVerticalStretch (0) Form.setObjectName (_fromUtf8("Form")) Form.resize (971, 930) self.plainTextEdit = QPlainTextEdit (Form) self.plainTextEdit.setGeometry (QRect (740, 280, 221, 611)) self.plainTextEdit.setObjectName (_fromUtf8 ("plainTextEdit")) self.plainTextEdit.setFont (font) self.widget = OGLViewer (Form) self.widget.setUi_Form (self) self.widget.setGeometry (QRect (10, 10, 720, 450)) sizePolicy.setHeightForWidth (self.widget.sizePolicy().hasHeightForWidth()) self.widget.setSizePolicy (sizePolicy) self.widget.setObjectName (_fromUtf8 ("widget")) self.wireOGLViewerUp () self.wireEngineUp () self.label_view = QLabel (Form) self.label_view.setGeometry (QRect (10, 470, 720, 450)) sizePolicy.setHeightForWidth (self.label_view.sizePolicy().hasHeightForWidth()) self.label_view.setSizePolicy (sizePolicy) self.label_view.setObjectName (_fromUtf8 ("label_view")) self.initLabel () self.pixmap_item = self.label_view.setPixmap (QPixmap.fromImage (self.image)) # buttons definitions self.renderBtn = QPushButton (Form) self.pauseBtn = QPushButton (Form) self.stopBtn = QPushButton (Form) self.upBtn = QPushButton (Form) self.downBtn = QPushButton (Form) self.moreDownBtn = QPushButton (Form) self.moreUpBtn = QPushButton (Form) self.rightBtn = QPushButton (Form) self.moreRightBtn = QPushButton (Form) self.leftBtn = QPushButton (Form) self.furtherLeft = QPushButton (Form) self.grid_switch = QPushButton (Form) buttons_properties_list = [[self.renderBtn, True, QRect (740, 140, 61, 21), "render"], [self.pauseBtn, False, QRect (740, 120, 61, 21), "pause"], [self.stopBtn, False, QRect (740, 100, 61, 21), "stop"], [self.upBtn, False, QRect (820, 120, 21, 21), "one_row_up"], [self.downBtn, False, QRect (820, 140, 21, 21), "one_row_down"], [self.moreDownBtn, False, QRect (820, 160, 21, 21), "ten_rows_down"], [self.moreUpBtn, False, QRect (820, 100, 21, 21), "ten_rows_up"], [self.rightBtn, False, QRect (780, 180, 21, 21), "one_column_right"], [self.moreRightBtn, False, QRect (800, 180, 21, 21), "ten_columns_right"], [self.leftBtn, False, QRect (760, 180, 21, 21), "one_column_left"], [self.furtherLeft, False, QRect (740, 180, 21, 21), "ten_columns_left"], [self.grid_switch, False, QRect (870, 230, 91, 31), "grid_switch"]] for button in buttons_properties_list: button[0].setEnabled (button[1]) button[0].setGeometry (button[2]) button[0].setFont (font) button[0].setObjectName (_fromUtf8 (button[3])) # other UI elements self.progressBar = QProgressBar (Form) self.progressBar.setGeometry (QRect (740, 901, 221, 20)) self.progressBar.setProperty ("value", 0) self.progressBar.setObjectName (_fromUtf8("progressBar")) self.progressBar.setMinimum (0) self.progressBar.setMaximum (100) self.slider_label = QLabel (Form) self.slider_label.setGeometry (QRect(900, 260, 61, 16)) self.slider_label.setFont(font) self.slider_label.setObjectName (_fromUtf8("slider_label")) self.slider_label.setEnabled (True) self.arrowSizeSlider = QSlider (Form) self.arrowSizeSlider.setGeometry (QRect (740, 258, 151, 22)) self.arrowSizeSlider.setMinimum (2) self.arrowSizeSlider.setMaximum (40) self.arrowSizeSlider.setSingleStep (1) self.arrowSizeSlider.setProperty ("value", 4) self.arrowSizeSlider.setOrientation (Qt.Horizontal) self.arrowSizeSlider.setObjectName (_fromUtf8("arrowSizeSlider")) self.retranslateUi (Form) QMetaObject.connectSlotsByName (Form) def retranslateUi (self, Form): Form.setWindowTitle (_translate ("Form", "RayTracing Debugging Tool", None)) self.renderBtn.setText (_translate ("Form", "Render", None)) self.pauseBtn.setText (_translate ("Form", "Pause", None)) self.stopBtn.setText (_translate ("Form", "Stop", None)) self.upBtn.setText (_translate ("Form", "^", None)) self.downBtn.setText (_translate ("Form", "v", None)) self.moreDownBtn.setText (_translate ("Form", "+", None)) self.moreUpBtn.setText (_translate ("Form", "-", None)) self.rightBtn.setText (_translate ("Form", ">", None)) self.moreRightBtn.setText (_translate ("Form", "+", None)) self.leftBtn.setText (_translate ("Form", "<", None)) self.furtherLeft.setText (_translate ("Form", "-", None)) self.grid_switch.setText (_translate ("Form", "Grid on/off", None)) self.slider_label.setText (_translate ("Form", "Arrows size", None)) self.connect (self.renderBtn, SIGNAL ("clicked()"), self.__fsm.startRendering) self.connect (self.pauseBtn, SIGNAL ("clicked()"), self.__fsm.pauseRendering) self.connect (self.stopBtn, SIGNAL ("clicked()"), self.__fsm.stopRendering) self.connect (self.arrowSizeSlider, SIGNAL ("sliderMoved(int)"), self.resizeArrows) def initLabel (self): color = QColor (250, 250, 250) self.image.fill (color) ''' # test init for i in range (0, 200, 20): for x in range (i, i+20): for y in range (i, i+20): self.image.setPixel (x,y, qRgb (0, 0, 0)) ''' def enableUIButtons (self, boolean_dict): ''' method used by the debug state machine to manage the greyed-out state of buttons. ''' b_dict = dict (boolean_dict) self.renderBtn.setEnabled (b_dict['renderBtn']) self.pauseBtn.setEnabled (b_dict['pauseBtn']) self.stopBtn.setEnabled (b_dict['stopBtn']) self.upBtn.setEnabled (b_dict['upBtn']) self.downBtn.setEnabled (b_dict['downBtn']) self.moreDownBtn.setEnabled (b_dict['moreDownBtn']) self.moreUpBtn.setEnabled (b_dict['moreUpBtn']) self.rightBtn.setEnabled (b_dict['rightBtn']) self.moreRightBtn.setEnabled (b_dict['moreRightBtn']) self.leftBtn.setEnabled (b_dict['leftBtn']) self.furtherLeft.setEnabled (b_dict['furtherLeft']) if b_dict['progressBar'] == 'completed': self.progressBar.setValue (100) elif b_dict['progressBar'] == 'reset': self.progressBar.reset () def addScreenshot (self): ''' it grabs a screenshot of OpenGL viewer and add it into the QImage instance. ''' self.image = self.widget.grabFrameBuffer () self.pixmap_item = self.label_view.setPixmap (QPixmap.fromImage (self.image)) def prepAndStartEngineUp (self): ''' it preps the engine and start it up. ''' self.__engine.setImage (self.image) self.__engine.setCameraNormalMatrix (self.widget.getNormalMatrix(), self.widget.getFovy ()) self.__engine.setModel (self.__model) self.__engine.start () def addCamera (self): self.widget.addCamera () def setIsStoppedFlag (self, boo): self.__engine.setIsStoppedFlag (boo) def setIsPausedFlag (self, boo): self.__engine.setIsPausedFlag (boo) def changeRenderBtnName (self, title): self.renderBtn.setText (_translate ("Form", title, None)) # listeners - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - def resizeArrows (self, e): self.widget.changeArrowsSize (e*0.5) def updateImage (self, e): self.pixmap_item = self.label_view.setPixmap (QPixmap.fromImage (self.image)) self.progressBar.setValue (int(100*e)) def displayGLMatrix (self, e): ''' this method is registered to the MatrixChanged event fired from the OGLViewer component. It prints the model matrix. Only for debugging purposes. ''' pass
class MyMainWindow(QMainWindow): ' Main Window ' def __init__(self, parent=None): super(MyMainWindow, self).__init__(parent) self.statusBar().showMessage(__doc__) self.setWindowTitle(__doc__) self.setMinimumSize(250, 280) self.setMaximumSize(300, 300) self.resize(250, 290) self.setWindowIcon(QIcon.fromTheme("face-monkey")) self.setStyleSheet('''QWidget { color: rgba( 0, 255, 255, 255 ); background-color: #323232; font-family: 'Ubuntu Light'; font-size: 14px; } QToolTip { border: 1px solid black; background-color: #ffa02f; background-image: None; padding: 1px; border-radius: 3px; opacity: 100; } QWidget:item:hover { background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #ca0619 ); color: #000000; } QWidget:item:selected { background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a ); } QWidget:disabled { color: #404040; background-color: #323232; } QWidget:focus { background-image: None; border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a ); } QPushButton { background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646 ); border-width: 1px; border-color: #1e1e1e; border-style: solid; border-radius: 6; padding: 3px; font-size: 12px; padding-left: 5px; padding-right: 5px; background-image: None; } QPushButton:pressed { background-image: None; background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525 ); } QComboBox { background-image: None; selection-background-color: #ffaa00; background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646 ); border-style: solid; border: 1px solid #1e1e1e; border-radius: 5; } QComboBox:hover, QPushButton:hover { background-image: url(.bg.png); border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a ); } QComboBox:on { padding-top: 3px; padding-left: 4px; background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525 ); selection-background-color: #ffaa00; background-image: None; } QComboBox QAbstractItemView { background-image: None; border: 2px solid darkgray; selection-background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a ); } QComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top right; width: 15px; border-left-width: 0px; border-left-color: darkgray; border-left-style: solid; border-top-right-radius: 3px; border-bottom-right-radius: 3px; background-image: None; } QComboBox::down-arrow { background-image: None; } QSlider { border-width: 2px; border-color: #1e1e1e; border-style: solid; padding: 3px; font-size: 8px; padding-left: 5px; padding-right: 5px; width: 25px; border-radius: 5px; } QSlider::sub-page:vertical { background: red; border: none; width: 25px; } QSlider::add-page:vertical { background: green; border: none; width: 25px; } QSlider::handle:vertical { background-color: QLinearGradient(spread:pad, x1:0, y1:0, x2:1, y2:0.273, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(150, 255, 255, 255) ); width: 10px; height: 25px; border: 1px solid grey; text-align: center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius 2px; margin-left: 2px; margin-right: 2px; } QSlider::handle:vertical:hover { border: 2px solid #ffaa00; margin-left: 2px; margin-right: 2px; } QSlider::sub-page:vertical:disabled { background: #bbb; border-color: #999; } QSlider::add-page:vertical:disabled { background: #eee; border-color: #999; } QSlider::handle:vertical:disabled { background: #eee; border: 1px solid #aaa; border-radius: 4px; } ''') self.label1 = QLabel(self) self.label1.setText('Use Debug') self.label1.setGeometry(QtCore.QRect(25, 25, 125, 25)) self.slider1 = QSlider(self) self.slider1.setGeometry(QtCore.QRect(150, 25, 25, 25)) self.slider1.setTickInterval(1) self.slider1.setCursor(QCursor(QtCore.Qt.OpenHandCursor)) self.slider1.TickPosition(QSlider.TicksBothSides) self.slider1.setRange(0, 1) self.slider1.setValue(1) self.sli1lbl = QLabel(str(self.slider1.value()), self.slider1) self.sli1lbl.move(9, 5) self.sli1lbl.setAutoFillBackground(False) self.slider1.valueChanged.connect( lambda: self.sli1lbl.setText(str(self.slider1.value()))) self.slider1.sliderPressed.connect( lambda: self.slider1.setCursor(QCursor(QtCore.Qt.ClosedHandCursor))) self.slider1.sliderReleased.connect( lambda: self.slider1.setCursor(QCursor(QtCore.Qt.OpenHandCursor))) self.label2 = QLabel(self) self.label2.setText('Make Executable') self.label2.setGeometry(QtCore.QRect(25, 75, 125, 25)) self.slider2 = QSlider(self) self.slider2.setGeometry(QtCore.QRect(150, 75, 25, 25)) self.slider2.setTickInterval(1) self.slider2.setCursor(QCursor(QtCore.Qt.OpenHandCursor)) self.slider2.TickPosition(QSlider.TicksBothSides) self.slider2.setRange(0, 1) self.slider2.setValue(1) self.sli2lbl = QLabel(str(self.slider2.value()), self.slider2) self.sli2lbl.move(9, 5) self.sli2lbl.setAutoFillBackground(False) self.slider2.valueChanged.connect( lambda: self.sli2lbl.setText(str(self.slider2.value()))) self.slider2.sliderPressed.connect( lambda: self.slider2.setCursor(QCursor(QtCore.Qt.ClosedHandCursor))) self.slider2.sliderReleased.connect( lambda: self.slider2.setCursor(QCursor(QtCore.Qt.OpenHandCursor))) self.label3 = QLabel(self) self.label3.setText('Relative Imports') self.label3.setGeometry(QtCore.QRect(25, 125, 125, 25)) self.slider3 = QSlider(self) self.slider3.setGeometry(QtCore.QRect(150, 125, 25, 25)) self.slider3.setTickInterval(1) self.slider3.setCursor(QCursor(QtCore.Qt.OpenHandCursor)) self.slider3.TickPosition(QSlider.TicksBothSides) self.slider3.setRange(0, 1) self.slider3.setValue(0) self.sli3lbl = QLabel(str(self.slider3.value()), self.slider3) self.sli3lbl.move(9, 5) self.sli3lbl.setAutoFillBackground(False) self.slider3.valueChanged.connect( lambda: self.sli3lbl.setText(str(self.slider3.value()))) self.slider3.sliderPressed.connect( lambda: self.slider3.setCursor(QCursor(QtCore.Qt.ClosedHandCursor))) self.slider3.sliderReleased.connect( lambda: self.slider3.setCursor(QCursor(QtCore.Qt.OpenHandCursor))) self.label4 = QLabel(self) self.label4.setText('Indent Spaces') self.label4.setGeometry(QtCore.QRect(25, 175, 125, 25)) self.combo1 = QComboBox(self) self.combo1.setCursor(QCursor(QtCore.Qt.PointingHandCursor)) self.combo1.addItems(['4', '0', '2', '6', '8']) self.combo1.setGeometry(QtCore.QRect(150, 175, 50, 25)) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setGeometry(QtCore.QRect(25, 225, 200, 32)) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Close | QDialogButtonBox.Help) self.buttonBox.setCenterButtons(False) self.buttonBox.helpRequested.connect(lambda: QMessageBox.about( self, __doc__, str(__doc__ + ', ' + ',\nversion ' + __version__ + '(' + __license__ + '),\nby ' + __author__ + ', ' + __email__))) self.buttonBox.accepted.connect(self.run) self.buttonBox.rejected.connect(self.close) palette = self.palette() palette.setBrush(QPalette.Base, Qt.transparent) self.setPalette(palette) self.setAttribute(Qt.WA_OpaquePaintEvent, False) def run(self): 'Run the actual conversion.' # Ask the User for the source .ui file as input filein = str(QFileDialog.getOpenFileName( self, __doc__, path.expanduser("~"), 'UI(*.ui)')).strip() # Parse Value of Slider1 as the Debug flag parameter if self.slider1.value() == 0: arg1 = '' else: arg1 = '--debug ' # Parse Value of Slider2 as the Execute flag parameter if self.slider2.value() == 0: arg2 = '' else: arg2 = '--execute ' # Parse Value of Slider3 as the relative imports flag parameter if self.slider3.value() == 0: arg3 = '' else: arg3 = '--from-imports ' # debug #print(arg1, arg2, arg3, str(self.combo1.currentText())) # run the subprocesses subprocess.Popen( 'nice --adjustment=19 pyuic4 ' + arg1 + arg2 + arg3 + '--indent=' + str(self.combo1.currentText()) + ' --output=' + str(filein).lower().replace('.ui', '.py') + ' ' + filein + ' && chmod -v +x ' + str(filein).lower().replace('.ui', '.py'), shell=True) def paintEvent(self, event): ' Paint semi-transparent background ' painter = QPainter(self) painter.fillRect(event.rect(), Qt.transparent) painter.setPen(Qt.NoPen) painter.setBrush(QColor(0, 0, 0)) painter.setOpacity(0.75) painter.drawRoundedRect(self.rect(), 75, 50) painter.end()
class GuiMain(object): def __init__(self, data): self.data = data self.loadSave = False def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") #Set size of window and make it non-resizeable MainWindow.resize(818, 665) MainWindow.setFixedHeight(665) MainWindow.setFixedWidth(818) MainWindow.setWindowTitle("Map Master: Search for the Lost City") MainWindow.setWindowIcon(QIcon("icon_medium.ico")) #Set window backgrounds self.background = QLabel(MainWindow) self.backgroundPixmapMenu = QPixmap(normpath("images/gameMenu2.png")) self.backgroundPixmapSettings = QPixmap(normpath("images/gameMenuSettings2.png")) self.background.setPixmap(self.backgroundPixmapMenu) self.background.setGeometry(QtCore.QRect(0, 0, 818, 665)) #Stylesheet settings for labels and buttons self.fg = "QLabel {color:black}" self.fgb = "QPushButton {color:black}" self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.stackedWidget = QStackedWidget(self.centralwidget) self.stackedWidget.setEnabled(True) self.stackedWidget.setObjectName("stackedWidget") #Main Menu page self.menuPage = QWidget() self.menuPage.setObjectName("menuPage") self.startButton = QPushButton(self.menuPage) self.startButton.setStyleSheet(self.fgb) self.startButton.setGeometry(QtCore.QRect(600, 200, 180, 60)) self.startButton.setText(QApplication.translate("MainWindow", "Start Game", None, QApplication.UnicodeUTF8)) self.startButton.setObjectName("startButton") self.loadButton = QPushButton(self.menuPage) self.loadButton.setStyleSheet(self.fgb) self.loadButton.setGeometry(QtCore.QRect(600, 280, 180, 60)) self.loadButton.setText(QApplication.translate("MainWindow", "Load Game", None, QApplication.UnicodeUTF8)) self.loadButton.setObjectName("loadButton") self.settingsButton = QPushButton(self.menuPage) self.settingsButton.setStyleSheet(self.fgb) self.settingsButton.setGeometry(QtCore.QRect(600, 440, 180, 60)) self.settingsButton.setText(QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.settingsButton.setObjectName("settingsButton") self.quitButton = QPushButton(self.menuPage) self.quitButton.setStyleSheet(self.fgb) self.quitButton.setGeometry(QtCore.QRect(600, 520, 180, 60)) self.quitButton.setText(QApplication.translate("MainWindow", "Quit", None, QApplication.UnicodeUTF8)) self.quitButton.setObjectName("quitButton") self.instrButton = QPushButton(self.menuPage) self.instrButton.setStyleSheet(self.fgb) self.instrButton.setGeometry(QtCore.QRect(600, 360, 180, 60)) self.instrButton.setText(QApplication.translate("MainWindow", "Instructions", None, QApplication.UnicodeUTF8)) self.instrButton.setObjectName("instrButton") self.stackedWidget.addWidget(self.menuPage) #Settings page self.settingsPage = QWidget() self.settingsPage.setObjectName("settingsPage") self.volumeSlider = QSlider(self.settingsPage) self.volumeSlider.setGeometry(QtCore.QRect(200, 200, 400, 30)) self.volumeSlider.setProperty("value", 50) self.volumeSlider.setOrientation(QtCore.Qt.Horizontal) self.volumeSlider.setObjectName("volumeSlider") self.soundLabel = QLabel(self.settingsPage) self.soundLabel.setGeometry(QtCore.QRect(340, 160, 120, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.soundLabel.setFont(font) self.soundLabel.setStyleSheet(self.fg) self.soundLabel.setText(QApplication.translate("MainWindow", "Volume", None, QApplication.UnicodeUTF8)) self.soundLabel.setAlignment(QtCore.Qt.AlignCenter) self.soundLabel.setObjectName("soundLabel") #Quiet Sound Graphic self.quietGraphic = QLabel(self.settingsPage) self.quietGraphic.setPixmap(QPixmap(normpath("images/speakerQuiet.png"))) self.quietGraphic.setGeometry(QtCore.QRect(90, 180, 80, 80)) self.quietGraphic.setObjectName("quietGraphic") #Loud Sound Graphic self.loudGraphic = QLabel(self.settingsPage) self.loudGraphic.setPixmap(QPixmap(normpath("images/speakerLoud.png"))) self.loudGraphic.setEnabled(True) self.loudGraphic.setGeometry(QtCore.QRect(630, 180, 80, 80)) self.loudGraphic.setObjectName("loudGraphic") self.settingsLabel = QLabel(self.settingsPage) self.settingsLabel.setGeometry(QtCore.QRect(260, 30, 280, 60)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(36) self.settingsLabel.setFont(font) self.settingsLabel.setStyleSheet(self.fg) self.settingsLabel.setText(QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.settingsLabel.setAlignment(QtCore.Qt.AlignCenter) self.settingsLabel.setObjectName("settingsLabel") self.doneButton = QPushButton(self.settingsPage) self.doneButton.setStyleSheet(self.fgb) self.doneButton.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.doneButton.setText(QApplication.translate("MainWindow", "Done", None, QApplication.UnicodeUTF8)) self.doneButton.setObjectName("doneButton") self.stackedWidget.addWidget(self.settingsPage) self.soundManager = Sounds(self.volumeSlider.sliderPosition()) #Main Game page self.mainPage = QWidget() self.mainPage.setObjectName("mainPage") #Person View self.personView = ViewGraphics(self.mainPage) self.personView.setGeometry(QtCore.QRect(0, 0, 390, 500)) self.personView.setObjectName("personView") #Map View self.mapView = ViewGraphics(self.mainPage) self.mapView.setGeometry(QtCore.QRect(410, 0, 390, 500)) self.mapView.setObjectName("mapView") #ClueView self.clueView = QLabel(self.mainPage) self.clueView.setGeometry(QtCore.QRect(0, 510, 390, 91)) self.clueView.setObjectName("clueView") font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.clueView.setFont(font) self.clueView.setStyleSheet(self.fg) #Map Toggles self.latLongCheck = QCheckBox(self.mainPage) self.latLongCheck.setGeometry(QtCore.QRect(420, 510, 97, 41)) self.latLongCheck.setText(QApplication.translate("MainWindow", "Latitude/ \n" "Longitude", None, QApplication.UnicodeUTF8)) self.latLongCheck.setObjectName("latLongCheck") self.colorCheck = QCheckBox(self.mainPage) self.colorCheck.setGeometry(QtCore.QRect(560, 510, 97, 41)) self.colorCheck.setText(QApplication.translate("MainWindow", "Color\n" "Coding", None, QApplication.UnicodeUTF8)) self.colorCheck.setObjectName("colorCheck") self.legendCheck = QCheckBox(self.mainPage) self.legendCheck.setGeometry(QtCore.QRect(680, 520, 97, 22)) self.legendCheck.setText(QApplication.translate("MainWindow", "Legend", None, QApplication.UnicodeUTF8)) self.legendCheck.setObjectName("legendCheck") self.searchButton = QPushButton(self.mainPage) self.searchButton.setStyleSheet(self.fgb) self.searchButton.setGeometry(QtCore.QRect(420, 560, 211, 41)) self.searchButton.setText(QApplication.translate("MainWindow", "Search", None, QApplication.UnicodeUTF8)) self.searchButton.setObjectName("searchButton") #Score pieces self.scoreBox = QLabel(self.mainPage) self.scoreBox.setStyleSheet(self.fg) self.scoreBox.setGeometry(QtCore.QRect(720, 560, 71, 41)) self.scoreBox.setObjectName("scoreBox") self.scoreBox.setText(QApplication.translate("MainWindow", "0", None, QApplication.UnicodeUTF8)) self.scoreLabel = QLabel(self.mainPage) self.scoreLabel.setStyleSheet(self.fg) self.scoreLabel.setGeometry(QtCore.QRect(660, 570, 51, 17)) self.scoreLabel.setText(QApplication.translate("MainWindow", "Score:", None, QApplication.UnicodeUTF8)) self.scoreLabel.setAlignment(QtCore.Qt.AlignCenter) self.scoreLabel.setObjectName("scoreLabel") self.stackedWidget.addWidget(self.mainPage) #Help page self.helpPage = QWidget() self.helpPage.setObjectName("helpPage") self.HelpLabel = QLabel(self.helpPage) self.HelpLabel.setStyleSheet(self.fg) self.HelpLabel.setGeometry(QtCore.QRect(260, 30, 280, 60)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(36) self.HelpLabel.setFont(font) self.HelpLabel.setText(QApplication.translate("MainWindow", "Instructions", None, QApplication.UnicodeUTF8)) self.HelpLabel.setAlignment(QtCore.Qt.AlignCenter) self.HelpLabel.setObjectName("HelpLabel") self.wInstr = QLabel(self.helpPage) self.wInstr.setStyleSheet(self.fg) self.wInstr.setGeometry(QtCore.QRect(200, 150, 40, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.wInstr.setFont(font) self.wInstr.setText(QApplication.translate("MainWindow", "W", None, QApplication.UnicodeUTF8)) self.wInstr.setAlignment(QtCore.Qt.AlignCenter) self.wInstr.setObjectName("wInstr") self.sInstr = QLabel(self.helpPage) self.sInstr.setStyleSheet(self.fg) self.sInstr.setGeometry(QtCore.QRect(200, 200, 40, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.sInstr.setFont(font) self.sInstr.setText(QApplication.translate("MainWindow", "S", None, QApplication.UnicodeUTF8)) self.sInstr.setAlignment(QtCore.Qt.AlignCenter) self.sInstr.setObjectName("sInstr") self.aInstr = QLabel(self.helpPage) self.aInstr.setStyleSheet(self.fg) self.aInstr.setGeometry(QtCore.QRect(200, 250, 40, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.aInstr.setFont(font) self.aInstr.setText(QApplication.translate("MainWindow", "A", None, QApplication.UnicodeUTF8)) self.aInstr.setAlignment(QtCore.Qt.AlignCenter) self.aInstr.setObjectName("aInstr") self.dInstr = QLabel(self.helpPage) self.dInstr.setStyleSheet(self.fg) self.dInstr.setGeometry(QtCore.QRect(200, 300, 40, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.dInstr.setFont(font) self.dInstr.setText(QApplication.translate("MainWindow", "D", None, QApplication.UnicodeUTF8)) self.dInstr.setAlignment(QtCore.Qt.AlignCenter) self.dInstr.setObjectName("dInstr") self.wInstr2 = QLabel(self.helpPage) self.wInstr2.setStyleSheet(self.fg) self.wInstr2.setGeometry(QtCore.QRect(400, 150, 180, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.wInstr2.setFont(font) self.wInstr2.setText(QApplication.translate("MainWindow", "Move North", None, QApplication.UnicodeUTF8)) self.wInstr2.setAlignment(QtCore.Qt.AlignCenter) self.wInstr2.setObjectName("wInstr2") self.sInstr2 = QLabel(self.helpPage) self.sInstr2.setStyleSheet(self.fg) self.sInstr2.setGeometry(QtCore.QRect(400, 200, 180, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.sInstr2.setFont(font) self.sInstr2.setText(QApplication.translate("MainWindow", "Move South", None, QApplication.UnicodeUTF8)) self.sInstr2.setAlignment(QtCore.Qt.AlignCenter) self.sInstr2.setObjectName("sInstr2") self.aInstr2 = QLabel(self.helpPage) self.aInstr2.setStyleSheet(self.fg) self.aInstr2.setGeometry(QtCore.QRect(400, 250, 180, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.aInstr2.setFont(font) self.aInstr2.setText(QApplication.translate("MainWindow", "Move West", None, QApplication.UnicodeUTF8)) self.aInstr2.setAlignment(QtCore.Qt.AlignCenter) self.aInstr2.setObjectName("aInstr2") self.dInstr2 = QLabel(self.helpPage) self.dInstr2.setStyleSheet(self.fg) self.dInstr2.setGeometry(QtCore.QRect(400, 300, 180, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.dInstr2.setFont(font) self.dInstr2.setText(QApplication.translate("MainWindow", "Move East", None, QApplication.UnicodeUTF8)) self.dInstr2.setAlignment(QtCore.Qt.AlignCenter) self.dInstr2.setObjectName("dInstr2") self.searchInstr = QPushButton(self.helpPage) self.searchInstr.setStyleSheet(self.fgb) self.searchInstr.setEnabled(True) self.searchInstr.setGeometry(QtCore.QRect(170, 350, 100, 30)) self.searchInstr.setText(QApplication.translate("MainWindow", "Search", None, QApplication.UnicodeUTF8)) self.searchInstr.setAutoDefault(False) self.searchInstr.setDefault(False) self.searchInstr.setFlat(False) self.searchInstr.setObjectName("searchInstr") self.dInstr2_2 = QLabel(self.helpPage) self.dInstr2_2.setStyleSheet(self.fg) self.dInstr2_2.setGeometry(QtCore.QRect(380, 350, 211, 30)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.dInstr2_2.setFont(font) self.dInstr2_2.setText(QApplication.translate("MainWindow", "Search for clues", None, QApplication.UnicodeUTF8)) self.dInstr2_2.setAlignment(QtCore.Qt.AlignCenter) self.dInstr2_2.setObjectName("dInstr2_2") self.doneButton2 = QPushButton(self.helpPage) self.doneButton2.setStyleSheet(self.fgb) self.doneButton2.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.doneButton2.setText(QApplication.translate("MainWindow", "Done", None, QApplication.UnicodeUTF8)) self.doneButton2.setObjectName("doneButton2") self.stackedWidget.addWidget(self.helpPage) #Credits page self.creditsPage = QWidget() self.creditsPage.setObjectName("creditsPage") self.creditsLabel = QLabel(self.creditsPage) self.creditsLabel.setStyleSheet(self.fg) self.creditsLabel.setGeometry(QtCore.QRect(260, 30, 280, 60)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(36) self.creditsLabel.setFont(font) self.creditsLabel.setText(QApplication.translate("MainWindow", "Credits", None, QApplication.UnicodeUTF8)) self.creditsLabel.setAlignment(QtCore.Qt.AlignCenter) self.creditsLabel.setObjectName("creditsLabel") self.credits = QLabel(self.creditsPage) self.credits.setStyleSheet(self.fg) self.credits.setGeometry(QtCore.QRect(180, 150, 500, 400)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(20) self.credits.setFont(font) self.credits.setText(QApplication.translate("MainWindow", "Gary Lent\n" "Grant Stafford\n" "Jessie Liu\n" "Peter Andrien\n" "Nokia (Qt4 framework)\n" "Riverbank Computing Ltd (PyQt)\n" "Celestial Aeon Project", None, QApplication.UnicodeUTF8)) self.credits.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.credits.setObjectName("credits") self.doneButton3 = QPushButton(self.creditsPage) self.doneButton3.setStyleSheet(self.fgb) self.doneButton3.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.doneButton3.setText(QApplication.translate("MainWindow", "Done", None, QApplication.UnicodeUTF8)) self.doneButton3.setObjectName("doneButton3") self.stackedWidget.addWidget(self.creditsPage) #Story page self.storyPage = QWidget() self.storyPage.setObjectName("storyPage") self.storyLabel = QLabel(self.storyPage) self.storyLabel.setStyleSheet(self.fg) self.storyLabel.setGeometry(QtCore.QRect(100, 50, 600, 400)) font = QFont() font.setFamily("Century Schoolbook L") font.setPointSize(25) self.storyLabel.setFont(font) self.storyLabel.setText(QApplication.translate("MainWindow", "My name is Travis Sinclair.\n I'm a skilled cartographer.\n I recently lost my job, but stumbled\n on a clue that may change my life \nforever. I've set off on a quest - a quest\n to find a lost city. I've found a clue,\n and believe there may be more.\n Help me find the lost city. ", None, QApplication.UnicodeUTF8)) self.storyLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.storyLabel.setObjectName("storyLabel") self.nextButton = QPushButton(self.storyPage) self.nextButton.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.nextButton.setText(QApplication.translate("MainWindow", "Next", None, QApplication.UnicodeUTF8)) self.nextButton.setObjectName("nextButton") self.stackedWidget.addWidget(self.storyPage) self.gridLayout.addWidget(self.stackedWidget, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) #Menu bar self.menubar = QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 818, 25)) self.menubar.setObjectName("menubar") self.menuMenu = QMenu(self.menubar) self.menuMenu.setTitle(QApplication.translate("MainWindow", "Menu", None, QApplication.UnicodeUTF8)) self.menuMenu.setObjectName("menuMenu") MainWindow.setMenuBar(self.menubar) self.actionSave_Game = QAction(MainWindow) self.actionSave_Game.setText(QApplication.translate("MainWindow", "Save Game", None, QApplication.UnicodeUTF8)) self.actionSave_Game.setObjectName("actionSave_Game") self.actionCredits = QAction(MainWindow) self.actionCredits.setText(QApplication.translate("MainWindow", "Credits", None, QApplication.UnicodeUTF8)) self.actionCredits.setObjectName("actionCredits") self.actionQuit = QAction(MainWindow) self.actionQuit.setText(QApplication.translate("MainWindow", "Quit", None, QApplication.UnicodeUTF8)) self.actionQuit.setObjectName("actionQuit") self.actionSettings = QAction(MainWindow) self.actionSettings.setText(QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.actionSettings.setObjectName("actionSettings") self.actionHelp = QAction(MainWindow) self.actionHelp.setText(QApplication.translate("MainWindow", "Help", None, QApplication.UnicodeUTF8)) self.actionHelp.setObjectName("actionHelp") self.actionMain_Menu = QAction(MainWindow) self.actionMain_Menu.setText(QApplication.translate("MainWindow", "Main Menu", None, QApplication.UnicodeUTF8)) self.actionMain_Menu.setObjectName("actionMain_Menu") self.menuMenu.addAction(self.actionSettings) self.menuMenu.addAction(self.actionHelp) self.menuMenu.addAction(self.actionSave_Game) self.menuMenu.addAction(self.actionCredits) self.menuMenu.addAction(self.actionMain_Menu) self.menuMenu.addAction(self.actionQuit) self.menubar.addAction(self.menuMenu.menuAction()) self.retranslateUi(MainWindow) self.stackedWidget.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(MainWindow) #These are the slots and signals to connect buttons to other functions self.location = 0 QtCore.QObject.connect(self.actionQuit, QtCore.SIGNAL("triggered()"), MainWindow.close) QtCore.QObject.connect(self.quitButton, QtCore.SIGNAL("released()"), MainWindow.close) QtCore.QObject.connect(self.settingsButton, QtCore.SIGNAL("released()"), self.setSettings) QtCore.QObject.connect(self.actionSettings, QtCore.SIGNAL("triggered()"), self.setSettings) QtCore.QObject.connect(self.loadButton, QtCore.SIGNAL("released()"), self.load_file_dialog) QtCore.QObject.connect(self.actionSave_Game, QtCore.SIGNAL("triggered()"),self.save_file_dialog) QtCore.QObject.connect(self.doneButton, QtCore.SIGNAL("released()"), self.goBack) QtCore.QObject.connect(self.startButton, QtCore.SIGNAL("released()"), self.newGame) QtCore.QObject.connect(self.actionMain_Menu, QtCore.SIGNAL("triggered()"), self.setMain) QtCore.QObject.connect(self.actionHelp, QtCore.SIGNAL("triggered()"), self.setInstructions) QtCore.QObject.connect(self.instrButton, QtCore.SIGNAL("released()"), self.setInstructions) QtCore.QObject.connect(self.doneButton2, QtCore.SIGNAL("released()"), self.goBack) QtCore.QObject.connect(self.doneButton3, QtCore.SIGNAL("released()"), self.goBack) QtCore.QObject.connect(self.actionCredits, QtCore.SIGNAL("triggered()"), self.setCredits) self.latLongCheck.stateChanged.connect(self.latLong) self.colorCheck.stateChanged.connect(self.colorize) self.legendCheck.stateChanged.connect(self.legend) QtCore.QObject.connect(self.searchButton, QtCore.SIGNAL("released()"), self.doSearch) QtCore.QObject.connect(self.nextButton, QtCore.SIGNAL("released()"), self.storyButton) self.volumeSlider.sliderMoved.connect(self.setVol) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): pass #Custom signals are here def setSettings(self): self.background.setPixmap(self.backgroundPixmapSettings) self.stackedWidget.setCurrentIndex(1) def setInstructions(self): self.background.setPixmap(self.backgroundPixmapSettings) self.stackedWidget.setCurrentIndex(3) def setCredits(self): self.background.setPixmap(self.backgroundPixmapSettings) self.stackedWidget.setCurrentIndex(4) def goBack(self): self.stackedWidget.setCurrentIndex(self.location) if self.location == 0: self.background.setPixmap(self.backgroundPixmapMenu) else: None #Should be something here later. def load_file_dialog(self): fd = QFileDialog() self.filename = fd.getOpenFileName(None, "Load Saved Game", "saves", "MapMaster Save files (*.save)") if isfile(self.filename): self.loadSaved = True self.stackedWidget.setCurrentIndex(2) self.location = 2 self.soundManager.switchSongs(self.location) def save_file_dialog(self): filename = QtGui.QFileDialog.getSaveFileName(None,"Save Game", "saves", "MapMaster Save files (*.save)") if filename == "": print "No file specified!" else: if ".save" in filename: self.fname = open(filename, "w") else: self.fname = open(filename + ".save",'w') score = str(self.data.score) numClues = str(len(self.data.clueStack)) charX, charY = self.data.character.getCenter() whiteSpace = " " toWriteList = whiteSpace + str(charX) + whiteSpace + str(charY) + whiteSpace + numClues + whiteSpace + score self.fname.write(toWriteList) self.fname.close() def newGame(self): self.background.setPixmap(self.backgroundPixmapSettings) self.filename = None self.stackedWidget.setCurrentIndex(5) self.location = 5 def storyButton(self): self.stackedWidget.setCurrentIndex(2) self.location = 2 self.soundManager.switchSongs(self.location) def setMain(self): self.save_file_dialog() self.background.setPixmap(self.backgroundPixmapMenu) self.stackedWidget.setCurrentIndex(0) self.location = 0 self.soundManager.switchSongs(self.location) def latLong(self): if self.latLongCheck.isChecked(): print "Lat/long overlay on" else: print "Lat/long overlay off" self.data.overlays['latLongOverlay'].mViewObj.setVisible(self.latLongCheck.isChecked()) def colorize(self): if self.colorCheck.isChecked(): print "Color overlay on" else: print "Color overlay off" self.data.overlays['colorOverlay'].mViewObj.setVisible(self.colorCheck.isChecked()) def legend(self): if self.legendCheck.isChecked(): print "Legend overlay on" else: print "Legend overlay off" self.data.overlays['legendOverlay'].mViewObj.setVisible(self.legendCheck.isChecked()) def setVol(self): self.soundManager.setVolume(self.volumeSlider.sliderPosition()) def doSearch(self): searchLandmark(self.data)
class Gui(object): def __init__(self, MainWindow): MainWindow.setObjectName("MainWindow") #Set size of window and make it non-resizeable MainWindow.resize(818, 665) MainWindow.setFixedHeight(665) MainWindow.setFixedWidth(818) MainWindow.setWindowTitle("Map Master: Search for the Lost City") MainWindow.setWindowIcon(QIcon("icon_medium.ico")) #Set window backgrounds self.background = QLabel(MainWindow) self.backgroundPixmapMenu = QPixmap(normpath("images/gameMenu2.png")) self.backgroundPixmapSettings = QPixmap(normpath( "images/gameMenuSettings2.png")) self.background.setPixmap(self.backgroundPixmapMenu) self.background.setGeometry(QtCore.QRect(0, 0, 818, 665)) self.popupPixmap = QPixmap(normpath("images/popupBG.png")) font = QFont() if "linux" in platform: font.setFamily("Century Schoolbook L") else: font.setFamily("Century Schoolbook") #Stylesheet settings for labels and buttons self.fg = "QLabel {color:black}" self.fgb = "QPushButton {color:black}" self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.stackedWidget = QStackedWidget(self.centralwidget) self.stackedWidget.setEnabled(True) self.stackedWidget.setObjectName("stackedWidget") #Main Menu page self.menuPage = QWidget() self.menuPage.setObjectName("menuPage") self.startButton = QPushButton(self.menuPage) self.startButton.setStyleSheet(self.fgb) self.startButton.setGeometry(QtCore.QRect(600, 200, 180, 60)) self.startButton.setText(QApplication.translate("MainWindow", "Start Game", None, QApplication.UnicodeUTF8)) self.startButton.setObjectName("startButton") font.setPointSize(15) self.startButton.setFont(font) self.loadButton = QPushButton(self.menuPage) self.loadButton.setStyleSheet(self.fgb) self.loadButton.setGeometry(QtCore.QRect(600, 280, 180, 60)) self.loadButton.setText(QApplication.translate("MainWindow", "Load Game", None, QApplication.UnicodeUTF8)) self.loadButton.setObjectName("loadButton") self.loadButton.setFont(font) self.settingsButton = QPushButton(self.menuPage) self.settingsButton.setStyleSheet(self.fgb) self.settingsButton.setGeometry(QtCore.QRect(600, 440, 180, 60)) self.settingsButton.setText(QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.settingsButton.setObjectName("settingsButton") self.settingsButton.setFont(font) self.quitButton = QPushButton(self.menuPage) self.quitButton.setStyleSheet(self.fgb) self.quitButton.setGeometry(QtCore.QRect(600, 520, 180, 60)) self.quitButton.setText(QApplication.translate("MainWindow", "Quit", None, QApplication.UnicodeUTF8)) self.quitButton.setObjectName("quitButton") self.quitButton.setFont(font) self.instrButton = QPushButton(self.menuPage) self.instrButton.setStyleSheet(self.fgb) self.instrButton.setGeometry(QtCore.QRect(600, 360, 180, 60)) self.instrButton.setText(QApplication.translate("MainWindow", "Instructions", None, QApplication.UnicodeUTF8)) self.instrButton.setObjectName("instrButton") self.instrButton.setFont(font) self.stackedWidget.addWidget(self.menuPage) #Settings page self.settingsPage = QWidget() self.settingsPage.setObjectName("settingsPage") self.volumeSlider = QSlider(self.settingsPage) self.volumeSlider.setGeometry(QtCore.QRect(200, 200, 400, 30)) self.volumeSlider.setProperty("value", 50) self.volumeSlider.setOrientation(QtCore.Qt.Horizontal) self.volumeSlider.setObjectName("volumeSlider") self.soundLabel = QLabel(self.settingsPage) self.soundLabel.setGeometry(QtCore.QRect(340, 160, 120, 30)) font.setPointSize(20) self.soundLabel.setFont(font) self.soundLabel.setStyleSheet(self.fg) self.soundLabel.setText(QApplication.translate("MainWindow", "Volume", None, QApplication.UnicodeUTF8)) self.soundLabel.setAlignment(QtCore.Qt.AlignCenter) self.soundLabel.setObjectName("soundLabel") #Quiet Sound Graphic self.quietGraphic = QLabel(self.settingsPage) self.quietGraphic.setPixmap(QPixmap(normpath( "images/speakerQuiet.png"))) self.quietGraphic.setGeometry(QtCore.QRect(90, 180, 80, 80)) self.quietGraphic.setObjectName("quietGraphic") #Loud Sound Graphic self.loudGraphic = QLabel(self.settingsPage) self.loudGraphic.setPixmap(QPixmap(normpath("images/speakerLoud.png"))) self.loudGraphic.setEnabled(True) self.loudGraphic.setGeometry(QtCore.QRect(630, 180, 80, 80)) self.loudGraphic.setObjectName("loudGraphic") self.settingsLabel = QLabel(self.settingsPage) self.settingsLabel.setGeometry(QtCore.QRect(260, 30, 280, 60)) font.setPointSize(36) self.settingsLabel.setFont(font) self.settingsLabel.setStyleSheet(self.fg) self.settingsLabel.setText(QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.settingsLabel.setAlignment(QtCore.Qt.AlignCenter) self.settingsLabel.setObjectName("settingsLabel") self.doneButton = QPushButton(self.settingsPage) self.doneButton.setStyleSheet(self.fgb) self.doneButton.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.doneButton.setText(QApplication.translate("MainWindow", "Done", None, QApplication.UnicodeUTF8)) self.doneButton.setObjectName("doneButton") font.setPointSize(15) self.doneButton.setFont(font) self.stackedWidget.addWidget(self.settingsPage) self.soundManager = Sounds(self.volumeSlider.sliderPosition()) #Main Game page self.mainPage = QWidget() self.mainPage.setObjectName("mainPage") #Person View self.personView = ViewGraphics(self.mainPage) self.personView.setGeometry(QtCore.QRect(0, 0, 390, 500)) self.personView.setObjectName("personView") #Map View self.mapView = ViewGraphics(self.mainPage) self.mapView.setGeometry(QtCore.QRect(410, 0, 390, 500)) self.mapView.setObjectName("mapView") #ClueView self.clueView = QLabel(self.mainPage) self.clueView.setGeometry(QtCore.QRect(0, 510, 390, 91)) self.clueView.setObjectName("clueView") font.setPointSize(20) self.clueView.setFont(font) self.clueView.setStyleSheet(self.fg) #Map Toggles self.latLongCheck = QCheckBox(self.mainPage) self.latLongCheck.setGeometry(QtCore.QRect(420, 510, 103, 41)) self.latLongCheck.setText(QApplication.translate("MainWindow", "Latitude/ \n" "Longitude", None, QApplication.UnicodeUTF8)) self.latLongCheck.setObjectName("latLongCheck") font.setPointSize(12) self.latLongCheck.setFont(font) self.latLongCheck.setFocusPolicy(QtCore.Qt.NoFocus) self.colorCheck = QCheckBox(self.mainPage) self.colorCheck.setGeometry(QtCore.QRect(560, 510, 97, 41)) self.colorCheck.setText(QApplication.translate("MainWindow", "Color\n" "Coding", None, QApplication.UnicodeUTF8)) self.colorCheck.setObjectName("colorCheck") self.colorCheck.setFont(font) self.colorCheck.setFocusPolicy(QtCore.Qt.NoFocus) self.legendCheck = QCheckBox(self.mainPage) self.legendCheck.setGeometry(QtCore.QRect(680, 520, 97, 22)) self.legendCheck.setText(QApplication.translate("MainWindow", "Legend", None, QApplication.UnicodeUTF8)) self.legendCheck.setObjectName("legendCheck") self.legendCheck.setFocusPolicy(QtCore.Qt.NoFocus) font.setPointSize(12) self.legendCheck.setFont(font) self.searchButton = QPushButton(self.mainPage) self.searchButton.setStyleSheet(self.fgb) self.searchButton.setGeometry(QtCore.QRect(420, 560, 211, 55)) self.searchButton.setText(QApplication.translate("MainWindow", "Search", None, QApplication.UnicodeUTF8)) self.searchButton.setObjectName("searchButton") font.setPointSize(15) self.searchButton.setFont(font) self.searchButton.setFocusPolicy(QtCore.Qt.NoFocus) #Score pieces self.scoreBox = QLabel(self.mainPage) self.scoreBox.setStyleSheet(self.fg) self.scoreBox.setGeometry(QtCore.QRect(720, 570, 71, 41)) self.scoreBox.setObjectName("scoreBox") self.scoreBox.setText(QApplication.translate("MainWindow", "0", None, QApplication.UnicodeUTF8)) self.scoreBox.setFont(font) self.scoreLabel = QLabel(self.mainPage) self.scoreLabel.setStyleSheet(self.fg) self.scoreLabel.setGeometry(QtCore.QRect(650, 580, 70, 17)) self.scoreLabel.setText(QApplication.translate("MainWindow", "Score:", None, QApplication.UnicodeUTF8)) self.scoreLabel.setAlignment(QtCore.Qt.AlignCenter) self.scoreLabel.setObjectName("scoreLabel") self.scoreLabel.setFont(font) self.popup = ViewGraphics(self.mainPage) self.popup.setStyleSheet( "QGraphicsView {background:transparent;border-style:none}") self.popupImage = self.popup.scene.addPixmap(self.popupPixmap) self.popup.setGeometry(QtCore.QRect(25, 25, 750, 450)) self.popup.setObjectName("popupLabel") font.setPointSize(25) self.popupText = self.popup.scene.addText("", font) self.textColor = QColor('black') self.popupText.setDefaultTextColor(self.textColor) self.popupText.setX(350) self.popupText.setY(225) self.popupImage.setOpacity(0) self.popupText.setOpacity(0) self.stackedWidget.addWidget(self.mainPage) #Help page self.helpPage = QWidget() self.helpPage.setObjectName("helpPage") self.HelpLabel = QLabel(self.helpPage) self.HelpLabel.setStyleSheet(self.fg) self.HelpLabel.setGeometry(QtCore.QRect(260, 30, 280, 60)) font.setPointSize(36) self.HelpLabel.setFont(font) self.HelpLabel.setText(QApplication.translate("MainWindow", "Instructions", None, QApplication.UnicodeUTF8)) self.HelpLabel.setAlignment(QtCore.Qt.AlignCenter) self.HelpLabel.setObjectName("HelpLabel") self.wInstr = QLabel(self.helpPage) self.wInstr.setStyleSheet(self.fg) self.wInstr.setGeometry(QtCore.QRect(200, 150, 40, 30)) font.setPointSize(20) self.wInstr.setFont(font) self.wInstr.setText(QApplication.translate("MainWindow", "W", None, QApplication.UnicodeUTF8)) self.wInstr.setAlignment(QtCore.Qt.AlignCenter) self.wInstr.setObjectName("wInstr") self.sInstr = QLabel(self.helpPage) self.sInstr.setStyleSheet(self.fg) self.sInstr.setGeometry(QtCore.QRect(200, 200, 40, 30)) self.sInstr.setFont(font) self.sInstr.setText(QApplication.translate("MainWindow", "S", None, QApplication.UnicodeUTF8)) self.sInstr.setAlignment(QtCore.Qt.AlignCenter) self.sInstr.setObjectName("sInstr") self.aInstr = QLabel(self.helpPage) self.aInstr.setStyleSheet(self.fg) self.aInstr.setGeometry(QtCore.QRect(200, 250, 40, 30)) self.aInstr.setFont(font) self.aInstr.setText(QApplication.translate("MainWindow", "A", None, QApplication.UnicodeUTF8)) self.aInstr.setAlignment(QtCore.Qt.AlignCenter) self.aInstr.setObjectName("aInstr") self.dInstr = QLabel(self.helpPage) self.dInstr.setStyleSheet(self.fg) self.dInstr.setGeometry(QtCore.QRect(200, 300, 40, 30)) self.dInstr.setFont(font) self.dInstr.setText(QApplication.translate("MainWindow", "D", None, QApplication.UnicodeUTF8)) self.dInstr.setAlignment(QtCore.Qt.AlignCenter) self.dInstr.setObjectName("dInstr") self.wInstr2 = QLabel(self.helpPage) self.wInstr2.setStyleSheet(self.fg) self.wInstr2.setGeometry(QtCore.QRect(400, 150, 180, 30)) self.wInstr2.setFont(font) self.wInstr2.setText(QApplication.translate("MainWindow", "Move North", None, QApplication.UnicodeUTF8)) self.wInstr2.setAlignment(QtCore.Qt.AlignCenter) self.wInstr2.setObjectName("wInstr2") self.sInstr2 = QLabel(self.helpPage) self.sInstr2.setStyleSheet(self.fg) self.sInstr2.setGeometry(QtCore.QRect(400, 200, 180, 30)) self.sInstr2.setFont(font) self.sInstr2.setText(QApplication.translate("MainWindow", "Move South", None, QApplication.UnicodeUTF8)) self.sInstr2.setAlignment(QtCore.Qt.AlignCenter) self.sInstr2.setObjectName("sInstr2") self.aInstr2 = QLabel(self.helpPage) self.aInstr2.setStyleSheet(self.fg) self.aInstr2.setGeometry(QtCore.QRect(400, 250, 180, 30)) self.aInstr2.setFont(font) self.aInstr2.setText(QApplication.translate("MainWindow", "Move West", None, QApplication.UnicodeUTF8)) self.aInstr2.setAlignment(QtCore.Qt.AlignCenter) self.aInstr2.setObjectName("aInstr2") self.dInstr2 = QLabel(self.helpPage) self.dInstr2.setStyleSheet(self.fg) self.dInstr2.setGeometry(QtCore.QRect(400, 300, 180, 30)) self.dInstr2.setFont(font) self.dInstr2.setText(QApplication.translate("MainWindow", "Move East", None, QApplication.UnicodeUTF8)) self.dInstr2.setAlignment(QtCore.Qt.AlignCenter) self.dInstr2.setObjectName("dInstr2") self.searchInstr = QPushButton(self.helpPage) self.searchInstr.setStyleSheet(self.fgb) self.searchInstr.setEnabled(True) self.searchInstr.setGeometry(QtCore.QRect(170, 350, 100, 30)) self.searchInstr.setText(QApplication.translate("MainWindow", "Search", None, QApplication.UnicodeUTF8)) self.searchInstr.setAutoDefault(False) self.searchInstr.setDefault(False) self.searchInstr.setFlat(False) self.searchInstr.setObjectName("searchInstr") font.setPointSize(15) self.searchInstr.setFont(font) self.dInstr2_2 = QLabel(self.helpPage) self.dInstr2_2.setStyleSheet(self.fg) self.dInstr2_2.setGeometry(QtCore.QRect(380, 350, 211, 30)) font.setPointSize(20) self.dInstr2_2.setFont(font) self.dInstr2_2.setText(QApplication.translate("MainWindow", "Search for clues", None, QApplication.UnicodeUTF8)) self.dInstr2_2.setAlignment(QtCore.Qt.AlignCenter) self.dInstr2_2.setObjectName("dInstr2_2") self.doneButton2 = QPushButton(self.helpPage) self.doneButton2.setStyleSheet(self.fgb) self.doneButton2.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.doneButton2.setText(QApplication.translate("MainWindow", "Done", None, QApplication.UnicodeUTF8)) self.doneButton2.setObjectName("doneButton2") font.setPointSize(15) self.doneButton2.setFont(font) self.stackedWidget.addWidget(self.helpPage) #Credits page self.creditsPage = QWidget() self.creditsPage.setObjectName("creditsPage") self.creditsLabel = QLabel(self.creditsPage) self.creditsLabel.setStyleSheet(self.fg) self.creditsLabel.setGeometry(QtCore.QRect(260, 30, 280, 60)) font.setPointSize(36) self.creditsLabel.setFont(font) self.creditsLabel.setText(QApplication.translate("MainWindow", "Credits", None, QApplication.UnicodeUTF8)) self.creditsLabel.setAlignment(QtCore.Qt.AlignCenter) self.creditsLabel.setObjectName("creditsLabel") self.credits = QLabel(self.creditsPage) self.credits.setStyleSheet(self.fg) self.credits.setGeometry(QtCore.QRect(180, 150, 500, 400)) font.setPointSize(20) self.credits.setFont(font) self.credits.setText(QApplication.translate("MainWindow", "Gary Lent\n" "Grant Stafford\n" "Jessie Liu\n" "Peter Andrien\n" "Nokia (Qt4 framework)\n" "Riverbank Computing Ltd (PyQt)\n" "Celestial Aeon Project", None, QApplication.UnicodeUTF8)) self.credits.setAlignment( QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.credits.setObjectName("credits") self.doneButton3 = QPushButton(self.creditsPage) self.doneButton3.setStyleSheet(self.fgb) self.doneButton3.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.doneButton3.setText(QApplication.translate("MainWindow", "Done", None, QApplication.UnicodeUTF8)) self.doneButton3.setObjectName("doneButton3") font.setPointSize(15) self.doneButton3.setFont(font) self.stackedWidget.addWidget(self.creditsPage) #Story page self.storyPage = QWidget() self.storyPage.setObjectName("storyPage") self.storyLabel = QLabel(self.storyPage) self.storyLabel.setStyleSheet(self.fg) self.storyLabel.setGeometry(QtCore.QRect(100, 50, 600, 400)) font.setPointSize(25) self.storyLabel.setFont(font) self.storyLabel.setText(QApplication.translate("MainWindow", "My name is Travis Sinclair.\n I'm a skilled cartographer.\n I recently" " lost my job, but stumbled\n on a clue that may change my life" " \nforever. I've set off on a quest - a quest\n to find a lost city. " "I've found a clue,\n and believe there may be more.\n Help me find " "the lost city. ", None, QApplication.UnicodeUTF8)) self.storyLabel.setAlignment( QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.storyLabel.setObjectName("storyLabel") self.nextButton = QPushButton(self.storyPage) self.nextButton.setGeometry(QtCore.QRect(600, 520, 161, 61)) self.nextButton.setText(QApplication.translate("MainWindow", "Next", None, QApplication.UnicodeUTF8)) self.nextButton.setObjectName("nextButton") self.nextButton.setStyleSheet(self.fgb) font.setPointSize(15) self.nextButton.setFont(font) self.stackedWidget.addWidget(self.storyPage) self.gridLayout.addWidget(self.stackedWidget, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) #Menu bar self.menubar = QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 818, 25)) self.menubar.setObjectName("menubar") self.menuMenu = QMenu(self.menubar) self.menuMenu.setTitle(QApplication.translate("MainWindow", "Menu", None, QApplication.UnicodeUTF8)) self.menuMenu.setObjectName("menuMenu") MainWindow.setMenuBar(self.menubar) self.actionSave_Game = QAction(MainWindow) self.actionSave_Game.setText(QApplication.translate("MainWindow", "Save Game", None, QApplication.UnicodeUTF8)) self.actionSave_Game.setObjectName("actionSave_Game") self.actionCredits = QAction(MainWindow) self.actionCredits.setText(QApplication.translate("MainWindow", "Credits", None, QApplication.UnicodeUTF8)) self.actionCredits.setObjectName("actionCredits") self.actionQuit = QAction(MainWindow) self.actionQuit.setText(QApplication.translate("MainWindow", "Quit", None, QApplication.UnicodeUTF8)) self.actionQuit.setObjectName("actionQuit") self.actionSettings = QAction(MainWindow) self.actionSettings.setText(QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8)) self.actionSettings.setObjectName("actionSettings") self.actionHelp = QAction(MainWindow) self.actionHelp.setText(QApplication.translate("MainWindow", "Help", None, QApplication.UnicodeUTF8)) self.actionHelp.setObjectName("actionHelp") self.actionMain_Menu = QAction(MainWindow) self.actionMain_Menu.setText(QApplication.translate("MainWindow", "Main Menu", None, QApplication.UnicodeUTF8)) self.actionMain_Menu.setObjectName("actionMain_Menu") self.menuMenu.addAction(self.actionSettings) self.menuMenu.addAction(self.actionHelp) self.menuMenu.addAction(self.actionSave_Game) self.menuMenu.addAction(self.actionCredits) self.menuMenu.addAction(self.actionMain_Menu) self.menuMenu.addAction(self.actionQuit) self.menubar.addAction(self.menuMenu.menuAction()) self.retranslateUi(MainWindow) self.stackedWidget.setCurrentIndex(0) self.stackIndex = 0 def retranslateUi(self, MainWindow): pass
class GUI(QWidget): def __init__(self, parent=None): global f f = open(filename, "a") f.write("Widget init.\n") f.close() QWidget.__init__(self, parent, Qt.WindowStaysOnTopHint) self.__setup_gui__(self) self._flag = False self._change = False f = open(filename, "a") f.write("End of widget init.\n") f.close() def closeEvent(self, event): reply = QMessageBox.question(self, "Confirm", "Are you sure You want to quit?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: event.accept() else: event.ignore() def __setup_gui__(self, Dialog): global f f = open(filename, "a") f.write("Setup of gui.\n") f.close() Dialog.setObjectName("Dialog") Dialog.resize(270, 145) self.setWindowTitle("Map Layer") screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.Render = QPushButton("Render", Dialog) self.Render.setGeometry(QRect(85, 90, 100, 25)) self.Render.setObjectName("Render") self.comboBox = QComboBox(Dialog) self.comboBox.setGeometry(QRect(100, 34, 115, 18)) self.comboBox.setEditable(False) self.comboBox.setMaxVisibleItems(11) self.comboBox.setInsertPolicy(QComboBox.InsertAtBottom) self.comboBox.setObjectName("comboBox") self.comboBox.addItems([ "Google Roadmap", "Google Terrain", "Google Satellite", "Google Hybrid", "Yahoo Roadmap", "Yahoo Satellite", "Yahoo Hybrid", "Bing Roadmap", "Bing Satellite", "Bing Hybrid", "Open Street Maps" ]) self.comboBox.setCurrentIndex(10) self.label1 = QLabel("Source:", Dialog) self.label1.setGeometry(QRect(55, 35, 35, 16)) self.label1.setObjectName("label1") self.slider = QSlider(Dialog) self.slider.setOrientation(Qt.Horizontal) self.slider.setMinimum(1) self.slider.setMaximum(12) self.slider.setValue(4) self.slider.setGeometry(QRect(110, 61, 114, 16)) self.label2 = QLabel("Quality: " + str(self.slider.value()), Dialog) self.label2.setGeometry(QRect(47, 61, 54, 16)) self.label2.setObjectName("label2") self.doubleSpinBox = QDoubleSpinBox(Dialog) self.doubleSpinBox.setGeometry(QRect(160, 5, 40, 20)) self.doubleSpinBox.setDecimals(0) self.doubleSpinBox.setObjectName("doubleSpinBox") self.doubleSpinBox.setMinimum(10.0) self.doubleSpinBox.setValue(20.0) self.doubleSpinBox.setEnabled(False) self.checkBox = QCheckBox("Auto refresh", Dialog) self.checkBox.setGeometry(QRect(50, 6, 100, 20)) self.checkBox.setLayoutDirection(Qt.RightToLeft) self.checkBox.setObjectName("checkBox") self.progressBar = QProgressBar(Dialog) self.progressBar.setGeometry(QRect(5, 130, 260, 10)) self.progressBar.setProperty("value", 0) self.progressBar.setTextVisible(False) self.progressBar.setObjectName("progressBar") self.progressBar.setVisible(False) QObject.connect(self.Render, SIGNAL("clicked()"), Dialog.__repaint__) QMetaObject.connectSlotsByName(Dialog) QObject.connect(self.slider, SIGNAL("valueChanged(int)"), self.__update_slider_label__) QObject.connect(self.comboBox, SIGNAL("activated(int)"), self.__combobox_changed__) self.timerRepaint = QTimer() QObject.connect(self.checkBox, SIGNAL("clicked()"), self.__activate_timer__) QObject.connect(self.timerRepaint, SIGNAL("timeout()"), self.__on_timer__) f = open(filename, "a") f.write("End of setup of gui.\n") f.close() def __combobox_changed__(self): self._change = True def __activate_timer__(self): self.doubleSpinBox.setEnabled(self.checkBox.isChecked()) if self.checkBox.isChecked(): self.timerRepaint.start(self.doubleSpinBox.value() * 1000) self.Render.setEnabled(False) if _progress == 0: self.__repaint__() else: self.timerRepaint.stop() self.Render.setEnabled(True) def __get_net_size__(self): global f f = open(filename, "a") f.write("Geting net size...\n") f.close() if not os.path.exists(Paths["Screenshot"]): Visum.Graphic.Screenshot(Paths["Screenshot"]) size = Image.open(Paths["Screenshot"]).size f = open(filename, "a") f.write("Read net size:" + str(size) + ".\n") f.close() return size def __on_timer__(self): global _paramGlobal self._flag = False Visum.Graphic.MaximizeNetWindow() param = _paramGlobal _paramGlobal = Visum.Graphic.GetWindow() shift = abs((param[0] - _paramGlobal[0]) / (param[2] - param[0])) zoom = abs((param[2] - param[0]) / (_paramGlobal[2] - _paramGlobal[0]) - 1) print _windowSizeGlobal if _windowSizeGlobal[2:4] != Visum.Graphic.GetMainWindowPos()[2:4]: self.__get_net_size__() self._flag = True elif shift > 0.4 or zoom > 0.2: self._flag = True if self._flag or self._change and _progress == 0: self.__repaint__() self._change = False def __update_slider_label__(self, value): self.label2.setText("Quality: " + str(value)) self._change = True def __update_progress_bar__(self): if _progress != 0: self.progressBar.setVisible(True) self.progressBar.setValue(_progress) else: self.progressBar.setVisible(False) def __rebuild_paths__(self): global Paths Paths["Images"] = [] list = os.listdir(Paths["ScriptFolder"]) imageList = [] for i in range(len(list)): if list[i][-3:] == "png": imageList.append(list[i]) for i in range(len(imageList)): try: Visum.Graphic.Backgrounds.ItemByKey(imageList[i]) Paths["Images"].append(Paths["ScriptFolder"] + "\\" + imageList[i]) except: pass def __repaint__(self): global _progress, f if len(Visum.Graphic.Backgrounds.GetAll) != len(Paths["Images"]): self.__rebuild_paths__() if _progress == 0: f = open(filename, "a") f.write("Doing repaint...\n") f.close() QWebSettings.clearMemoryCaches() timer = QTimer() timer.start(100) QObject.connect(timer, SIGNAL("timeout()"), self.__update_progress_bar__) Main(self.comboBox.currentIndex(), Visum.Graphic.GetWindow(), self.slider.value() / 4.0, self.__get_net_size__()) Visum.Graphic.Draw() self.__update_progress_bar__() _progress = 0 QTimer().singleShot(1500, self.__update_progress_bar__) f = open(filename, "a") f.write("End of doing repaint.\n") f.close()