def __init__(self, parent=None): from radiance import __version__ self.__version = __version__ self.parent = parent pixmap = QPixmap(QString(':/Radiance/splashscreen.png')) flags = Qt.WindowStaysOnTopHint QSplashScreen.__init__(self, pixmap, flags) self.setMask(pixmap.mask()) # Custom progress bar stylesheet progressbar_stylesheet = """ QProgressBar:horizontal { border: 1px solid black; background: white; padding: 1px; } QProgressBar::chunk:horizontal { background-color: qlineargradient(spread: pad, x1: 1, y1: 0.5, x2: 0, y2: 0.5, stop: 0 black, stop: 1 white); } """ # Place progress bar to bottom of splash screen. progressbar = QProgressBar(self) progressbar.setRange(0, 0) progressbar.setGeometry(10, self.height() - 20, self.width() - 20, 10) progressbar.setTextVisible(False) progressbar.setStyleSheet(progressbar_stylesheet) self.progressbar = progressbar self.show()
def __changeDirectory(self, path): for c in self.filesview: c.setParent(None) c.deleteLater() self.filesview = [] self.checkBox_2.setChecked(False) self.progressBars = {} for f in self.__getFiles(path): try: group = QGroupBox(f, self) group.setGeometry(QRect(20, 20, 100, 150)) group.setCheckable(True) group.setChecked(False) group.setFixedSize(100, 150) group.setFlat(True) group.setToolTip(f) label = QLabel(group) label.setScaledContents(True) label.setGeometry(QRect(5, 25, 90, 90)) label.setToolTip(f) progressBar = QProgressBar(group) progressBar.setGeometry(QRect(0, 70, 111, 10)) progressBar.setProperty("value", 0) progressBar.setTextVisible(False) progressBar.setToolTip('0%') progressBar.setVisible(False) self.progressBars[f] = progressBar self.filesview.append(group) from os.path import isfile if isfile(path + '/' + f): ext = f.split('.')[-1] if isfile('icons/' + ext.lower() + '.png'): label.setPixmap( QPixmap('icons/' + ext.lower() + '.png')) else: label.setPixmap(QPixmap('icons/default.png')) else: label.setPixmap(QPixmap('icons/folder.png')) self.connect(group, SIGNAL("clicked()"), self.__deselectFile) except ValueError: pass i = 0 for x in list(range(len(self.filesview))): if (x % 4) == 0: i = i + 1 self.rowsview[i].addWidget(self.filesview[x])
class InputDockWidget(QDockWidget): def __init__(self, *args): QDockWidget.__init__(self, *args) self.setupUi(self) self.setWindowIcon(QIcon(':/icons/qtsixa.png')) self.color = QColor(Qt.lightGray) self.setMinimumWidth(350) self.setContentsMargins(0, 0, 0, 0) self.adjustSize() def setupUi(self, QtSixAMainW): QtSixAMainW.setObjectName(_fromUtf8('QtSixAMainW')) QtSixAMainW.resize(935, 513) triggers = TiggersView(self) triggers.show() bumpers = BumpersView(self) bumpers.show() face = FaceButtonsView(self) face.show() dpad = DpadView(self) dpad.show() select = StartSelectView(self) select.show() sixaxis = SixAxisView(self) sixaxis.show() hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(triggers) hbox.addWidget(bumpers) hbox.addWidget(dpad) hbox.addWidget(face) hbox.addWidget(select) hbox.addWidget(sixaxis) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addLayout(hbox) self.setLayout(vbox) self.progress = QProgressBar(self) self.progress.setGeometry(20, 2, 50, 20) self.progress.setTextVisible(False) self.progress.setOrientation(Qt.Vertical) self.progress.setValue(80) self.progress.move(60,28) self.progress.show() print self.style().objectName() QApplication.setStyle(QStyleFactory.create('Cleanlooks')) def paintEvent(self, event = None): pass
class TiggersView(QGraphicsView): def __init__(self, *args): QGraphicsView.__init__(self, *args) self.move(2, 22) self.btnSize = 60 self.setMaximumHeight(60) self.setMaximumWidth(332) self.setMinimumHeight(60) self.setMinimumWidth(332) self.adjustSize() self.scene = QGraphicsScene(self) self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;') self.progress = QProgressBar(self) self.progress.setGeometry(200, 80, 250, 20) self.setScene(self.scene)
class SplashScreen(QSplashScreen): def __init__(self, pixmap): super(SplashScreen,self).__init__(pixmap) self._title=QLabel(self) self._title.setGeometry(50*self.width()/100, 20*self.height()/100, 50*self.width()/100, 11*self.height()/100 ) self._title.setStyleSheet('QLabel { color : rgb(191,180,110); }') font=QFont('Exo 2') font.setPixelSize(36) font.setBold(True) font.setItalic(True) self._title.setFont(font) font=QFont('Exo 2') font.setPixelSize(16) font.setBold(False) font.setItalic(True) self.setFont(font) self.progressBar = QProgressBar(self) self.progressBar.setGeometry(self.width()/10, 8*self.height()/10, 8*self.width()/10, self.height()/30) def setTitle(self,title): self._title.setText(title) def moveTitle(self, x1, y1, w, h): self._title.setGeometry(x1, y1, w, h) def mousePressEvent(self, event): pass
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 MainWindow(QWidget): """ the main window of the GUI. """ def __init__(self): """ constructor of the main window """ QWidget.__init__(self) self.layout = QGridLayout(self) self.setLayout(self.layout) self.edit = QLineEdit("http://en.wikipedia.org/wiki/Homomorphism", self) self.layout.addWidget(self.edit, 0, 0, 1, 2) self.queue = Queue() self.timer = QTimer(self) QObject.connect(self.timer, SIGNAL("timeout()"), self.tick) self.timer.start(10) self.combo = QComboBox(self) self.combo.addItem("Print") self.combo.addItem("MediaWiki") self.combo.addItem("normal") self.layout.addWidget(self.combo, 1, 1, 1, 1) self.layout.addWidget(QLabel("Template Expansion"), 1, 0, 1, 1) self.papercombo = QComboBox(self) self.papercombo.addItem("A4") self.papercombo.addItem("A5") self.papercombo.addItem("B5") self.papercombo.addItem("letter") self.papercombo.addItem("legal") self.papercombo.addItem("executive") self.layout.addWidget(self.papercombo, 2, 1, 1, 1) self.layout.addWidget(QLabel("Paper"), 2, 0, 1, 1) self.rastercombo = QComboBox(self) self.rastercombo.addItem("Rasterize") self.rastercombo.addItem("Keep vector form") self.layout.addWidget(self.rastercombo, 3, 1, 1, 1) self.layout.addWidget(QLabel("Vector Graphics"), 3, 0, 1, 1) self.inccombo = QComboBox(self) if platform.system() == "Linux": self.inccombo.addItem("Included") self.inccombo.addItem("Excluded") else: self.inccombo.addItem("excluded") self.layout.addWidget(self.inccombo, 4, 1, 1, 1) self.layout.addWidget(QLabel("LaTeX Source"), 4, 0, 1, 1) self.button = QPushButton("Run", self) self.layout.addWidget(self.button, 5, 0, 1, 2) self.counter = 0 QObject.connect(self.button, SIGNAL("clicked()"), self.callbackrun) self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 200, 25) self.pbar.setValue(0) self.layout.addWidget(self.pbar, 6, 0, 1, 2) self.resize(340, -1) self.setWindowTitle("MediaWiki to LaTeX") def callbackrun(self): """ Callback function that is called when the user clicks the run button. """ try: if os.path.exists("main.pdf"): mainfile = open("main.pdf", "ab") mainfile.close() except: QMessageBox.about( self, "File still open", "Please close your PDF viewer before pressing the run button!\n" + " This program need writing permission on the PDF file!") return self.counter = 0 self.button.setEnabled(False) thread = threading.Thread() thread.run = self.callbackthreadrun thread.start() def tick(self): """ callback function for the times. It is called every 10 milliseconds. """ got = False try: item = self.queue.get(False) got = True except: pass if got: self.callbacklog(item) self.timer.start(10) def getSwitch(self, switch): if switch == "MediaWiki": return " -m " if switch == "normal": return " -i " return "" def getVector(self, switch): if switch == "Rasterize": return "" return "-g" def callbackthreadrun(self): """ callback for a thread. When the used clicks the run button. The callbackrun function is called back. This starts a thread that called this functions. So this function runs in multithreaded context. So it cannot interact with the gui because of multithreading hazards """ p = os.system("mediawiki2latex -u " + self.edit.text() + " " + self.getSwitch(self.combo.currentText()) + self.getVector(self.rastercombo.currentText()) + " -o main.pdf") self.queue.put(["Done"]) def callbacklog(self, item): """ called back when the logger of the main program log a message. Used to update the progress bar. And to display the resulting pdf file in a pdf viewer if the main program has finished. This function is called from the main GUI loop. Essentially from the timer. So here are not multithreading problems and you can directly interact with all components of the GUI. """ self.counter += 1 self.pbar.setValue(int(100.0 - 100 * math.exp(-self.counter / 5000.0))) if item[0] == "Done": self.pbar.setValue(100) webbrowser.open('file://%s' % os.path.abspath("main.pdf")) self.button.setEnabled(True) def closeEvent(self, event): """ callback function called when this window is closes. Disable the callback function from the logger of the main program to this window to avoid calling callbacks on this windows in future since it will be destroyed """ pass def callbackthread(self, logmessage): """ callback called from the logger of the main program. This is called back from the tread of the main program. So it can not directly interact with the GUI because of multithreading hazards this way it just puts the message into a synchronized queue which will be polled by the timer and essentially call the callbacklog function in the context of the GUIs main thread """ self.queue.put(logmessage)
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()
class ViewDataTools(QMainWindow): def __init__(self, parent=None): super(ViewDataTools, self).__init__(parent) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # DATATOOLS WINDOWS: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ self.setWindowTitle(ui_strings.DATATOOLS_TITLE) self._width = 680 self._height = 560 self._left_margin = 10 self.resize(self._width, self._height) size_policy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(size_policy) self.setMinimumSize(QtCore.QSize(self._width, self._height)) self.setMaximumSize(QtCore.QSize(self._width, self._height)) self.setWindowIcon(QIcon(resources.ICON_LOGO)) # central widget self.central_widget = QWidget(self) # DataTools description self.lbl_description = QLabel(self.central_widget) self.lbl_description.setGeometry(QtCore.QRect(0, 0, self._width, 30)) self.lbl_description.setAlignment(QtCore.Qt.AlignCenter) self.lbl_description.setText(ui_strings.DATATOOLS_DESCRIPTION) # group input files self.group_input_file = QGroupBox(self.central_widget) self.group_input_file.setGeometry(QtCore.QRect(self._left_margin, 30, 660, 80)) self.group_input_file.setTitle(ui_strings.DATATOOLS_GROUP_INPUT) # frame input files self.frame_inputs = QFrame(self.group_input_file) self.frame_inputs.setGeometry(QtCore.QRect(self._left_margin, 0, 270, 80)) self.frame_inputs.setFrameShape(QFrame.StyledPanel) self.frame_inputs.setFrameShadow(QFrame.Raised) # label input type self.lbl_input_type = QLabel(self.frame_inputs) self.lbl_input_type.setGeometry(QtCore.QRect(20, 20, 60, 15)) self.lbl_input_type.setText(ui_strings.DATATOOLS_INPUT_TYPE) # button xls self.btn_xls = QToolButton(self.frame_inputs) self.btn_xls.setGeometry(QtCore.QRect(20, 35, 35, 35)) icon_xls = QIcon() icon_xls.addPixmap(QPixmap(resources.ICON_XLS), QIcon.Normal, QIcon.Off) self.btn_xls.setIcon(icon_xls) self.btn_xls.setIconSize(QtCore.QSize(24, 24)) self.btn_xls.setCheckable(True) self.btn_xls.setAutoExclusive(True) self.btn_xls.setObjectName("xls_button") # button csv self.btn_csv = QToolButton(self.frame_inputs) self.btn_csv.setGeometry(QtCore.QRect(60, 35, 35, 35)) icon_csv = QIcon() icon_csv.addPixmap(QPixmap(resources.ICON_CSV), QIcon.Normal, QIcon.Off) self.btn_csv.setIcon(icon_csv) self.btn_csv.setIconSize(QtCore.QSize(24, 24)) self.btn_csv.setCheckable(True) self.btn_csv.setAutoExclusive(True) self.btn_csv.setObjectName("csv_button") # checkbox csv with headers self.chk_csv_headers = QCheckBox(ui_strings.DATATOOLS_WITH_HEADERS, self.frame_inputs) self.chk_csv_headers.setGeometry(QtCore.QRect(100, 45, 110, 15)) self.chk_csv_headers.setEnabled(False) # TextEdit + PushButton (FindFolder) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # lbl sheet name self.lbl_file_path = QLabel(self.group_input_file) self.lbl_file_path.setGeometry(QtCore.QRect(250, 20, 120, 15)) self.lbl_file_path.setText(ui_strings.DATATOOLS_SELECT_FILE) self.txt_file = QLineEdit(self.group_input_file) self.txt_file.setGeometry(QtCore.QRect(250, 35, 160, 20)) self.txt_file.setReadOnly(True) self.btn_path = QPushButton(self.group_input_file) self.btn_path.setGeometry(QtCore.QRect(410, 34, 50, 22)) self.btn_path.setText(ui_strings.DATATOOLS_SELECT_BUTTON) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # lbl sheet name self.lbl_sheet_name = QLabel(self.group_input_file) self.lbl_sheet_name.setGeometry(QtCore.QRect(500, 20, 120, 15)) self.lbl_sheet_name.setText(ui_strings.DATATOOLS_SHEET_NAME) # Combobox select sheet - initially does not contain values self.cbo_sheet = QComboBox(self.group_input_file) self.cbo_sheet.setGeometry(QtCore.QRect(500, 35, 130, 20)) # data grid to visualize error messages self.tbl_errors = QTableWidget(self.central_widget) self.tbl_errors.setGeometry(QtCore.QRect(self._left_margin, 420, 660, 100)) # data grid to visualize those records with errors. self.tbl_uploaded_data = QTableWidget(self.central_widget) self.tbl_uploaded_data.setGeometry(QtCore.QRect(self._left_margin, 120, 500, 220)) # group run options self.group_run_options = QGroupBox(self.central_widget) self.group_run_options.setGeometry(QtCore.QRect(520, 120, 150, 220)) self.group_run_options.setTitle(ui_strings.DATATOOLS_GROUP_RUN) # Errors summary: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # group summary errors self.group_errors = QGroupBox(self.central_widget) self.group_errors.setGeometry(QtCore.QRect(self._left_margin, 350, 660, 60)) self.group_errors.setTitle(ui_strings.DATATOOLS_HEADER_ERRORS) # lbl records self.lbl_records = QLabel(self.group_errors) self.lbl_records.setGeometry(QtCore.QRect(165, 15, 80, 15)) self.lbl_records.setAlignment(QtCore.Qt.AlignCenter) self.lbl_records.setText(ui_strings.DATATOOLS_RECORDS) self.txt_records = QLineEdit(self.group_errors) self.txt_records.setGeometry(QtCore.QRect(165, 30, 80, 20)) self.txt_records.setAlignment(QtCore.Qt.AlignCenter) self.txt_records.setReadOnly(True) # lbl errors self.lbl_errors = QLabel(self.group_errors) self.lbl_errors.setGeometry(QtCore.QRect(275, 15, 80, 15)) self.lbl_errors.setAlignment(QtCore.Qt.AlignCenter) self.lbl_errors.setText(ui_strings.DATATOOLS_ERRORS) self.txt_errors = QLineEdit(self.group_errors) self.txt_errors.setGeometry(QtCore.QRect(275, 30, 80, 20)) self.txt_errors.setAlignment(QtCore.Qt.AlignCenter) self.txt_errors.setReadOnly(True) # lbl time self.lbl_time = QLabel(self.group_errors) self.lbl_time.setGeometry(QtCore.QRect(385, 15, 80, 15)) self.lbl_time.setAlignment(QtCore.Qt.AlignCenter) self.lbl_time.setText(ui_strings.DATATOOLS_TIME) self.txt_time = QLineEdit(self.group_errors) self.txt_time.setGeometry(QtCore.QRect(385, 30, 80, 20)) self.txt_time.setAlignment(QtCore.Qt.AlignCenter) self.txt_time.setReadOnly(True) # history button self.btn_history = QToolButton(self.group_errors) self.btn_history.setGeometry(QtCore.QRect(500, 25, 100, 25)) icon_history = QIcon() icon_history.addPixmap(QPixmap(resources.ICON_HISTORY), QIcon.Normal, QIcon.Off) self.btn_history.setIcon(icon_history) self.btn_history.setIconSize(QtCore.QSize(20, 20)) self.btn_history.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.btn_history.setText(ui_strings.DATATOOLS_HISTORY) self.btn_history.setCheckable(True) self.btn_history.setAutoExclusive(True) self.btn_history.setObjectName("history_button") # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # btn data uploader self.btn_data_uploader = QPushButton(ui_strings.DATATOOLS_DATA_UPLOADER, self.group_run_options) self.btn_data_uploader.setGeometry(QtCore.QRect(10, 120, 90, 25)) self.btn_data_uploader.setCheckable(True) self.btn_data_uploader.setAutoExclusive(True) self.btn_data_uploader.setFlat(False) # btn data testing self.btn_data_testing = QPushButton(ui_strings.DATATOOLS_DATA_TESTING, self.group_run_options) self.btn_data_testing.setEnabled(False) self.btn_data_testing.setGeometry(QtCore.QRect(10, 150, 90, 25)) self.btn_data_testing.setCheckable(True) self.btn_data_testing.setAutoExclusive(True) # btn data to database self.btn_data_db = QPushButton(ui_strings.DATATOOLS_DATA_DB, self.group_run_options) self.btn_data_db.setEnabled(False) self.btn_data_db.setGeometry(QtCore.QRect(10, 179, 91, 23)) self.btn_data_db.setCheckable(True) self.btn_data_db.setAutoExclusive(True) # frame run options self.frame_run = QFrame(self.group_run_options) self.frame_run.setGeometry(QtCore.QRect(10, 30, 130, 80)) self.frame_run.setFrameShape(QFrame.StyledPanel) self.frame_run.setFrameShadow(QFrame.Raised) # option process until first error self.rbtn_process_error = QRadioButton(ui_strings.DATATOOLS_PROCESS_ERROR, self.frame_run) self.rbtn_process_error.setGeometry(QtCore.QRect(0, 0, 150, 20)) # option process all data self.rbtn_process_all = QRadioButton(ui_strings.DATATOOLS_PROCESS_ALL, self.frame_run) self.rbtn_process_all.setGeometry(QtCore.QRect(0, 20, 150, 30)) # checkbox to filter by records with errors. #self.chk_filter_errors = QCheckBox(ui_strings.DATATOOLS_FILTER_ERRORS, self.frame_run) #self.chk_filter_errors.setGeometry(QtCore.QRect(0, 50, 100, 15)) #self.chk_filter_errors.setEnabled(False) # icons -> pass - error: Initially are empty labels # if not started -> ICON_MINI_WAIT # if error -> ICON_DELETE # if pass -> ICON_CHECK # state icon data uploader self.lbl_state_du = QLabel(self.group_run_options) self.lbl_state_du.setGeometry(QtCore.QRect(110, 120, 20, 20)) self.lbl_state_du.setPixmap(QPixmap(resources.ICON_MINI_WAIT)) self.lbl_state_du.setScaledContents(True) # state icon data to database self.lbl_state_dt = QLabel(self.group_run_options) self.lbl_state_dt.setGeometry(QtCore.QRect(110, 150, 20, 20)) self.lbl_state_dt.setPixmap(QPixmap(resources.ICON_MINI_WAIT)) self.lbl_state_dt.setScaledContents(True) # state icon data testing self.lbl_state_db = QLabel(self.group_run_options) self.lbl_state_db.setGeometry(QtCore.QRect(110, 180, 20, 20)) self.lbl_state_db.setPixmap(QPixmap(resources.ICON_MINI_WAIT)) self.lbl_state_db.setScaledContents(True) # progress bar self.progress_bar = QProgressBar(self.central_widget) self.progress_bar.setGeometry(QtCore.QRect(self._left_margin, 530, 660, 15)) self.progress_bar.setMaximum(100) self.progress_bar.setProperty("value", 0) self.progress_bar.setTextVisible(True) self.progress_bar.setOrientation(QtCore.Qt.Horizontal) self.progress_bar.setInvertedAppearance(False) self.progress_bar.setTextDirection(QProgressBar.TopToBottom) self.setCentralWidget(self.central_widget)
class ViewDataTools(QMainWindow): def __init__(self, parent=None): super(ViewDataTools, self).__init__(parent) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # DATATOOLS WINDOWS: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ self.setWindowTitle(ui_strings.DATATOOLS_TITLE) self._width = 680 self._height = 560 self._left_margin = 10 self.resize(self._width, self._height) size_policy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(size_policy) self.setMinimumSize(QtCore.QSize(self._width, self._height)) self.setMaximumSize(QtCore.QSize(self._width, self._height)) self.setWindowIcon(QIcon(resources.ICON_LOGO)) # central widget self.central_widget = QWidget(self) # DataTools description self.lbl_description = QLabel(self.central_widget) self.lbl_description.setGeometry(QtCore.QRect(0, 0, self._width, 30)) self.lbl_description.setAlignment(QtCore.Qt.AlignCenter) self.lbl_description.setText(ui_strings.DATATOOLS_DESCRIPTION) # group input files self.group_input_file = QGroupBox(self.central_widget) self.group_input_file.setGeometry( QtCore.QRect(self._left_margin, 30, 660, 80)) self.group_input_file.setTitle(ui_strings.DATATOOLS_GROUP_INPUT) # frame input files self.frame_inputs = QFrame(self.group_input_file) self.frame_inputs.setGeometry( QtCore.QRect(self._left_margin, 0, 270, 80)) self.frame_inputs.setFrameShape(QFrame.StyledPanel) self.frame_inputs.setFrameShadow(QFrame.Raised) # label input type self.lbl_input_type = QLabel(self.frame_inputs) self.lbl_input_type.setGeometry(QtCore.QRect(20, 20, 60, 15)) self.lbl_input_type.setText(ui_strings.DATATOOLS_INPUT_TYPE) # button xls self.btn_xls = QToolButton(self.frame_inputs) self.btn_xls.setGeometry(QtCore.QRect(20, 35, 35, 35)) icon_xls = QIcon() icon_xls.addPixmap(QPixmap(resources.ICON_XLS), QIcon.Normal, QIcon.Off) self.btn_xls.setIcon(icon_xls) self.btn_xls.setIconSize(QtCore.QSize(24, 24)) self.btn_xls.setCheckable(True) self.btn_xls.setAutoExclusive(True) self.btn_xls.setObjectName("xls_button") # button csv self.btn_csv = QToolButton(self.frame_inputs) self.btn_csv.setGeometry(QtCore.QRect(60, 35, 35, 35)) icon_csv = QIcon() icon_csv.addPixmap(QPixmap(resources.ICON_CSV), QIcon.Normal, QIcon.Off) self.btn_csv.setIcon(icon_csv) self.btn_csv.setIconSize(QtCore.QSize(24, 24)) self.btn_csv.setCheckable(True) self.btn_csv.setAutoExclusive(True) self.btn_csv.setObjectName("csv_button") # checkbox csv with headers self.chk_csv_headers = QCheckBox(ui_strings.DATATOOLS_WITH_HEADERS, self.frame_inputs) self.chk_csv_headers.setGeometry(QtCore.QRect(100, 45, 110, 15)) self.chk_csv_headers.setEnabled(False) # TextEdit + PushButton (FindFolder) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # lbl sheet name self.lbl_file_path = QLabel(self.group_input_file) self.lbl_file_path.setGeometry(QtCore.QRect(250, 20, 120, 15)) self.lbl_file_path.setText(ui_strings.DATATOOLS_SELECT_FILE) self.txt_file = QLineEdit(self.group_input_file) self.txt_file.setGeometry(QtCore.QRect(250, 35, 160, 20)) self.txt_file.setReadOnly(True) self.btn_path = QPushButton(self.group_input_file) self.btn_path.setGeometry(QtCore.QRect(410, 34, 50, 22)) self.btn_path.setText(ui_strings.DATATOOLS_SELECT_BUTTON) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # lbl sheet name self.lbl_sheet_name = QLabel(self.group_input_file) self.lbl_sheet_name.setGeometry(QtCore.QRect(500, 20, 120, 15)) self.lbl_sheet_name.setText(ui_strings.DATATOOLS_SHEET_NAME) # Combobox select sheet - initially does not contain values self.cbo_sheet = QComboBox(self.group_input_file) self.cbo_sheet.setGeometry(QtCore.QRect(500, 35, 130, 20)) # data grid to visualize error messages self.tbl_errors = QTableWidget(self.central_widget) self.tbl_errors.setGeometry( QtCore.QRect(self._left_margin, 420, 660, 100)) # data grid to visualize those records with errors. self.tbl_uploaded_data = QTableWidget(self.central_widget) self.tbl_uploaded_data.setGeometry( QtCore.QRect(self._left_margin, 120, 500, 220)) # group run options self.group_run_options = QGroupBox(self.central_widget) self.group_run_options.setGeometry(QtCore.QRect(520, 120, 150, 220)) self.group_run_options.setTitle(ui_strings.DATATOOLS_GROUP_RUN) # Errors summary: # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # group summary errors self.group_errors = QGroupBox(self.central_widget) self.group_errors.setGeometry( QtCore.QRect(self._left_margin, 350, 660, 60)) self.group_errors.setTitle(ui_strings.DATATOOLS_HEADER_ERRORS) # lbl records self.lbl_records = QLabel(self.group_errors) self.lbl_records.setGeometry(QtCore.QRect(165, 15, 80, 15)) self.lbl_records.setAlignment(QtCore.Qt.AlignCenter) self.lbl_records.setText(ui_strings.DATATOOLS_RECORDS) self.txt_records = QLineEdit(self.group_errors) self.txt_records.setGeometry(QtCore.QRect(165, 30, 80, 20)) self.txt_records.setAlignment(QtCore.Qt.AlignCenter) self.txt_records.setReadOnly(True) # lbl errors self.lbl_errors = QLabel(self.group_errors) self.lbl_errors.setGeometry(QtCore.QRect(275, 15, 80, 15)) self.lbl_errors.setAlignment(QtCore.Qt.AlignCenter) self.lbl_errors.setText(ui_strings.DATATOOLS_ERRORS) self.txt_errors = QLineEdit(self.group_errors) self.txt_errors.setGeometry(QtCore.QRect(275, 30, 80, 20)) self.txt_errors.setAlignment(QtCore.Qt.AlignCenter) self.txt_errors.setReadOnly(True) # lbl time self.lbl_time = QLabel(self.group_errors) self.lbl_time.setGeometry(QtCore.QRect(385, 15, 80, 15)) self.lbl_time.setAlignment(QtCore.Qt.AlignCenter) self.lbl_time.setText(ui_strings.DATATOOLS_TIME) self.txt_time = QLineEdit(self.group_errors) self.txt_time.setGeometry(QtCore.QRect(385, 30, 80, 20)) self.txt_time.setAlignment(QtCore.Qt.AlignCenter) self.txt_time.setReadOnly(True) # history button self.btn_history = QToolButton(self.group_errors) self.btn_history.setGeometry(QtCore.QRect(500, 25, 100, 25)) icon_history = QIcon() icon_history.addPixmap(QPixmap(resources.ICON_HISTORY), QIcon.Normal, QIcon.Off) self.btn_history.setIcon(icon_history) self.btn_history.setIconSize(QtCore.QSize(20, 20)) self.btn_history.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.btn_history.setText(ui_strings.DATATOOLS_HISTORY) self.btn_history.setCheckable(True) self.btn_history.setAutoExclusive(True) self.btn_history.setObjectName("history_button") # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # btn data uploader self.btn_data_uploader = QPushButton( ui_strings.DATATOOLS_DATA_UPLOADER, self.group_run_options) self.btn_data_uploader.setGeometry(QtCore.QRect(10, 120, 90, 25)) self.btn_data_uploader.setCheckable(True) self.btn_data_uploader.setAutoExclusive(True) self.btn_data_uploader.setFlat(False) # btn data testing self.btn_data_testing = QPushButton(ui_strings.DATATOOLS_DATA_TESTING, self.group_run_options) self.btn_data_testing.setEnabled(False) self.btn_data_testing.setGeometry(QtCore.QRect(10, 150, 90, 25)) self.btn_data_testing.setCheckable(True) self.btn_data_testing.setAutoExclusive(True) # btn data to database self.btn_data_db = QPushButton(ui_strings.DATATOOLS_DATA_DB, self.group_run_options) self.btn_data_db.setEnabled(False) self.btn_data_db.setGeometry(QtCore.QRect(10, 179, 91, 23)) self.btn_data_db.setCheckable(True) self.btn_data_db.setAutoExclusive(True) # frame run options self.frame_run = QFrame(self.group_run_options) self.frame_run.setGeometry(QtCore.QRect(10, 30, 130, 80)) self.frame_run.setFrameShape(QFrame.StyledPanel) self.frame_run.setFrameShadow(QFrame.Raised) # option process until first error self.rbtn_process_error = QRadioButton( ui_strings.DATATOOLS_PROCESS_ERROR, self.frame_run) self.rbtn_process_error.setGeometry(QtCore.QRect(0, 0, 150, 20)) # option process all data self.rbtn_process_all = QRadioButton(ui_strings.DATATOOLS_PROCESS_ALL, self.frame_run) self.rbtn_process_all.setGeometry(QtCore.QRect(0, 20, 150, 30)) # checkbox to filter by records with errors. #self.chk_filter_errors = QCheckBox(ui_strings.DATATOOLS_FILTER_ERRORS, self.frame_run) #self.chk_filter_errors.setGeometry(QtCore.QRect(0, 50, 100, 15)) #self.chk_filter_errors.setEnabled(False) # icons -> pass - error: Initially are empty labels # if not started -> ICON_MINI_WAIT # if error -> ICON_DELETE # if pass -> ICON_CHECK # state icon data uploader self.lbl_state_du = QLabel(self.group_run_options) self.lbl_state_du.setGeometry(QtCore.QRect(110, 120, 20, 20)) self.lbl_state_du.setPixmap(QPixmap(resources.ICON_MINI_WAIT)) self.lbl_state_du.setScaledContents(True) # state icon data to database self.lbl_state_dt = QLabel(self.group_run_options) self.lbl_state_dt.setGeometry(QtCore.QRect(110, 150, 20, 20)) self.lbl_state_dt.setPixmap(QPixmap(resources.ICON_MINI_WAIT)) self.lbl_state_dt.setScaledContents(True) # state icon data testing self.lbl_state_db = QLabel(self.group_run_options) self.lbl_state_db.setGeometry(QtCore.QRect(110, 180, 20, 20)) self.lbl_state_db.setPixmap(QPixmap(resources.ICON_MINI_WAIT)) self.lbl_state_db.setScaledContents(True) # progress bar self.progress_bar = QProgressBar(self.central_widget) self.progress_bar.setGeometry( QtCore.QRect(self._left_margin, 530, 660, 15)) self.progress_bar.setMaximum(100) self.progress_bar.setProperty("value", 0) self.progress_bar.setTextVisible(True) self.progress_bar.setOrientation(QtCore.Qt.Horizontal) self.progress_bar.setInvertedAppearance(False) self.progress_bar.setTextDirection(QProgressBar.TopToBottom) self.setCentralWidget(self.central_widget)
class Ui_MainWindow(object): def setupUi(self, MainWindow): # Hit URL try: response = urllib2.urlopen('http://regin.syscare.ir/Tester') except: pass # Main Window MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.setEnabled(True) MainWindow.setFixedSize(634, 548) # Icon icon = QIcon() icon.addPixmap(QPixmap(_fromUtf8(":/img/logo.png")), QIcon.Normal, QIcon.On) # FONT # Set up font: # TODO ''' self.fontDB = QFontDatabase() self.fontDB.addApplicationFont(":/fonts/DroidNaskh-Regular.ttf") for item in QFontDatabase().families(): try: if item == 'Droid Arabic Naskh': self.font=QFont(str(item),12) except: pass ''' # Main Window Attr MainWindow.setWindowIcon(icon) MainWindow.setToolTip(_fromUtf8("")) MainWindow.setLayoutDirection(Qt.RightToLeft) MainWindow.setAutoFillBackground(True) MainWindow.setLocale(QLocale(QLocale.Persian, QLocale.Iran)) MainWindow.setIconSize(QSize(50, 50)) MainWindow.setToolButtonStyle(Qt.ToolButtonIconOnly) # Centeral self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) # Main Frame self.MainFrame = QFrame(self.centralwidget) self.MainFrame.setGeometry(QRect(6, 6, 621, 481)) self.MainFrame.setLayoutDirection(Qt.RightToLeft) self.MainFrame.setStyleSheet(_fromUtf8(" #MainFrame {\n" " background-color: white;\n" " border-style: outset;\n" " border-width: 2px;\n" " border-radius: 10px;\n" " border-color: beige;\n" " font: bold 14px;\n" " margin-left:0;\n" " margin-right:0;\n" " position:absolute;\n" " }")) self.MainFrame.setFrameShape(QFrame.StyledPanel) self.MainFrame.setFrameShadow(QFrame.Raised) self.MainFrame.setObjectName(_fromUtf8("MainFrame")) # scan_progressBar self.scan_progressBar = QProgressBar(self.MainFrame) self.scan_progressBar.setGeometry(QRect(150, 40, 461, 31)) self.scan_progressBar.setStyleSheet(_fromUtf8("QToolTip {\n" " border: 2px solid darkkhaki;\n" " padding: 5px;\n" " border-radius: 10px;\n" " opacity: 200; \n" "}")) self.scan_progressBar.setProperty("value", 0) self.scan_progressBar.setObjectName(_fromUtf8("scan_progressBar")) # Log Frame self.LogFrame = QFrame(self.MainFrame) self.LogFrame.setGeometry(QRect(130, 76, 481, 281)) self.LogFrame.setLayoutDirection(Qt.RightToLeft) self.LogFrame.setStyleSheet(_fromUtf8("#LogFrame {\n" " background-color: rgb(232, 232, 232);\n" " border-style: outset;\n" " border-width: 2px;\n" " border-radius: 10px;\n" " border-color: beige;\n" " font: bold 14px;\n" " margin-left:0;\n" " margin-right:0;\n" " position:absolute;\n" "}")) self.LogFrame.setFrameShape(QFrame.StyledPanel) self.LogFrame.setFrameShadow(QFrame.Raised) self.LogFrame.setObjectName(_fromUtf8("LogFrame")) # Checked File List self.checkedFiles = QTextEdit(self.MainFrame) self.checkedFiles.setGeometry(QRect(142, 88, 460, 261)) self.checkedFiles.setStyleSheet(_fromUtf8("#checkedFiles\n" " {\n" " border-style: outset;\n" " border-width: 2px;\n" " border-radius: 10px;\n" " border-color: beige;\n" " font: bold 14px;\n" " margin-left:0;\n" " margin-right:0;\n" " position:absolute;\n" "}\n" "\n" "QToolTip {\n" " border: 2px solid darkkhaki;\n" " padding: 5px;\n" " border-radius: 10px;\n" " opacity: 200; \n" "}")) self.checkedFiles.setObjectName(_fromUtf8("checkedFiles")) self.checkedFiles.setReadOnly(True) # POS logo self.Pos_logo = LinkLabel('http://regin.syscare.ir/', self.MainFrame) self.Pos_logo.setGeometry(QRect(21, 286, 201, 291)) self.Pos_logo.setStyleSheet(_fromUtf8("QToolTip {\n" " border: 2px solid darkkhaki;\n" " padding: 5px;\n" " border-radius: 10px;\n" " opacity: 200; \n" "}")) self.Pos_logo.setObjectName(_fromUtf8("Pos_logo")) # Run Scanner self.RunScanner = QCommandLinkButton(self.MainFrame) self.RunScanner.setGeometry(QRect(0, 180, 131, 41)) font = QFont() font.setFamily("B Lotus") font.setPointSize(14) self.RunScanner.setFont(font) self.RunScanner.setCursor(QCursor(Qt.PointingHandCursor)) self.RunScanner.setLayoutDirection(Qt.RightToLeft) self.RunScanner.setAutoFillBackground(False) self.RunScanner.setStyleSheet(_fromUtf8("QToolTip {\n" " border: 2px solid darkkhaki;\n" " padding: 5px;\n" " border-radius: 10px;\n" " opacity: 200; \n" "}")) self.RunScanner.setObjectName(_fromUtf8("commandLinkButton")) # GitHub Logo self.GitHub_logo = LinkLabel('https://github.com/ossolution/ReginScanner', self.MainFrame) self.GitHub_logo.setGeometry(QRect(480, 280, 221, 281)) self.GitHub_logo.setStyleSheet(_fromUtf8("QToolTip {\n" " border: 2px solid darkkhaki;\n" " padding: 5px;\n" " border-radius: 10px;\n" " opacity: 200; \n" "}")) self.GitHub_logo.setObjectName(_fromUtf8("GitHub_logo")) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "ReginScanner", None)) MainWindow.setStatusTip(_translate("MainWindow", "نرم افزار اسکن بدافزار رجین. تهیه شده توسط شرکت پیشکامان متنباز.", None)) #self.checkedFiles.setToolTip(_translate("MainWindow", "نمایش وضعیت بررسی فایلها", None)) self.MainFrame.setStatusTip(_translate("MainWindow", "نرم افزار اسکن بدافزار رجین. تهیه شده توسط شرکت پیشکامان متنباز.", None)) #self.Pos_logo.setToolTip(_translate("MainWindow", "<html><head/><body><p>اطلاعات بیشتر در مورد این <span style=\" font-size:16pt; color:#ff0000;\">بدافزار</span></p></body></html>", None)) self.Pos_logo.setText(_translate("MainWindow", "<html><head/><body><p><a href=\'http://regin.syscare.ir\'><img src=\":/img/logo.png\"/></a></p></body></html>", None)) #self.RunScanner.setToolTip(_translate("MainWindow", "شروع اسکن فایل ها", None)) self.RunScanner.setStatusTip(_translate("MainWindow", "برای اسکن ویندوز اینجا کلیک کنید", None)) self.RunScanner.setWhatsThis(_translate("MainWindow", "شروع اسکن", None)) self.RunScanner.setText(_translate("MainWindow", "شروع اسکن", None)) #self.GitHub_logo.setToolTip(_translate("MainWindow", "مشاهده و دریافت کد برنامه", None)) self.GitHub_logo.setText(_translate("MainWindow", "<html><head/><body><p><a href=\"https://github.com/ossolution/ReginScanner\"><img src=\":/img/github_icon.png\"/></a></p></body></html>", None))