How to use the ginga.GingaPlugin function in ginga

To help you get started, we’ve selected a few ginga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ejeschke / ginga / ginga / gtk3w / plugins / WBrowser.py View on Github external
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
from gi.repository import Gtk

from ginga import GingaPlugin

has_webkit = False
try:
    from gi.repository import WebKit
    has_webkit = True
except ImportError:
    pass


class WBrowser(GingaPlugin.GlobalPlugin):

    def __init__(self, fv):
        # superclass defines some variables for us, like logger
        super(WBrowser, self).__init__(fv)

        self.browser = None

    def build_gui(self, container):
        if not has_webkit:
            self.browser = Gtk.Label("Please install the python-webkit "
                                     "package to enable this plugin")
        else:
            self.browser = WebKit.WebView()

        sw = Gtk.ScrolledWindow()
        sw.set_border_width(2)
github ejeschke / ginga / ginga / gtkw / plugins / Contents.py View on Github external
#
# Contents.py -- Table of Contents plugin for fits viewer
#
# Eric Jeschke (eric@naoj.org)
#
# Copyright (c) Eric R. Jeschke.  All rights reserved.
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
from ginga import GingaPlugin
from ginga.misc import Bunch, Future

import gtk
import time

class Contents(GingaPlugin.GlobalPlugin):

    def __init__(self, fv):
        # superclass defines some variables for us, like logger
        super(Contents, self).__init__(fv)

        columns = [ ('Name', 'NAME'), ('Object', 'OBJECT'),
                    ('Date', 'DATE-OBS'), ('Time UT', 'UT'),
                     ]

        prefs = self.fv.get_preferences()
        self.settings = prefs.createCategory('plugin_Contents')
        self.settings.addDefaults(columns=columns, always_expand=True)
        self.settings.load(onError='silent')

        # For table-of-contents pane
        self.nameDict = Bunch.caselessDict()
github ejeschke / ginga / ginga / gtkw / plugins / Drawing.py View on Github external
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
import gtk
from ginga.gtkw import GtkHelp

from ginga.gtkw import ImageViewCanvasTypesGtk as CanvasTypes
from ginga import GingaPlugin
from ginga import colors

draw_colors = colors.get_colors()

default_drawtype = 'point'
default_drawcolor = 'blue'

class Drawing(GingaPlugin.LocalPlugin):

    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(Drawing, self).__init__(fv, fitsimage)

        self.layertag = 'drawing-canvas'

        canvas = CanvasTypes.DrawingCanvas()
        canvas.enable_draw(True)
        canvas.set_drawtype('point', color='cyan')
        canvas.set_callback('draw-event', self.draw_cb)
        canvas.setSurface(self.fitsimage)
        self.canvas = canvas

        self.w = None
        self.drawtypes = canvas.get_drawtypes()
github ejeschke / ginga / ginga / rv / plugins / Mosaic.py View on Github external
import time
from datetime import datetime
import threading

import numpy as np

from ginga.AstroImage import AstroImage
from ginga.util import wcs, iqcalc, dp, io_fits, mosaic
from ginga import GingaPlugin
from ginga.gw import Widgets


__all__ = ['Mosaic']


class Mosaic(GingaPlugin.LocalPlugin):

    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(Mosaic, self).__init__(fv, fitsimage)

        self.mosaic_count = 0
        self.img_mosaic = None
        self.bg_ref = 0.0

        self.ev_intr = threading.Event()
        self.lock = threading.RLock()
        self.read_elapsed = 0.0
        self.process_elapsed = 0.0
        self.ingest_count = 0
        # holds processed images to be inserted into mosaic image
        self.images = []
github ejeschke / ginga / ginga / gtkw / plugins / Errors.py View on Github external
#
# Errors.py -- Error reporting plugin for fits viewer
# 
# Eric Jeschke (eric@naoj.org)
#
# Copyright (c) Eric R. Jeschke.  All rights reserved.
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
import time

from ginga import GingaPlugin

import gtk

class Errors(GingaPlugin.GlobalPlugin):

    def __init__(self, fv):
        # superclass defines some variables for us, like logger
        super(Errors, self).__init__(fv)


    def build_gui(self, container):
        self.msgFont = self.fv.getFont("fixedFont", 12)

        self.msgList = gtk.VBox(spacing=2)
        
        sw = gtk.ScrolledWindow()
        sw.set_border_width(2)
        sw.set_policy(gtk.POLICY_AUTOMATIC,
                      gtk.POLICY_AUTOMATIC)
        sw.add_with_viewport(self.msgList)
