2 # -*- coding: utf-8 -*-
3 # vim: set expandtab tabstop=4 shiftwidth=4 :
4 #----------------------------------------------------------------------------
6 #----------------------------------------------------------------------------
7 # This file is part of etherled.
9 # etherled is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the Free
11 # Software Foundation; either version 2 of the License, or (at your option)
14 # etherled is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 # You should have received a copy of the GNU General Public License along
20 # with etherled; if not, write to the Free Software Foundation, Inc., 59
21 # Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #----------------------------------------------------------------------------
23 # Creado: vie oct 27 23:36:22 ART 2005
24 # Autores: Leandro Lucarella <llucare@fi.uba.ar>
25 #----------------------------------------------------------------------------
29 class Led(gtk.DrawingArea):
30 def __init__(self, prendido=False, file_on='led-on.png',
31 file_off='led-off.png', width = 24, height = 24):
32 self.prendido = prendido
35 self.pixbuf_on = gtk.gdk.pixbuf_new_from_file(file_on)
36 self.pixbuf_off = gtk.gdk.pixbuf_new_from_file(file_off)
37 gtk.DrawingArea.__init__(self)
38 self.set_size_request(width, height)
39 self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
40 self.connect("expose-event", self.on_expose_event)
41 self.connect("button-press-event", self.on_button_press_event)
43 def on_expose_event(self, widget, event):
44 gc = self.style.fg_gc[gtk.STATE_NORMAL]
46 pixbuf = self.pixbuf_on
48 pixbuf = self.pixbuf_off
49 self.window.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0)
52 def on_button_press_event(self, widget, event):
53 self.prendido = not self.prendido