/usr/lib/python3/dist-packages/ginga/rv/plugins/Errors.py is in python3-ginga 2.6.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #
# Errors.py -- Error reporting plugin for fits viewer
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
import time
from ginga import GingaPlugin
from ginga.gw import Widgets
class Errors(GingaPlugin.GlobalPlugin):
def __init__(self, fv):
# superclass defines some variables for us, like logger
super(Errors, self).__init__(fv)
self.pending_errors = []
self.gui_up = False
def build_gui(self, container):
self.msg_font = self.fv.get_font("fixedFont", 10)
vbox = Widgets.VBox()
mlst = Widgets.VBox()
mlst.set_spacing(2)
self.msg_list = mlst
sw = Widgets.ScrollArea()
sw.set_widget(self.msg_list)
vbox.add_widget(sw, stretch=1)
hbox = Widgets.HBox()
btn = Widgets.Button("Remove All")
btn.add_callback('activated', lambda w: self.remove_all())
hbox.add_widget(btn, stretch=0)
hbox.add_widget(Widgets.Label(''), stretch=1)
vbox.add_widget(hbox, stretch=0)
container.add_widget(vbox, stretch=1)
self.gui_up = True
pending = self.pending_errors
self.pending_errors = []
for errmsg, ts in pending:
self.add_error(errmsg, ts=ts)
def add_error(self, errmsg, ts=None):
if ts is None:
# Add the time the error occurred
ts = time.strftime("%m/%d %H:%M:%S", time.localtime())
if not self.gui_up:
self.pending_errors.append((errmsg, ts))
return
vbox = Widgets.VBox()
hbox = Widgets.HBox()
# Add the time the error occurred
ts = time.strftime("%m/%d %H:%M:%S", time.localtime())
lbl = Widgets.Label(ts, halign='left')
hbox.add_widget(lbl, stretch=0)
hbox.add_widget(Widgets.Label(''), stretch=1)
vbox.add_widget(hbox, stretch=0)
tw = Widgets.TextArea(editable=False, wrap=False)
tw.set_font(self.msg_font)
tw.set_text(errmsg)
vbox.add_widget(tw, stretch=1)
hbox = Widgets.HBox()
btn = Widgets.Button("Remove")
btn.add_callback('activated', lambda w: self.remove_error(vbox))
hbox.add_widget(btn)
hbox.add_widget(Widgets.Label(''), stretch=1)
vbox.add_widget(hbox, stretch=0)
# special hack for Qt
vbox.cfg_expand(horizontal=1)
self.msg_list.add_widget(vbox, stretch=0)
# TODO: force scroll to bottom
def remove_error(self, child):
self.msg_list.remove(child)
def remove_all(self):
for child in list(self.msg_list.get_children()):
self.remove_error(child)
def __str__(self):
return 'errors'
#END
|