Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/parentesis.activity/interfaz.py
blob: 07d3a98d228c58bf9cac4513ca2983206be918fb (plain)
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
#!/usr/bin/env python

# example-start buttons buttons.py

import pygtk
pygtk.require('2.0')
import gtk

# Crea un boton con un parentesis y le da comportamiento de alternar el 
parentesis
def crear_label_boton_paren(str):
    boton = gtk.Button()
    etiqueta  = gtk.Label(str)
    boton.add(etiqueta)
    
    etiqueta.show()
    boton.show()
    
    return boton

# Crea una label y la empaca en un boton
# and pack it into a button
def crear_label_boton(str):
    button = gtk.Button();
    etiqueta = gtk.Label(str)    
    button.add(etiqueta)
    etiqueta.show()
    button.show()
    
    return button

def devolver_par():
    return (3,4)
# Create a new hbox with an image and a label packed into it
# and return the box.
def xpm_label_box(parent, xpm_filename, label_text):
    # Create box for xpm and label
    box1 = gtk.HBox(False, 0)
    box1.set_border_width(2)

    # Now on to the image stuff
    image = gtk.Image()
    image.set_from_file(xpm_filename)

    # Create a label for the button
    label = gtk.Label(label_text)

    # Pack the pixmap and label into the box
    box1.pack_start(image, False, False, 3)
    box1.pack_start(label, False, False, 3)

    image.show()
    label.show()
    return box1



class Buttons:
    # Our usual callback method
    def callback(self, widget, data=None):
        print "Hello again - %s was pressed" % data

    def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.window.set_title("Image'd Buttons!")        
        self.window.connect("destroy", lambda wid: gtk.main_quit())
        self.window.connect("delete_event", lambda a1,a2:gtk.main_quit())
        self.window.set_border_width(10)

        cajaHorz = gtk.HBox(False, 0)
        
        etiqueta = gtk.Label("PARENTESIS")
        cajaVert = gtk.VBox(False, 0)
        cajaVert.pack_start(etiqueta, True, True, 0)

        cajaHor = gtk.HBox(False, 0)
        button = gtk.Button()    
        button.connect("clicked", self.callback, "cool button")

        self.listaBotones = []
        boton = crear_label_boton("(")
        
        
        cajaVert.pack_start(cajaHor, True, True, 0)
        # This calls our box creating function
        box1 = xpm_label_box(self.window, "info.xpm", "cool button")
        button.add(box1)
        cajaVert.pack_start(button, True, True, 0)
        cajaVert.show()

        box1.show()
        button.show()
        vscale = gtk.VScale(adjustment=None)
        hscale = gtk.HScale(adjustment=None)


        arrow = gtk.Arrow(gtk.ARROW_UP, gtk.SHADOW_IN)
        arrow.show()
        cajaVert.pack_start(arrow, True, True, 0)
        
        botonIgual = crear_label_boton("=")
        botonRes = crear_label_boton(str(eval("2+(3*4)+4") ) )
        #cajaHorz.pack_start(botonPar1, True, True, 0)
        #cajaHorz.pack_start(botonOprn1, True, True, 0)        
        #cajaHorz.pack_start(botonOprd1, True, True, 0)
        #cajaHorz.pack_start(botonOprn2, True, True, 0)
        #cajaHorz.pack_start(botonPar2, True, True, 0)
        print self.listaBotones
        cosita = botonRes.set_label("alfa")             
        print "la cista es", cosita
        for x in "2+(3*4)+4":           
            self.listaBotones.append(x)
            if x == "(" or x == ")":             
                boton = crear_label_boton(x)#crear_label_boton_paren(x)
                print x, "parentesis"
            else:
                boton = crear_label_boton(x)
                print x, "NO - parentesis"
            cajaHorz.pack_start(boton, True, True,0)    
        cajaHorz.pack_start(botonIgual, True, True, 0)
        cajaHorz.pack_start(botonRes, True, True, 0)


        cajaVert.pack_start(cajaHorz, True, True, 0)
        cajaHorz.show()
        cajaVert.show()
  #      self.window.add(hscale)
#        hscale.show()    
        

        etiqueta.show()
        self.window.add(cajaVert)
        self.window.show()

def main():  
    gtk.main()
    return 0     

if __name__ == "__main__":
    Buttons()
    main()