diff options
-rw-r--r-- | Widgets.py | 73 |
1 files changed, 34 insertions, 39 deletions
@@ -11,14 +11,13 @@ from gi.repository import Gtk, Gdk, GObject, GdkPixbuf import Globals as G class Button(Gtk.EventBox): - __gsignals__ = {"clicked":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, ))} + __gsignals__ = {"clicked":(GObject.SIGNAL_RUN_FIRST, + GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, ))} def __init__(self): Gtk.EventBox.__init__(self) self.set_visible_window(True) self.set_border_width(1) - #self.add_events(Gdk.BUTTON_PRESS_MASK | Gdk.BUTTON_RELEASE_MASK | Gdk.POINTER_MOTION_MASK | - # Gdk.ENTER_NOTIFY_MASK | Gdk.LEAVE_NOTIFY_MASK) self.connect("button_press_event", self.button_press) self.connect("button_release_event", self.button_release) self.connect("enter-notify-event", self.enter_notify_event) @@ -83,14 +82,20 @@ class TablaPeriodica(Gtk.EventBox): def __init__(self): Gtk.EventBox.__init__(self) self.set_visible_window(True) - #self.modify_bg(0, G.FONDO3) - self.tabla = None + self.tabla = Tabla() + self.add(self.tabla) + self.show_all() + +class Tabla(Gtk.Table): + def __init__(self): + Gtk.Table.__init__(self, rows = 10, columns = 19, homogeneous = True) + self.set_row_spacing(7, 5) self.filasdeelementos = None self.set_layout() self.show_all() - + self.connect("draw", self.re_paint) + def set_layout(self): - self.tabla = Tabla() # Cabecera for x in range(1,19): button = Button() @@ -99,27 +104,16 @@ class TablaPeriodica(Gtk.EventBox): button.clickedcolor = G.BLANCO button.modify_bg(0, button.normalcolor) button.add(Gtk.Label(x)) - self.tabla.attach(button, x, x+1, 0, 1) - ''' - self.tabla.attach(button, x, x+1, 0, 1, - xoptions=Gtk.EXPAND|Gtk.FILL, - yoptions=Gtk.EXPAND|Gtk.FILL, - xpadding=0, ypadding=0)''' + self.attach(button, x, x+1, 0, 1) - for x in range(1,10): + for x in range(1, 8): button = Button() button.normalcolor = G.BLANCO button.selectlocor = G.BLANCO button.clickedcolor = G.BLANCO button.modify_bg(0, button.normalcolor) button.add(Gtk.Label(x)) - self.tabla.attach(button, 0, 1, x, x+1) - ''' - self.tabla.attach(button, 0, 1, x, x+1, - xoptions=Gtk.EXPAND|Gtk.FILL, - yoptions=Gtk.EXPAND|Gtk.FILL, - xpadding=0, ypadding=0)''' - self.add(self.tabla) + self.attach(button, 0, 1, x, x+1) estructura = G.INDICEELEMENTOS elementos = G.ELEMENTOS @@ -143,12 +137,7 @@ class TablaPeriodica(Gtk.EventBox): for boton in line: col = line.index(boton)+1 if boton != None: - self.tabla.attach(boton, col, col+1, row, row+1) - ''' - self.tabla.attach(boton, col, col+1, row, row+1, - xoptions=Gtk.EXPAND|Gtk.FILL, - yoptions=Gtk.EXPAND|Gtk.FILL, - xpadding=0, ypadding=0)''' + self.attach(boton, col, col+1, row, row+1) def set_colores(self, boton): for elemen in G.COLORS: @@ -157,18 +146,9 @@ class TablaPeriodica(Gtk.EventBox): boton.normalcolor = color boton.modify_bg(0, boton.normalcolor) -class Tabla(Gtk.Table): - def __init__(self): - Gtk.Table.__init__(self, rows = 10, columns = 19, homogeneous = True) - self.set_row_spacing(7, 5) - self.show_all() - - self.connect("draw", self.re_paint) - def re_paint(self, widget, context): rect = widget.get_allocation() - x, y = (rect.x, rect.y) - w, h = (rect.width, rect.height) + x, y, w, h = (rect.x, rect.y, rect.width, rect.height) linear = cairo.LinearGradient(x,y,w,h) linear.add_color_stop_rgba(0.00, 1, 1, 1, 1.0) @@ -177,9 +157,24 @@ class Tabla(Gtk.Table): context.rectangle(x, y, w, h) context.set_source(linear) context.fill() - + + rect = self.filasdeelementos[4][2].get_allocation() + x = rect.x + rect = self.filasdeelementos[0][0].get_allocation() + y = rect.y + rect = self.filasdeelementos[4][11].get_allocation() + margen = rect.width/3 + w = rect.x + rect.width - x + margen + h = rect.height*3 + x, y, w, h = (x+margen, y+margen, w-margen*3, h - margen) + + context.rectangle (x, y, w, h) + context.set_source_rgba (1, 1, 1, 0.3) + context.fill () + class Toolbar1(Gtk.Toolbar): - __gsignals__ = {"clicked":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING, ))} + __gsignals__ = {"clicked":(GObject.SIGNAL_RUN_FIRST, + GObject.TYPE_NONE, (GObject.TYPE_STRING, ))} def __init__(self): Gtk.Toolbar.__init__(self) self.modify_bg(0, G.NEGRO) |