aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-12-20 19:25:48 -0500
committerJesús <heckyel@hyperbola.info>2019-12-20 19:25:48 -0500
commitc0da5d1d20aef2ab8ffeda8c1263bd8b339efb9f (patch)
tree9eb92e416592dec340061b578c65cd48b71aed30
parentdf2fc30636efd1b61f6da361446e4d6d4c41c07e (diff)
downloadhypervideo-gui-c0da5d1d20aef2ab8ffeda8c1263bd8b339efb9f.tar.lz
hypervideo-gui-c0da5d1d20aef2ab8ffeda8c1263bd8b339efb9f.tar.xz
hypervideo-gui-c0da5d1d20aef2ab8ffeda8c1263bd8b339efb9f.zip
pep8
-rw-r--r--hypervideo_gui/main_ui.py96
1 files changed, 45 insertions, 51 deletions
diff --git a/hypervideo_gui/main_ui.py b/hypervideo_gui/main_ui.py
index 8ec63d0..9466bcf 100644
--- a/hypervideo_gui/main_ui.py
+++ b/hypervideo_gui/main_ui.py
@@ -83,33 +83,22 @@ class MainWindow(QMainWindow):
self.cmd = None
self.proc = QProcess(self)
- self.proc.started.connect(
- lambda: self.show_message("Creating List"))
- self.proc.started.connect(
- lambda: self.btn_get_fmts.setEnabled(False))
- self.proc.finished.connect(
- lambda: self.show_message("Finished creating List"))
+ self.proc.started.connect(lambda: self.show_msg("Creating list"))
+ self.proc.started.connect(lambda: self.btn_get_fmts.setEnabled(False))
+ self.proc.finished.connect(lambda: self.show_msg("List done!"))
self.proc.finished.connect(self.process_finished)
- self.proc.finished.connect(
- lambda: self.btn_get_fmts.setEnabled(True))
+ self.proc.finished.connect(lambda: self.btn_get_fmts.setEnabled(True))
self.proc.readyRead.connect(self.process_output)
self.dl_proc = QProcess(self)
self.dl_proc.setProcessChannelMode(QProcess.MergedChannels)
- self.dl_proc.started.connect(
- lambda: self.show_message("Download started"))
- self.dl_proc.started.connect(
- lambda: self.dl_button.setEnabled(False))
- self.dl_proc.started.connect(
- lambda: self.cancel_button.setEnabled(True))
- self.dl_proc.finished.connect(
- lambda: self.show_message("Download finished"))
- self.dl_proc.finished.connect(
- lambda: self.dl_button.setEnabled(True))
- self.dl_proc.finished.connect(
- lambda: self.cancel_button.setEnabled(False))
- self.dl_proc.finished.connect(
- lambda: self.setWindowTitle(__title__))
+ self.dl_proc.started.connect(lambda: self.show_msg("Download started"))
+ self.dl_proc.started.connect(lambda: self.dl_btn.setEnabled(False))
+ self.dl_proc.started.connect(lambda: self.cxl_btn.setEnabled(True))
+ self.dl_proc.finished.connect(lambda: self.show_msg("Download done!"))
+ self.dl_proc.finished.connect(lambda: self.dl_btn.setEnabled(True))
+ self.dl_proc.finished.connect(lambda: self.cxl_btn.setEnabled(False))
+ self.dl_proc.finished.connect(lambda: self.setWindowTitle(__title__))
self.dl_proc.readyRead.connect(self.dl_process_out)
self.setGeometry(0, 0, 600, 250)
@@ -180,12 +169,13 @@ class MainWindow(QMainWindow):
hlayout3.addWidget(btn_exec_path)
hlayout3.addWidget(self.lbl_exec_path)
- self.dl_button = QToolButton()
- self.dl_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
- self.dl_button.setText("Download")
- self.dl_button.clicked.connect(self.download_selected)
- self.dl_button.setFixedWidth(btnwidth)
- self.dl_button.setFixedHeight(32)
+ # Download button
+ self.dl_btn = QToolButton()
+ self.dl_btn.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ self.dl_btn.setText("Download")
+ self.dl_btn.clicked.connect(self.download_selected)
+ self.dl_btn.setFixedWidth(btnwidth)
+ self.dl_btn.setFixedHeight(32)
self.btn_get_fmts = QToolButton()
self.btn_get_fmts.setText('Get Formats')
@@ -193,28 +183,32 @@ class MainWindow(QMainWindow):
self.btn_get_fmts.setFixedHeight(32)
self.btn_get_fmts.clicked.connect(self.fill_combo_formats)
- self.cancel_button = QToolButton()
- self.cancel_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
- self.cancel_button.setText("Cancel")
- self.cancel_button.clicked.connect(self.cancel_download)
- self.cancel_button.setEnabled(False)
- self.cancel_button.setFixedWidth(btnwidth)
- self.cancel_button.setFixedHeight(32)
+ # Cancel button
+ self.cxl_btn = QToolButton()
+ self.cxl_btn.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ self.cxl_btn.setText("Cancel")
+ self.cxl_btn.clicked.connect(self.cancel_download)
+ self.cxl_btn.setEnabled(False)
+ self.cxl_btn.setFixedWidth(btnwidth)
+ self.cxl_btn.setFixedHeight(32)
+ # Video FormatCombobox
self.vfms_cmbox = QComboBox()
self.populate_video_format_combobox(self.dflt_fms_menu_items)
self.vfms_cmbox.setFixedHeight(26)
+ # Progressbar
self.pbar = QProgressBar()
self.pbar.setFixedHeight(16)
self.pbar.setMaximum(100)
self.pbar.setMinimum(0)
self.pbar.setValue(0)
+ # Layout
btn_layout = QHBoxLayout()
- btn_layout.addWidget(self.dl_button)
+ btn_layout.addWidget(self.dl_btn)
btn_layout.addWidget(self.btn_get_fmts)
- btn_layout.addWidget(self.cancel_button)
+ btn_layout.addWidget(self.cxl_btn)
vlayout = QVBoxLayout()
vlayout.addLayout(hlayout)
@@ -285,18 +279,18 @@ class MainWindow(QMainWindow):
def update_output_path(self):
''' Update Path Output '''
self.out_folder_path = self.lbl_out_path.text()
- self.show_message(
+ self.show_msg(
"Output path changed to: %s" %
self.lbl_out_path.text())
def update_hypervideo_path(self):
''' Update Hypervideo Path Output '''
self.hypervideo_bin = self.lbl_exec_path.text()
- self.show_message(
+ self.show_msg(
"hypervideo path changed to: %s" %
self.lbl_exec_path.text())
- def show_message(self, message):
+ def show_msg(self, message):
''' Show Message in StatuBar '''
self.statusBar().showMessage(message, msecs=0)
@@ -352,9 +346,9 @@ class MainWindow(QMainWindow):
debugging('Scan Formats')
self.proc.start(self.hypervideo_bin, ['-F', self.url_catch])
else:
- self.show_message("URL empty")
+ self.show_msg("URL empty")
else:
- self.show_message("hypervideo missing")
+ self.show_msg("hypervideo missing")
def process_output(self):
''' Process out '''
@@ -376,7 +370,7 @@ class MainWindow(QMainWindow):
count = self.vfms_cmbox.count()
self.vfms_cmbox.setCurrentIndex(count - 1)
else:
- self.show_message("Formats empty or URL without video")
+ self.show_msg("Formats empty or URL without video")
def download_selected(self):
''' Download selected video format '''
@@ -407,17 +401,17 @@ class MainWindow(QMainWindow):
options.append("-o")
options.append("%(title)s.%(ext)s")
options.append(self.url_catch)
- self.show_message("Download started")
+ self.show_msg("Download started")
debugging('Download Selected Quality: %s' % quality)
debugging('Download URL: %s' % self.url_catch)
self.dl_proc.setWorkingDirectory(self.out_folder_path)
self.dl_proc.start(self.hypervideo_bin, options)
else:
- self.show_message("List of available files is empty")
+ self.show_msg("List of available files is empty")
else:
- self.show_message("URL empty")
+ self.show_msg("URL empty")
else:
- self.show_message("hypervideo missing")
+ self.show_msg("hypervideo missing")
def dl_process_out(self):
''' Download process out '''
@@ -427,7 +421,7 @@ class MainWindow(QMainWindow):
except TypeError:
out = str(self.dl_proc.readAll()).rstrip()
out = out.rpartition("[download] ")[2]
- self.show_message("Progress: %s" % out)
+ self.show_msg("Progress: %s" % out)
self.setWindowTitle(out)
out = out.rpartition("%")[0].rpartition(".")[0]
if not out == "":
@@ -442,11 +436,11 @@ class MainWindow(QMainWindow):
if self.dl_proc.state() == QProcess.Running:
debugging('Process is running, will be cancelled')
self.dl_proc.close()
- self.show_message("Download cancelled")
+ self.show_msg("Download cancelled")
self.pbar.setValue(0)
- self.cancel_button.setEnabled(False)
+ self.cxl_btn.setEnabled(False)
else:
- self.show_message("Process is not running")
+ self.show_msg("Process is not running")
def create_status_bar(self):
''' Create StatusBar'''