github ejeschke / ginga / ginga / gtkw / plugins / MultiDim.py View on Github external
# MultiDim.py -- Multidimensional plugin for fits viewer
# 
# Eric Jeschke (eric@naoj.org)
#
# Copyright (c)  Eric R. Jeschke.  All rights reserved.
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
from ginga.gtkw import GtkHelp, gtksel
import gtk

from ginga import AstroImage
from ginga.util import wcs
from ginga import GingaPlugin

class MultiDim(GingaPlugin.LocalPlugin):

    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(MultiDim, self).__init__(fv, fitsimage)

        self.curhdu = 0
        self.naxispath = []

    def build_gui(self, container):
        vbox1 = gtk.VBox()

        self.msgFont = self.fv.getFont("sansFont", 14)
        tw = gtk.TextView()
        tw.set_wrap_mode(gtk.WRAP_WORD)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
github ejeschke / ginga / ginga / examples / reference-viewer / MyGlobalPlugin.py View on Github external
"""
Skeleton example of a Ginga global plugin called 'MyGlobalPlugin'

To enable it, run ginga with the command
    $ ginga --modules=MyLocalPlugin

it should become active in the right panel.
"""

from ginga import GingaPlugin
from ginga.gw import Widgets

# import any other modules you want here--it's a python world!


class MyGlobalPlugin(GingaPlugin.GlobalPlugin):

    def __init__(self, fv):
        """
        This method is called when the plugin is loaded for the  first
        time.  ``fv`` is a reference to the Ginga (reference viewer) shell.

        You need to call the superclass initializer and then do any local
        initialization.
        """
        super(MyGlobalPlugin, self).__init__(fv)

        # Your initialization here

        # Create some variables to keep track of what is happening
        # with which channel
        self.active = None
github ejeschke / ginga / ginga / rv / plugins / ScreenShot.py View on Github external
"""
import os.path
import shutil
import tempfile
import math

from ginga import GingaPlugin
from ginga.gw import Widgets, Viewers
from ginga.pilw.ImageViewPil import CanvasView
from ginga.util import io_rgb

__all__ = ['ScreenShot']


class ScreenShot(GingaPlugin.LocalPlugin):

    def __init__(self, fv, fitsimage):
        # superclass defines some variables for us, like logger
        super(ScreenShot, self).__init__(fv, fitsimage)

        self.tosave_type = 'png'
        self.saved_type = None
        self.savetypes = ('png', 'jpeg')
        self.tmpname = os.path.join(tempfile.tempdir, "__snap")
        self.save_path = ''
        self.save_name = ''

        self._wd = 200
        self._ht = 200
        self._split_sizes = [500, 400]
github ejeschke / ginga / ginga / rv / plugins / RC.py View on Github external
import bz2
from io import BytesIO

import numpy as np

from ginga import GingaPlugin
from ginga import AstroImage
from ginga.gw import Widgets
from ginga.util import grc

__all__ = ['RC']

help_msg = sys.modules[__name__].__doc__


class RC(GingaPlugin.GlobalPlugin):

    def __init__(self, fv):
        # superclass defines some variables for us, like logger
        super(RC, self).__init__(fv)

        # What port to listen for requests
        self.port = 9000
        # If blank, listens on all interfaces
        self.host = 'localhost'

        # this will hold the remote object
        self.robj = None
        # this will hold the remote object server
        self.server = None

        self.ev_quit = fv.ev_quit
github ejeschke / ginga / ginga / rv / plugins / Thumbs.py View on Github external
import threading
import bisect

from ginga import GingaPlugin
from ginga import RGBImage
from ginga.misc import Bunch
from ginga.util import iohelper
from ginga.gw import Widgets, Viewers
from ginga.util.paths import icondir
from ginga.pilw.ImageViewPil import CanvasView
from ginga.util import io_rgb

__all__ = ['Thumbs']


class Thumbs(GingaPlugin.GlobalPlugin):

    def __init__(self, fv):
        # superclass defines some variables for us, like logger
        super(Thumbs, self).__init__(fv)

        # For thumbnail pane
        self.thumblock = threading.RLock()
        self.thumb_dict = {}
        self.thumb_list = []
        self.thumb_num_cols = 1
        self._wd = 300
        self._ht = 400
        self._cmxoff = 0
        self._cmyoff = 0
        self._displayed_thumb_dict = {}
        tt_keywords = ['OBJECT', 'FRAMEID', 'UT', 'DATE-OBS']