def download_(self): print("download_") self.b = QCommandLinkButton("") self.b.clicked.connect(self.get_setup) msg = QLabel("Connexion ...") self.addWidget(msg) msg.hide() self.b.setText(self.check.data.get("message")) self.addWidget(self.b)
def __init__(self, files, tab, delete, parent, test=False): """ Keyword arguments: files -- list with dicts containing file names tab -- instanseof AudioVideoTab, ImageTab or DocumentTab indicating currently active tab delete -- boolean that shows if files must removed after conversion parent -- parent widget files: Each dict have only one key and one corresponding value. Key is a file to be converted and it's value is the name of the new file that will be converted. Example list: [{"/foo/bar.png" : "/foo/bar.bmp"}, {"/f/bar2.png" : "/f/bar2.bmp"}] """ super(Progress, self).__init__(parent) self.parent = parent self.files = files self.num_total_files = len(self.files) self.tab = tab self.delete = delete if not test: self._type = tab.name self.step = int(100 / len(files)) self.ok = 0 self.error = 0 self.running = True self.nowQL = QLabel(self.tr('In progress: ')) totalQL = QLabel(self.tr('Total:')) self.nowQPBar = QProgressBar() self.nowQPBar.setValue(0) self.totalQPBar = QProgressBar() self.totalQPBar.setValue(0) self.cancelQPB = QPushButton(self.tr('Cancel')) detailsQPB = QCommandLinkButton(self.tr('Details')) detailsQPB.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) detailsQPB.setCheckable(True) detailsQPB.setMaximumWidth(113) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) self.outputQTE = QTextEdit() self.outputQTE.setReadOnly(True) self.frame = QFrame() frame_layout = utils.add_to_layout('h', self.outputQTE) self.frame.setLayout(frame_layout) self.frame.hide() hlayout = utils.add_to_layout('h', None, self.nowQL, None) hlayout2 = utils.add_to_layout('h', None, totalQL, None) hlayout3 = utils.add_to_layout('h', detailsQPB, line) hlayout4 = utils.add_to_layout('h', self.frame) hlayout5 = utils.add_to_layout('h', None, self.cancelQPB) vlayout = utils.add_to_layout( 'v', hlayout, self.nowQPBar, hlayout2, self.totalQPBar, None, hlayout3, hlayout4, hlayout5 ) self.setLayout(vlayout) detailsQPB.toggled.connect(self.resize_dialog) detailsQPB.toggled.connect(self.frame.setVisible) self.cancelQPB.clicked.connect(self.reject) self.file_converted_signal.connect(self.next_file) self.refr_bars_signal.connect(self.refresh_progress_bars) self.update_text_edit_signal.connect(self.update_text_edit) self.resize(484, 200) self.setWindowTitle('FF Multi Converter - ' + self.tr('Conversion')) if not test: self.get_data() # should be first and not in QTimer.singleShot() QTimer.singleShot(0, self.manage_conversions)
def __init__(self, files, _type, cmd, ffmpeg, size, mntaspect, delete, parent, test=False): """ Keyword arguments: files -- list with dicts containing file names _type -- 'AudioVideo', 'Images' or 'Documents' depending files type cmd -- ffmpeg command, for audio/video conversions ffmpeg -- if True ffmpeg will be used, else avconv for audio/video conversions size -- new image size string of type 'widthxheight' eg. '300x300' for image conversions mntaspect -- boolean indicating whether aspect ratio must be maintained for image conversions delete -- boolean that shows if files must removed after conversion files: Each dict have only one key and one corresponding value. Key is a file to be converted and it's value is the name of the new file that will be converted. Example list: [{"/foo/bar.png" : "/foo/bar.bmp"}, {"/f/bar2.png" : "/f/bar2.bmp"}] """ super(Progress, self).__init__(parent) self.parent = parent self._type = _type self.cmd = cmd self.ffmpeg = ffmpeg self.size = size self.mntaspect = mntaspect self.files = files self.delete = delete if not test: self.step = int(100 / len(files)) self.ok = 0 self.error = 0 self.running = True self.nowLabel = QLabel(self.tr('In progress: ')) totalLabel = QLabel(self.tr('Total:')) self.nowBar = QProgressBar() self.nowBar.setValue(0) self.totalBar = QProgressBar() self.totalBar.setValue(0) self.cancelButton = QPushButton(self.tr('Cancel')) detailsButton = QCommandLinkButton(self.tr('Details')) detailsButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed)) detailsButton.setCheckable(True) detailsButton.setMaximumWidth(113) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) self.textEdit = QTextEdit() self.textEdit.setReadOnly(True) self.frame = QFrame() frame_layout = pyqttools.add_to_layout(QHBoxLayout(), self.textEdit) self.frame.setLayout(frame_layout) self.frame.hide() hlayout = pyqttools.add_to_layout(QHBoxLayout(), None, self.nowLabel, None) hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), None, totalLabel, None) hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), detailsButton, line) hlayout4 = pyqttools.add_to_layout(QHBoxLayout(), self.frame) hlayout5 = pyqttools.add_to_layout(QHBoxLayout(), None, self.cancelButton) vlayout = pyqttools.add_to_layout(QVBoxLayout(), hlayout, self.nowBar, hlayout2, self.totalBar, None, hlayout3, hlayout4, hlayout5) self.setLayout(vlayout) detailsButton.toggled.connect(self.resize_dialog) detailsButton.toggled.connect(self.frame.setVisible) self.cancelButton.clicked.connect(self.reject) self.file_converted_signal.connect(self.file_converted) self.refr_bars_signal.connect(self.refresh_progress_bars) self.update_text_edit_signal.connect(self.update_text_edit) self.resize(484, 200) self.setWindowTitle('FF Multi Converter - ' + self.tr('Conversion')) if not test: QTimer.singleShot(0, self.manage_conversions)
class GStatusBar(QStatusBar): def __init__(self, parent): QStatusBar.__init__(self, parent) if not Config.SERV: print("Not Serveur ") return self.rsp = {} self.check = TaskThreadServer(self) QObject.connect(self.check, SIGNAL("download_"), self.download_) self.check.start() def download_(self): print("download_") self.b = QCommandLinkButton("") self.b.clicked.connect(self.get_setup) msg = QLabel("Connexion ...") self.addWidget(msg) msg.hide() self.b.setText(self.check.data.get("message")) self.addWidget(self.b) def get_setup(self): self.progressBar = QProgressBar(self) # self.progressBar.setGeometry(430, 30, 400, 25) self.addWidget(self.progressBar) self.t = TaskThread(self) QObject.connect(self.t, SIGNAL("download_finish"), self.download_finish) self.t.start() def failure(self): print("failure") self.b.setText("La mise à jour a échoué.") self.progressBar.close() self.b.setEnabled(True) def download_finish(self): print('download_finish') self.b.hide() self.progressBar.close() self.instb = QCommandLinkButton("installer la Ver. {}".format( self.check.data.get("version"))) self.instb.clicked.connect(self.start_install) # self.progressBar.close() self.addWidget(self.instb) def start_install(self): try: os.startfile(os.path.basename(self.installer_name)) import sys sys.exit() except OSError: self.failure() def download_setup_file(self): self.b.setEnabled(False) self.b.setText("Téléchargement en cours ...") self.installer_name = "{}.exe".format(self.check.data.get("app")) url = "{}{}".format(base_url, self.check.data.get("setup_file_url")) r = requests.get(url, stream=True) if r.status_code == 200: total_length = r.headers.get('content-length') with open(self.installer_name, 'wb') as f: if total_length is None: # no content length header f.write(r.content) else: dl = 0 for data in r.iter_content(chunk_size=4096): dl += len(data) f.write(data) done = int(100 * dl / int(total_length)) self.progressBar.setValue(done)
def __init__(self, files, tab, delete, parent, test=False): """ Keyword arguments: files -- list with dicts containing file names tab -- instanseof AudioVideoTab, ImageTab or DocumentTab indicating currently active tab delete -- boolean that shows if files must removed after conversion parent -- parent widget files: Each dict have only one key and one corresponding value. Key is a file to be converted and it's value is the name of the new file that will be converted. Example list: [{"/foo/bar.png" : "/foo/bar.bmp"}, {"/f/bar2.png" : "/f/bar2.bmp"}] """ super(Progress, self).__init__(parent) self.parent = parent self.files = files self.num_total_files = len(self.files) self.tab = tab self.delete = delete if not test: self._type = tab.name self.step = int(100 / len(files)) self.ok = 0 self.error = 0 self.running = True self.nowQL = QLabel(self.tr('In progress: ')) totalQL = QLabel(self.tr('Total:')) self.nowQPBar = QProgressBar() self.nowQPBar.setValue(0) self.totalQPBar = QProgressBar() self.totalQPBar.setValue(0) self.cancelQPB = QPushButton(self.tr('Cancel')) detailsQPB = QCommandLinkButton(self.tr('Details')) detailsQPB.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) detailsQPB.setCheckable(True) detailsQPB.setMaximumWidth(113) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) self.outputQTE = QTextEdit() self.outputQTE.setReadOnly(True) self.frame = QFrame() frame_layout = utils.add_to_layout('h', self.outputQTE) self.frame.setLayout(frame_layout) self.frame.hide() hlayout = utils.add_to_layout('h', None, self.nowQL, None) hlayout2 = utils.add_to_layout('h', None, totalQL, None) hlayout3 = utils.add_to_layout('h', detailsQPB, line) hlayout4 = utils.add_to_layout('h', self.frame) hlayout5 = utils.add_to_layout('h', None, self.cancelQPB) vlayout = utils.add_to_layout('v', hlayout, self.nowQPBar, hlayout2, self.totalQPBar, None, hlayout3, hlayout4, hlayout5) self.setLayout(vlayout) detailsQPB.toggled.connect(self.resize_dialog) detailsQPB.toggled.connect(self.frame.setVisible) self.cancelQPB.clicked.connect(self.reject) self.file_converted_signal.connect(self.next_file) self.refr_bars_signal.connect(self.refresh_progress_bars) self.update_text_edit_signal.connect(self.update_text_edit) self.resize(484, 200) self.setWindowTitle('FF Multi Converter - ' + self.tr('Conversion')) if not test: self.get_data() # should be first and not in QTimer.singleShot() QTimer.singleShot(0, self.manage_conversions)
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)
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))