def __init__(self, app, logger, timezone, color='lightgreen',
                 font='Liberation Sans', show_seconds=False):
        """Constructor for a clock object using a ginga canvas.
        """
        self.logger = logger

        if isinstance(timezone, Bunch):
            self.timezone = timezone.location
            self.tzinfo = tz.tzoffset(timezone.location, timezone.time_offset)
        else:
            self.timezone = timezone
            self.tzinfo = pytz.timezone(timezone)

        self.color = color
        self.font = font
        self.largesize = 72
        self.smallsize = 24
        self.show_seconds = show_seconds

        # now import our items
        from ginga.gw import Viewers

        fi = Viewers.CanvasView(logger=logger)
        fi.set_bg(0.2, 0.2, 0.2)
        self.viewer = fi
        fi.add_callback('configure', self.clock_resized_cb)

        # canvas that we will draw on
        self.canvas = fi.get_canvas()

        wd, ht = width, height
        if self.show_seconds:
            wd += 300

        fi.set_desired_size(wd, ht)
        iw = Viewers.GingaViewerWidget(viewer=fi)

        self.widget = iw

        self.clock_resized_cb(self.viewer, wd, ht)

        dt = datetime.utcnow().replace(tzinfo=pytz.utc)
        self.update_clock(dt)
def __init__ ( self , app , logger , timezone , color = 'lightgreen' , font = 'Liberation Sans' , show_seconds = False ) : self . logger = logger if isinstance ( timezone , Bunch ) : self . timezone = timezone . location self . tzinfo = tz . tzoffset ( timezone . location , timezone . time_offset ) else : self . timezone = timezone self . tzinfo = pytz . timezone ( timezone ) self . color = color self . font = font self . largesize = 72 self . smallsize = 24 self . show_seconds = show_seconds from ginga . gw import Viewers fi = Viewers . CanvasView ( logger = logger ) fi . set_bg ( 0.2 , 0.2 , 0.2 ) self . viewer = fi fi . add_callback ( 'configure' , self . clock_resized_cb ) self . canvas = fi . get_canvas ( ) wd , ht = width , height if self . show_seconds : wd += 300 fi . set_desired_size ( wd , ht ) iw = Viewers . GingaViewerWidget ( viewer = fi ) self . widget = iw self . clock_resized_cb ( self . viewer , wd , ht ) dt = datetime . utcnow ( ) . replace ( tzinfo = pytz . utc ) self . update_clock ( dt )
Constructor for a clock object using a ginga canvas.