Source code for vdat.gui.progress
# Virus Data Analysis Tool: a data reduction GUI for HETDEX/VIRUS data
# Copyright (C) 2016 "The HETDEX collaboration"
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
'Custom progress and status bar objects'
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from qtpy import QtCore, QtWidgets
[docs]class VDATProgressBar(QtWidgets.QProgressBar):
'''VDAT progress bar.
.. list-table:: **Custom slot**
:header-rows: 1
* - Name
- Signature
- Description
* - :meth:`setup_bar`
- int
- setup the format, the maximum to the input value and the value to
zero
* - :meth:`update_bar`
- int, int, int, int
- update the value of the progress bar; only the second value used
* - :meth:`reset_bar`
- bool
- if the input is ``True`` reset the progress bar
Parameters
----------
parent : :class:`PyQt5.QtWidgets.QWidget` instance
the parent widget
'''
def __init__(self, parent=None):
super(VDATProgressBar, self).__init__(parent)
self.setMinimum(0)
[docs] @QtCore.Slot(int)
def setup_bar(self, max_):
"""Setup the format, the maximum to the input value and the value to
zero. Designed to be connected with the ``n_primaries`` signal from
:mod:`vdat.command_interpreter.signals`
Parameters
----------
max_ : int
maximum value for the progress bar
"""
self.setFormat('%v/%m - %p%')
self.setMaximum(max_)
self.setValue(0)
[docs] @QtCore.Slot(int, int, int, int)
def update_bar(self, int_tot, int_done, int_skipped, int_fail):
"""Set the value of the progress bar to ``int_done``. Designed to be
connected with the ``progress`` signal from
:mod:`vdat.command_interpreter.signals`.
"""
self.setValue(int_done)
[docs] @QtCore.Slot(bool)
def reset_bar(self, bool_global):
"""If ``bool_global == True``, reset the progress bar. Designed to be
connected with the ``command_done`` signal from
:mod:`vdat.command_interpreter.signals`."""
if bool_global:
self.reset()
[docs]class VDATStatusBar(QtWidgets.QStatusBar):
'''Customized status bar
.. list-table:: **Custom slot**
:header-rows: 1
* - Name
- Signature
- Description
* - :meth:`running_command`
- int, str
- show a message with the input string
* - :meth:`clear_message`
- bool
- if the input is ``True`` show the message "Done" for 3 seconds
Parameters
----------
parent : :class:`PyQt5.QtWidgets.QWidget` instance
the parent widget
'''
def __init__(self, parent=None):
super(VDATStatusBar, self).__init__(parent=parent)
self.setObjectName("statusbar")
[docs] @QtCore.Slot(int, str)
def running_command(self, int_, str_):
"""Show the input string. Designed to
be connected with the ``command_string`` signal from
:mod:`vdat.command_interpreter.signals`."""
self.showMessage('Finished: ' + str_)
[docs] @QtCore.Slot(bool)
def clear_message(self, global_):
"""If ``bool_global == True``, show "Done" for 3 seconds. Designed to
be connected with the ``command_done`` signal from
:mod:`vdat.command_interpreter.signals`."""
if global_:
self.showMessage('Done', msecs=3000)