vdat.gui.queue – The Queue window

Create a window representing a queue via a list of items.

The original implementation has been generated from reading ui file ‘listWindow.ui’

Created: Mon Jun 15 16:25:52 2015 by: PyQt4 UI code generator 4.10.4

class vdat.gui.queue.QueuedCommand(command, label, tool_tip=None, parent=None)[source]

Bases: PyQt5.QtWidgets.QListWidgetItem

Class describing the objects stored in the ModifyableListWidget.

Each object represent a command

Parameters:
command : QCommandInterpreter

instance of the command interpreter to add to the queue

label : string

a label to appear for this command on the queue

tool_tip : string, optional

tool tip to show

parent : PyQt5.QtWidgets.QWidget instance

the parent widget

class vdat.gui.queue.ModifyableListWidget[source]

Bases: PyQt5.QtWidgets.QListWidget

List widget with the possibility to remove items

keyPressEvent(event)[source]

Override the default method, removing the selected entry

Parameters:
event : PyQt5.QtGui.QKeyEvent

object describing a key being pressed or released

class vdat.gui.queue.Queue(parent=None)[source]

Bases: PyQt5.QtWidgets.QMainWindow

A queue that stores user commands and displays them in a GUI window.

Custom signals
Name Signature Description
closeSignal   emitted when the queue window is closed
job_added   emitted when a job is added to the queue
run_signal   emitted when a new command can be run
queue_empty_signal   emitted when the queue is empty
command_done bool these five signals are a Qt re-implementation of the signals described in the signals
command_string int, str  
global_logger int, str  
n_primaries int  
progress int, int, int, int  
Custom slot
Name Signature Description
toggle() bool hide (False) or show (True) the panel
run()   grab a command from the queue and run it
toggle_and_rerun()   prepare to run a new command
Connections between custom signals and/or slots
Signal Slot/Signal
job_added run()
run_signal run()
QCommandInterpreter.command_done command_done
QCommandInterpreter.command_string command_string
QCommandInterpreter.global_logger global_logger
QCommandInterpreter.n_primaries n_primaries
QCommandInterpreter.progress progress
PyQt5.QtCore.QThread.started QCommandInterpreter.run()
QCommandInterpreter.finished toggle_and_rerun()
Parameters:
parent : PyQt5.QtWidgets.QWidget instance

the parent widget

Attributes:
is_command_running : bool

mark whether a command is running or not in a thread

closeSignal
job_added
run_signal
queue_empty_signal
command_done
command_string
global_logger
n_primaries
progress
_reconnect_names = ['command_done', 'command_string', 'global_logger', 'n_primaries', 'progress']
setupUi()[source]

Setup the queue window

closeEvent(event)[source]

When the user closes the window, ignore the request, hide the window and emit the closeSignal signal.

Parameters:
event : PyQt5.QtGui.QKeyEvent

object describing a key being pressed or released

toggle(tggl)[source]

Hide or show the panel. Alias of setVisible().

Parameters:
toggle : bool

whether the window is visible or not

add_command(command, label, tool_tip=None)[source]

Add a command to the queue. Emit the job_added signal.

Parameters:
command : QCommandInterpreter

instance of the command interpreter to add to the queue

label : string

A label to appear for this command on the queue

tool_tip : string, optional

tool tip to show

get_command()[source]

Get the top item from the queue.

Returns:
:class:`QCommandInterpreter` instance

command to run, or None if the list is empty

connect_worker_signals(worker)[source]

Connect the worker signals to the corresponding ones in this class

Parameters:
worker : QCommandInterpreter

worker instance with the signals to connect with this object ones

remove_old_thread_worker()[source]

Quit the used thread and mark the it and worker for deletion

run()[source]

Grab a job from the queue and run it on a newly created QThread.

If a command is already running, and return. If the queue is empty notify the user and return.

The QThread and QCommandInterpreter instances are saved in a local cache and removed the next time run() is called.

toggle_and_rerun()[source]

Remove the old thread and command, mark that the command is not running and emit the run_signal signal

class vdat.gui.queue.QCommandInterpreter(*args, **kwargs)[source]

Bases: vdat.command_interpreter.core.CommandInterpreter, PyQt5.QtCore.QObject

Create a QObject from the CommandInterpreter.

Reimplement the make_signals() to use only the command_logger signals from the command_interpreter and use Signal for the other signals

Custom signals
Name Signature Description
command_done bool these five signals are a Qt re-implementation of the signals described in the signals
command_string int, str  
global_logger int, str  
n_primaries int  
progress int, int, int, int  
finished   emitted when the run is finished
Custom slot
Name Signature Description
run()   Run the command
Parameters:
parent : PyQt5.QtWidgets.QWidget instance

the parent widget

args, kwargs:

passed to the CommandInterpreter

command_done
command_string
global_logger
n_primaries
progress
finished
make_signals()[source]

Use Signals instead of vdat.command_interpreter.signals, except for the command_logger one

connect_signals()[source]
disconnect_signals()[source]
run()[source]

Transform the method to a Slot

class vdat.gui.queue.QueuAction(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QAction

Action for the queue window.

Create the menu entry and binds signals known by the queue window to show/hide it

Custom slot
Name Signature Description
update_text() bool change the text to show in the action item
Connections between custom signals and/or slots
Signal Slot/Signal
toggled update_text()
Queue.closeSignal toggle()
toggled Queue.toggle()
Parameters:
*args, **kargs:

arguments passed to the parent class

connect_with_queue()[source]

Connect with signals and slots in Queue

update_text(toggled)[source]

Update the text in the action when the queue window is opened or closed

Parameters:
toggled : bool

whether is checked or not

vdat.gui.queue.set_queue(parent=None)[source]

Create a Queue instance and save it. You can access it with get_queue()

Parameters:
parent : PyQt5.QtWidgets.QWidget instance

the parent widget

vdat.gui.queue.get_queue()[source]

Get the locally stored Queue instance