daplis_rtp.gui.tabs.base module

What the four plotting tabs do the same way.

Finding the newest data file, noticing when a new one lands, reporting a file that cannot be read, stopping cleanly when it goes wrong: each tab had its own copy of all four, and they had drifted. Only one of them guarded against the refresh firing again while one was still running, only one closed over the case of the directory disappearing mid-stream, and the three that showed an error box left the timer running behind it - so a modal box, which spins an event loop of its own, stacked a new box on top of itself every 100 ms until the stream was stopped by hand.

class daplis_rtp.gui.tabs.base.PlotTab(parent=None)[source]

Bases: TabShell

A tab with a plot, a folder of data files, and a live stream.

__init__(parent=None)[source]
bind_session()[source]

Register the controls this tab should remember.

build()[source]

Fill the shell. Every tab writes this and nothing else.

canvas_class = None
hint_text = ''
static last_data_file(path)[source]

The newest ‘.dat’ file in path, or None.

None covers both a directory with no data files in it and the files - or the directory itself - going away while the stream runs: glob lists the directory first and getctime is called on the result afterwards, so a file that disappears in between raises OSError rather than simply dropping out of the list.

no_data(message)[source]

There is nothing to read in the folder.

Silent while a stream is running, because that is the ordinary way a run begins: the stream is started first and the acquisition second, so the folder is empty for the first few seconds by design. Interrupting that with a message box - and stopping the stream to show it, as every error here must - meant the stream could not be armed before the data it was waiting for existed.

An explicit ‘Refresh plot’ is a different question, and gets a different answer: nothing there is exactly what the user asked about.

on_refresh_requested()[source]

Hook: what an explicit ‘look again’ re-arms.

on_session_restored()[source]

Hook: derive whatever the restored controls imply.

A control whose value the tab also keeps in a variable - a cycle length parsed out of a line edit - has to be re-read once the stored text is back in the widget.

on_stream_start()[source]

Hook: what this tab arms when a run starts.

on_stream_stop()[source]

Hook: what this tab stands down when a run ends.

on_waiting_for_data()[source]

Hook: say, quietly, that the folder is still empty.

plotted_data()[source]

The numbers behind the plot, for File -> Export.

Returns None when there is nothing to export, or a dict:

stem

A suggested file name, without an extension.

columns

Ordered {heading: 1-D array}; every column the same length.

notes

Lines describing where the numbers came from, written into the file as # comments so that a plot found on a disk six months later can still say what it was.

refresh()[source]

Read the newest file and redraw. Written by every tab.

report_error(text, details=None)[source]

Stop the stream, then say what went wrong.

In that order on purpose: a modal box runs an event loop of its own, so a stream left running would ask for refresh again behind it and stack a new box on top of this one for as long as it stayed open.

session_scope = ''
slot_refresh()[source]

Look again now, whether or not a stream is running.

start_stream()[source]
stop_stream()[source]
toggle_stream()[source]
update_time_stamp()[source]

One refresh, and never two at once.

Both the canvas redraw and a message box spin the event loop, so another refresh can be asked for while this call is still running; without the guard those calls stack up.

watched_paths()[source]

The folders a running stream should watch. Tabs override.