/usr/lib/python3/dist-packages/ginga/rv/plugins/Blink.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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | #
# Blink.py -- Blink plugin for Ginga reference viewer
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
from ginga import GingaPlugin
from ginga.gw import Widgets
class Blink(GingaPlugin.LocalPlugin):
def __init__(self, fv, fitsimage):
# superclass defines some variables for us, like logger
super(Blink, self).__init__(fv, fitsimage)
self.interval = 1.0
self.blink_timer = fv.get_timer()
self.blink_timer.set_callback('expired', self._blink_timer_cb)
prefs = self.fv.get_preferences()
self.settings = prefs.createCategory('plugin_Blink')
self.settings.addDefaults(blink_channels=False)
self.settings.load(onError='silent')
self.blink_channels = self.settings.get('blink_channels', False)
def build_gui(self, container):
top = Widgets.VBox()
top.set_border_width(4)
vbox, sw, orientation = Widgets.get_oriented_box(container)
vbox.set_border_width(4)
vbox.set_spacing(2)
self.msg_font = self.fv.get_font("sansFont", 12)
tw = Widgets.TextArea(wrap=True, editable=False)
tw.set_font(self.msg_font)
self.tw = tw
fr = Widgets.Expander("Instructions")
fr.set_widget(tw)
vbox.add_widget(fr, stretch=0)
fr = Widgets.Frame("Blink")
vbox2 = Widgets.VBox()
captions = (("Interval:", 'label', 'Interval', 'entry',
"Start Blink", 'button', "Stop Blink", 'button'),
)
w, b = Widgets.build_info(captions, orientation=orientation)
self.w = b
b.interval.set_text(str(self.interval))
b.interval.add_callback('activated', lambda w: self._set_interval_cb())
b.interval.set_tooltip("Interval in seconds between changing images")
b.start_blink.add_callback('activated',
lambda w: self._start_blink_cb())
b.stop_blink.add_callback('activated',
lambda w: self._stop_blink_cb())
vbox2.add_widget(w, stretch=0)
hbox = Widgets.HBox()
btn1 = Widgets.RadioButton("Blink channels")
btn1.add_callback('activated',
lambda w, tf: self._set_blink_mode_cb(tf == True))
btn1.set_tooltip("Choose this to blink across channels")
btn1.set_state(self.blink_channels)
self.w.blink_channels = btn1
hbox.add_widget(btn1)
btn2 = Widgets.RadioButton("Blink images in channel", group=btn1)
btn2.set_state(not self.blink_channels)
btn2.add_callback('activated',
lambda w, tf: self._set_blink_mode_cb(tf == False))
btn2.set_tooltip("Choose this to blink images within a channel")
self.w.blink_within = btn2
hbox.add_widget(btn2)
hbox.add_widget(Widgets.Label(''), stretch=1)
vbox2.add_widget(hbox, stretch=0)
fr.set_widget(vbox2)
vbox.add_widget(fr, stretch=0)
spacer = Widgets.Label('')
vbox.add_widget(spacer, stretch=1)
top.add_widget(sw, stretch=1)
btns = Widgets.HBox()
btns.set_spacing(3)
btn = Widgets.Button("Close")
btn.add_callback('activated', lambda w: self.close())
btns.add_widget(btn, stretch=0)
btns.add_widget(Widgets.Label(''), stretch=1)
top.add_widget(btns, stretch=0)
container.add_widget(top, stretch=1)
def close(self):
self.fv.stop_local_plugin(self.chname, str(self))
return True
def instructions(self):
self.tw.set_text("""Blink the images in this channel.
Only images loaded in memory will be cycled.""")
def start(self):
self.instructions()
self.resume()
def pause(self):
self.stop_blinking()
def resume(self):
self.start_blinking()
def stop(self):
self.stop_blinking()
def redo(self):
pass
def _blink_timer_cb(self, timer):
# set timer
if self.blink_channels:
self.fv.gui_do(self.fv.next_channel)
else:
self.fv.gui_do(self.fv.next_img, loop=True)
timer.set(self.interval)
def start_blinking(self):
self.blink_timer.set(self.interval)
def stop_blinking(self):
self.blink_timer.clear()
def _start_blink_cb(self):
self._set_interval_cb()
self.start_blinking()
def _stop_blink_cb(self):
self.stop_blinking()
def _set_interval_cb(self):
interval = float(self.w.interval.get_text())
self.interval = max(min(interval, 30.0), 0.25)
self.stop_blinking()
self.start_blinking()
def _set_blink_mode_cb(self, tf):
self.blink_channels = tf
def __str__(self):
return 'blink'
#END
|