Example #1
0
def testEntLabList():
    #myEntLabList
    # ridefinisco la callback
    def on_activate(widg, ind, *data):
        print "b", "%05s" % widg.get_text(), ind, data

    # xBox, [xBox, [entr, call, labe]] * N
    obje, othe = myEntLabList(
        name=["One", "Two", "Three"],
        numb=6,
        call=on_activate,
        data=[],
        nLab=['Label01', 'Label02', 'Label03'],
        cLab="#333",
        tLab='h',
        aLab=[False, False, 1],
        tBox='v',
        aBox=[False, False, 1],
    )
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myEntLabList',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #2
0
def testChkButton():
    #myChkButton
    # ridefinisco la callback
    def on_clicked(widg, name, *data):
        ena = widg.get_active()
        print "b) %s is %s" % (name, ("OFF", "ON")[ena])

    # butt, call
    obje, othe = myChkButton(
        name='my_ChkButton',
        valu=True,
        colo='black',
        # call= on_clicked, data=['myCheck',])
        call=None,
        data=[
            'myCheck',
        ])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='prova',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, [othe])
    # <-
    return obj1
Example #3
0
def testButList():
    #myButList
    # ridefinisco la callback
    def on_clicked(widg, ind, *data):
        print "b", ind, data

    # xBox, [butt,call] * N
    obje, othe = myButList(name=["_Read", "_Write", "_Default"],
                           icon=Gtk.STOCK_NO,
                           call=on_clicked,
                           data=[],
                           tBox='v',
                           aBox=[False, False, 1])
    # abilito la vista dell'icona che di default รจ nascosta
    othe[0][0].set_always_show_image(True)
    othe[1][0].set_always_show_image(True)
    othe[2][0].set_always_show_image(True)
    # cambio icona ad alcuni bottoni
    othe[0][0].props.image = Gtk.Image.new_from_stock(Gtk.STOCK_YES,
                                                      Gtk.ICON_SIZE_BUTTON)
    othe[1][0].props.image = Gtk.Image.new_from_stock(Gtk.STOCK_STOP,
                                                      Gtk.ICON_SIZE_BUTTON)
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myButton',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #4
0
def testChkButLisLabel():
    #myChkButLisLabel
    # ridefinisco la callback
    def on_clicked(widg, ind, *data):
        ena = widg.get_active()
        #print "b", widg, ind, idata
        print "%05s" % widg.props.label.replace('_', ''), "is", ("OFF",
                                                                 "ON")[ena]

    # xBox, [labe, [butt, call] * N]
    obje, othe = myChkButLisLabel(name=["One", "Two", "Three"],
                                  valu=False,
                                  colo=None,
                                  call=on_clicked,
                                  data=[],
                                  nLab='Label',
                                  cLab=None,
                                  tBox='h',
                                  aBox=[False, False, 1])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myButton',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #5
0
def myLabFrame(name='myLabel', 
            leng=0, prea=' ', post='', 
            font='Curier 10', 
            colo=Gdk.color_parse('black'),
            nFra='Label', cFra='black', bFra=1, sFra=Gtk.SHADOW_ETCHED_OUT, 
            tFra='v', aFra=[False, False, 1]):
    """ crea una label con attributi stabilit
    
        -> name nome associato alla label
        -> leng lunghezza di formattazione
        -> prea preambolo di formattazione
        -> post post (aggiunto dopo la label)
        -> font font usato per il testo
        -> colo colore assegnato
        -> nFra nome del frame 
        -> cFra colore nome del frame 
        -> bFra bordo riservato all'esterno
        -> sFra tipo di cornice
        -> tFra tipo di contenitore v/h 
        -> aFra attributi del contenitore
    """
#myLabel
    # labe
    labe = myLabel(name=name, 
                   leng=leng, prea=prea, post=post, 
                   font=font, colo=colo)
#myFrame
    #fram, [labe, xBox]
    fram,othe = myFrame(nFra, labe, cFra, bFra, sFra, tFra, aFra)
    # <-
    #fram, [labe, lFrm, xBox]        
    return fram, [labe, othe[0], othe[1]]
Example #6
0
def myEntFrame(name='myText',
               numb=None,
               call=None,
               data=['dati'],
               nFra='Label',
               cFra='black',
               bFra=1,
               sFra=Gtk.SHADOW_ETCHED_OUT,
               tFra='v',
               aFra=[False, False, 1]):
    """ crea una entry text di una certa dimensione 'numb'
		con un testo di default 'text' inserita in un frame
		
		-> name testo da inserire nella entry
		-> call funzione da eseguire su evento
		-> data dati da passare alla funzione
		-> numb numero massimo di caratteri visibili 
		-> nFra nome del frame 
		-> cFra colore nome del frame 
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi del contenitore
	"""
    #myEntry
    entr, call = myEntry(name=name, numb=numb, call=call, data=data)
    #myFrame
    #fram, [labe, xBox]
    fram, othe = myFrame(nFra, entr, cFra, bFra, sFra, tFra, aFra)
    # <-
    #fram, [labe, xBox, entr, call]
    return fram, [othe[0], othe[1], entr, call]
Example #7
0
def testLabList():
    #myLabList
    # xBox, [labe, None] * N
    obje, othe = myLabList(name=["Read", "Write", "Default"],
                           leng=7,
                           prea=' ',
                           post=':',
                           font='Courier 10',
                           colo='brown',
                           tBox='v',
                           aBox=[False, False, 1])
    # cambio colore alla seconda label
    othe[1][0].modify_fg(Gtk.STATE_NORMAL, Gdk.color_parse("green"))
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myLabel',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #8
0
def testEntFraList(debu=0):
    #myEntFraList
    # ridefinisco la callback
    def on_activate(widg, ind, *data):
        print "b", "%05s" % widg.get_text(), ind, data

    # xBox, [fram, [labe, xBox, entr, call]] * N
    obje, othe = myEntFraList(name=["One", "Two", "Three"],
                              numb=None,
                              call=on_activate,
                              data=[],
                              nFra=['Label01', 'Label02', 'Label03'],
                              cFra='black',
                              bFra=1,
                              sFra=Gtk.SHADOW_ETCHED_OUT,
                              tFra='v',
                              aFra=[False, False, 1],
                              tBox='h',
                              aBox=[False, False, 1])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myEntryFrame',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #9
0
def testRadButton():
    #radButton
    # ridefinisco la callback
    def on_clicked(widg, *data):
        # descrivo solo quello attivato
        try:
            if widg.get_active():
                print data[0]
        except:
            pass

    # butt, call
    obje, othe = myRadButton(name='primo',
                             chil=None,
                             valu=False,
                             call=on_clicked,
                             data=[
                                 'myRadio',
                             ])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myRadioButton',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, [othe])
    # <-
    return obj1
Example #10
0
def myEntFrame(name='myText', 
			   numb=None,
			   call=None, data=['dati'],
			   nFra='Label', cFra='black', bFra=1, sFra=Gtk.SHADOW_ETCHED_OUT, 
			   tFra='v', aFra=[False, False, 1]):
	""" crea una entry text di una certa dimensione 'numb'
		con un testo di default 'text' inserita in un frame
		
		-> name testo da inserire nella entry
		-> call funzione da eseguire su evento
		-> data dati da passare alla funzione
		-> numb numero massimo di caratteri visibili 
		-> nFra nome del frame 
		-> cFra colore nome del frame 
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi del contenitore
	"""    
#myEntry
	entr,call = myEntry(name=name,
						numb=numb,
						call=call, data=data)
#myFrame
	#fram, [labe, xBox]
	fram,othe = myFrame(nFra, entr, cFra, bFra, sFra, tFra, aFra)
	# <-
	#fram, [labe, xBox, entr, call]        
	return fram, [othe[0], othe[1], entr, call]
Example #11
0
def testEntList():
    #myEntList
    # ridefinisco la callback
    def on_activate(widg, ind, *data):
        pass
        print "b", "%05s" % widg.get_text(), ind, data

    # xBox, [entr, call] * N
    obje, othe = myEntList(name=["One", "Two", "Three"],
                           numb=6,
                           call=on_activate,
                           data=[],
                           tBox='h',
                           aBox=[False, False, 1])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myEntry',
                         obje=obje,
                         colo="black",
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #12
0
def testButList():
#myButList    
	# ridefinisco la callback
	def on_clicked(widg, ind, *data):
		print "b", ind, data
	# xBox, [butt,call] * N
	obje, othe = myButList(name=["_Read","_Write","_Default"], 
						   icon=Gtk.STOCK_NO,
						   call=on_clicked, data=[],
						   tBox='v', aBox=[False, False, 1])
	# abilito la vista dell'icona che di default รจ nascosta
	othe[0][0].set_always_show_image (True)    
	othe[1][0].set_always_show_image (True)    
	othe[2][0].set_always_show_image (True)    
	# cambio icona ad alcuni bottoni
	othe[0][0].props.image = Gtk.Image.new_from_stock(Gtk.STOCK_YES, Gtk.ICON_SIZE_BUTTON)
	othe[1][0].props.image = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.ICON_SIZE_BUTTON)
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myButton', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #13
0
def testRadButList():
    #myRadButton
    # ridefinisco la callback
    def on_clicked(widg, ind, *data):
        ena = widg.get_active()
        if ena:
            print "b", "%05s" % widg.props.label.replace('_', ''),
            print ind, data

    # xBox, [butt,call] * N
    obje, othe = myRadButList(name=["One", "Two", "Three"],
                              chil=None,
                              valu=1,
                              call=on_clicked,
                              data=[],
                              tBox='h',
                              aBox=[False, False, 1])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='select',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #14
0
def testChkButList():
    #myChkButton
    # ridefinisco la callback
    def on_clicked1(widg, ind, *data):
        ena = widg.get_active()
        print "%05s" % widg.props.label.replace('_', ''), "is", ("OFF",
                                                                 "ON")[ena]

    # xBox, [butt, call] * N
    obje, othe = myChkButList(name=["Uno", "Due", "Tre"],
                              valu=False,
                              colo=None,
                              call=on_clicked1,
                              data=['uffi'],
                              tBox='h',
                              aBox=[False, False, 1])
    #myFrame
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myButton',
                         obje=obje,
                         colo='black',
                         bord=2,
                         shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v')
    #debug
    myViewObject(obje, othe)
    # <-
    return obj1
Example #15
0
def myButFrame(name='my_Button',
               nBut='myButton',
               icon=Gtk.STOCK_OK,
               call=None,
               data=['dati'],
               bFra=1,
               sFra=Gtk.SHADOW_ETCHED_OUT,
               tFra='v',
               aFra=[False, False, 1]):
    """ crea un bottone con associato una icona in un frame con etichetta
		alla premuta del bottone viene eseguita la funzione associata
	
		-> name nome associato al frame label
		-> nBut nome associato al button label
		-> icon tipo di icona associata
		-> call funzione da eseguire su evento
		-> data dati da passare alla funzione
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi del contenitore
	"""

    #callback debug
    def on_clicked(widg, *data):
        print "a", data
#button
# istanzio un bottone

    butt = Gtk.Button(stock=icon)
    # lo rendo visibile
    butt.show()
    # confermo l'immagine attuale
    butt.props.image = butt.get_image()
    # assegno il nome alla label del bottone
    butt.props.label = nBut
    #myFrame
    #fram, [labe, xBox]
    obje, othe = myFrame(name, butt, 'black', bFra, sFra, tFra, aFra)

    # in assenza di callback usa quella di debug
    if call == None:
        call = on_clicked
    butt.connect('clicked', call, *data)
    # <-
    #fram, [labe, xBox, butt, call]
    return obje, [othe[0], othe[1], butt, call]
Example #16
0
def testLabList():
#myLabList    
    # xBox, [labe, None] * N
    obje, othe = myLabList(name=["Read","Write","Default"], 
                           leng=7, prea=' ', post=':', 
                           font='Courier 10', 
                           colo='brown',
                           tBox='v', aBox=[False, False, 1])
    # cambio colore alla seconda label
    othe[1][0].modify_fg(Gtk.STATE_NORMAL, Gdk.color_parse("green"))
#myFrame    
    # fram,[labe,xBox]
    obj1, oth1 = myFrame(name='myLabel', obje=obje, colo='black',
                         bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
                         tBox='v' )
    #debug
    myViewObject(obje, othe)
# <-
    return obj1
Example #17
0
def myButFrame(name='my_Button',
			   nBut='myButton',  
			   icon=Gtk.STOCK_OK, 
			   call=None, data=['dati'],
			   bFra=1, sFra=Gtk.SHADOW_ETCHED_OUT, 
			   tFra='v', aFra=[False, False, 1]):
	""" crea un bottone con associato una icona in un frame con etichetta
		alla premuta del bottone viene eseguita la funzione associata
	
		-> name nome associato al frame label
		-> nBut nome associato al button label
		-> icon tipo di icona associata
		-> call funzione da eseguire su evento
		-> data dati da passare alla funzione
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi del contenitore
	"""
	#callback debug    
	def on_clicked(widg, *data):
		print "a", data
#button
	# istanzio un bottone
	butt = Gtk.Button(stock=icon)
	# lo rendo visibile
	butt.show()
	# confermo l'immagine attuale
	butt.props.image = butt.get_image()
	# assegno il nome alla label del bottone
	butt.props.label = nBut
#myFrame
	#fram, [labe, xBox]
	obje, othe = myFrame(name, butt, 'black', bFra, sFra, tFra, aFra)
	
	# in assenza di callback usa quella di debug
	if call == None:
		call = on_clicked
	butt.connect('clicked', call, *data)
# <-
	#fram, [labe, xBox, butt, call]        
	return obje, [othe[0], othe[1], butt, call]
Example #18
0
def testChkButList():
#myChkButton    
	# ridefinisco la callback
	def on_clicked1(widg, ind, *data):
		ena = widg.get_active()
		print "%05s" %widg.props.label.replace('_',''), "is", ("OFF", "ON")[ena]
	# xBox, [butt, call] * N
	obje, othe = myChkButList(name=["Uno","Due","Tre"], 
							  valu=False, colo=None, 
							  call=on_clicked1, data=['uffi'],
							  tBox='h', aBox=[False, False, 1])
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myButton', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #19
0
def testEntList():
#myEntList    
	# ridefinisco la callback
	def on_activate(widg, ind, *data):
		pass
		print "b", "%05s" %widg.get_text(), ind, data
	# xBox, [entr, call] * N
	obje, othe = myEntList(name=["One","Two","Three"], 
						   numb=6, 
						   call=on_activate, data=[],
						   tBox='h', aBox=[False, False, 1] )
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myEntry', obje=obje, colo="black",
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #20
0
def testChkButton():
#myChkButton
	# ridefinisco la callback        
	def on_clicked(widg, name, *data):
		ena = widg.get_active()
		print "b) %s is %s" % (name, ("OFF", "ON")[ena])
	# butt, call
	obje, othe = myChkButton(name='my_ChkButton', 
							 valu=True, colo='black', 
							# call= on_clicked, data=['myCheck',])
							 call= None, data=['myCheck',])
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='prova', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, [othe])
# <-
	return obj1
Example #21
0
def myLabFrame(name='myLabel',
               leng=0,
               prea=' ',
               post='',
               font='Curier 10',
               colo=Gdk.color_parse('black'),
               nFra='Label',
               cFra='black',
               bFra=1,
               sFra=Gtk.SHADOW_ETCHED_OUT,
               tFra='v',
               aFra=[False, False, 1]):
    """ crea una label con attributi stabilit
    
        -> name nome associato alla label
        -> leng lunghezza di formattazione
        -> prea preambolo di formattazione
        -> post post (aggiunto dopo la label)
        -> font font usato per il testo
        -> colo colore assegnato
        -> nFra nome del frame 
        -> cFra colore nome del frame 
        -> bFra bordo riservato all'esterno
        -> sFra tipo di cornice
        -> tFra tipo di contenitore v/h 
        -> aFra attributi del contenitore
    """
    #myLabel
    # labe
    labe = myLabel(name=name,
                   leng=leng,
                   prea=prea,
                   post=post,
                   font=font,
                   colo=colo)
    #myFrame
    #fram, [labe, xBox]
    fram, othe = myFrame(nFra, labe, cFra, bFra, sFra, tFra, aFra)
    # <-
    #fram, [labe, lFrm, xBox]
    return fram, [labe, othe[0], othe[1]]
Example #22
0
def testEntLabList():
#myEntLabList    
	# ridefinisco la callback
	def on_activate(widg, ind, *data):
		print "b", "%05s" %widg.get_text(), ind, data
	# xBox, [xBox, [entr, call, labe]] * N
	obje, othe = myEntLabList(name=["One","Two","Three"], 
							  numb=6, 
							  call=on_activate, data=[],
							  nLab=['Label01','Label02','Label03'], cLab="#333",
							  tLab='h', aLab=[False, False, 1],
							  tBox='v', aBox=[False, False, 1],)
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myEntLabList', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #23
0
def testRadButList():
#myRadButton    
	# ridefinisco la callback
	def on_clicked(widg, ind, *data):
		ena = widg.get_active()
		if ena:
			print "b", "%05s" %widg.props.label.replace('_',''), 
			print ind, data 
	# xBox, [butt,call] * N
	obje, othe = myRadButList(name=["One","Two","Three"], 
							  chil=None, valu=1, 
							  call=on_clicked, data=[],
							  tBox='h', aBox=[False, False, 1])
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='select', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #24
0
def testChkButLisLabel():
#myChkButLisLabel    
	# ridefinisco la callback
	def on_clicked(widg, ind, *data):
		ena = widg.get_active()
		#print "b", widg, ind, idata
		print "%05s" %widg.props.label.replace('_',''), "is", ("OFF", "ON")[ena]
	# xBox, [labe, [butt, call] * N]
	obje, othe = myChkButLisLabel(name=["One","Two","Three"], 
								  valu=False, colo=None, 
								  call=on_clicked, data=[],
								  nLab='Label', cLab=None,
								  tBox='h', aBox=[False, False, 1])
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myButton', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #25
0
def testEntFraList(debu=0):
#myEntFraList    
	# ridefinisco la callback
	def on_activate(widg, ind, *data):
		print "b", "%05s" %widg.get_text(), ind, data
	# xBox, [fram, [labe, xBox, entr, call]] * N        
	obje, othe = myEntFraList(name=["One","Two","Three"], 
							  numb=None, 
							  call=on_activate, data=[],
							  nFra=['Label01','Label02','Label03'],
							  cFra='black', 
							  bFra=1, sFra=Gtk.SHADOW_ETCHED_OUT, 
							  tFra='v', aFra=[False, False, 1],
							  tBox='h', aBox=[False, False, 1])
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myEntryFrame', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, othe)
# <-
	return obj1
Example #26
0
def testRadButton():
#radButton
	# ridefinisco la callback        
	def on_clicked(widg, *data):
		# descrivo solo quello attivato
		try:
			if widg.get_active():
				print data[0]
		except:
			pass
	# butt, call
	obje, othe = myRadButton(name='primo', 
							chil=None, valu=False, 
							call= on_clicked, data=['myRadio',])
#myFrame    
	# fram,[labe,xBox]
	obj1, oth1 = myFrame(name='myRadioButton', obje=obje, colo='black',
						 bord=2, shad=Gtk.SHADOW_ETCHED_OUT,
						 tBox='v' )
	#debug
	myViewObject(obje, [othe])
# <-
	return obj1
Example #27
0
def myTxtView(name='myTxtView',
              colo='black',
              widt=300,
              heig=70,
              font="courier 9",
              edit=False,
              left=1,
              righ=1,
              bord=3,
              bFra=1,
              sFra=Gtk.SHADOW_ETCHED_OUT,
              tFra='v',
              aFra=[False, False, 1]):
    """ crea una textView all'interno di un frame
		
		-> name nome assegnato alla label del Frame
		-> widt larghezza da assegnare allo Scrolled
		-> heig altezza da assegnare allo Scrolled
		-> font font da utilizzare
		-> edit abilta la modifica
		-> left margine sinistro sul textView
		-> righ margine destro sul textView
		-> bord margine esterno dello scroolbar
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi contenitore 
	"""
    #textBuffer
    buff = Gtk.TextBuffer()
    #textView
    # istanzio un TextView
    text = Gtk.TextView(buffer=buff)
    text.show()
    text.modify_font(Pango.FontDescription(font))
    text.set_property('can-focus', edit)
    text.set_editable(edit)
    text.set_cursor_visible(edit)
    # text.set_sensitive(edit)
    # text.set_overwrite (True)
    # text.set_wrap_mode(True)
    text.set_left_margin(left)
    text.set_right_margin(righ)
    #  blocca il size visibile con lo scroll
    #(width, higth)
    #text.set_size_request(100,100)
    #myScrolled
    scro = myScrolled(obje=text,
                      bord=bord,
                      widt=widt,
                      heig=heig,
                      shad=Gtk.SHADOW_ETCHED_IN,
                      poli=(Gtk.POLICY_AUTOMATIC, Gtk.POLICY_AUTOMATIC))
    #tag
    buff.create_tag("blaWhi", foreground="black", background="white")
    buff.create_tag("redWhi", foreground="red", background="white")
    buff.create_tag("greWhi", foreground="green", background="white")
    buff.create_tag("bluWhi", foreground="blue", background="white")
    buff.create_tag("redBla", foreground="red", background="black")
    buff.create_tag("whiBlu", foreground="white", background="blue")
    cTag = [
        "blaWhi",
    ]
    # curs = buff.get_end_iter()
    #myFrame
    # fram, [labe, xBox]
    fram, othe = myFrame(name=name,
                         obje=scro,
                         colo=colo,
                         bord=bFra,
                         shad=sFra,
                         tBox=tFra,
                         aBox=aFra)

    #callback
    def clear(*args):
        """ pulitura del textBuffer """
        sta, end = buff.get_bounds()
        buff.delete(sta, end)
        # curs = buff.get_end_iter()
    def read(*args):
        "funzione di lettura dell'intero buffer"
        sta, end = buff.get_bounds()
        return buff.get_text(sta, end)

    def write(*msg):
        "funzione di scrittura per il redirect"
        for ele in msg:
            if len(ele) > 0:
                writeTag(ele, cTag[0])

    def writeTag(str="", tag="blkWhi"):
        "inserisco la stringa nel buffer"
        #ite = curs
        ite = buff.get_end_iter()
        # printD("\nite: %d %d" %(ite.get_line(), ite.get_line_offset()))

        # inserisco testo con tag
        buff.insert_with_tags_by_name(ite, str, tag)
        # aggiorno lo scrollbar
        text.scroll_mark_onscreen(buff.get_insert())
        # risolve il bug della prima scrittura
        # text.grab_focus()

        if 0:
            if '\r' in str:
                ite.backward_line()

        # # aggiorno le linee acquisite
        # num = buff.get_line_count()
        # printD("%s(%d)" %(str, num), '')

    def test(*msg):
        # sovrascrittura del metodo per permettere la scrittura con i colori
        sys.stdout = write
        print "%s" % msg
        # torno al default
        sys.stdout = sys.__stdout__

    # def cursor(*args):
    # 	x, y = text.get_pointer()
    # 	printD("\na) %d %d" %(x,y))
    # 	x, y = text.window_to_buffer_coords(Gtk.TEXT_WINDOW_WIDGET, x, y)
    # 	printD("\nb) %d %d" %(x,y))
    # 	# if text.get_iter_at_location(x, y).has_tag(errTag):
    # 	# # Code here
# <-
#          0,   1,   2,   3,   4,    5,    6,       7
# fram,[labe,xBox,buff,text,cTag,clear,write,writeTag]
    return fram, [othe[0], othe[1], buff, text, cTag, clear, write,
                  writeTag]  #,cursor]
Example #28
0
def myButSwiFrame(name='myButSwitFrame',
                  icon=[Gtk.STOCK_NO, Gtk.STOCK_YES],
                  call=None,
                  data=[['dati 0'], ['dati 1']],
                  func=[None, None],
                  bFra=1,
                  sFra=Gtk.SHADOW_ETCHED_OUT,
                  tFra='h',
                  aFra=[False, False, 1]):
    """ crea un bottone con 2 stati all'interno di un frame,
		 ad ogni stato e' associata una icona
		 
		-> name nome associato alla label del frame
		-> icon tipo di icone associate
		-> call funzione da eseguire su evento
		-> data dati da passare alla funzione
		-> func funzioni associate allo stato dello switch
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi del contenitore
	"""

    #callback debug
    def on_clicked(widg, *data):
        "widg e' il riferimento dell'istanza"
        al = widg.get_children()[0]  # alignment
        hb = al.get_children()[0]  # hbox
        image, text = hb.get_children()
        # verifica dello stato in base alla icona attuale
        if image.get_stock()[0] == widg.icon[0]:
            # switch On
            widg.props.image = Gtk.Image.new_from_stock(
                widg.icon[1], Gtk.ICON_SIZE_BUTTON)
            if widg.func[0]:
                widg.func[0](*data[0])
            # update status
            widg.stat = 1
        else:
            # switch Off
            widg.props.image = Gtk.Image.new_from_stock(
                widg.icon[0], Gtk.ICON_SIZE_BUTTON)
            if widg.func[1]:
                widg.func[1](*data[1])
            # update status
            widg.stat = 0
#button
# istanzio un bottone

    butt = Gtk.Button(stock=icon[0])
    # reference icon
    butt.icon = icon
    # reference name
    butt.labe = name
    # reference function
    butt.func = func
    # reference status
    butt.stat = 0
    # lo rendo visibile
    butt.show()
    # elimino la label
    butt.props.image = butt.get_image()
    butt.props.label = ""
    #myFrame
    #fram,[labe,xBox]
    fram, othe = myFrame(name, butt, 'black', bFra, sFra, tFra, aFra)

    # in assenza di callback usa quella di debug
    if call == None:
        call = on_clicked
    # passo il riferimento dell'oggetto stesso "butt"
    butt.connect('clicked', call, *data)
    # <-
    #fram, [labe, xBox, butt, call]
    return fram, [othe[0], othe[1], butt, call]
Example #29
0
def myButSwiFrame(name='myButSwitFrame', 
				  icon=[Gtk.STOCK_NO, Gtk.STOCK_YES],
				  call=None, data=[['dati 0'],['dati 1']],
				  func=[None, None],
				  bFra=1, sFra=Gtk.SHADOW_ETCHED_OUT, 
				  tFra='h', aFra=[False, False, 1]):
	""" crea un bottone con 2 stati all'interno di un frame,
		 ad ogni stato e' associata una icona
		 
		-> name nome associato alla label del frame
		-> icon tipo di icone associate
		-> call funzione da eseguire su evento
		-> data dati da passare alla funzione
		-> func funzioni associate allo stato dello switch
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi del contenitore
	"""
	#callback debug    
	def on_clicked(widg, *data):
		"widg e' il riferimento dell'istanza"
		al = widg.get_children()[0] # alignment
		hb = al.get_children()[0]   # hbox
		image, text = hb.get_children()
		# verifica dello stato in base alla icona attuale
		if image.get_stock()[0] == widg.icon[0]:
			# switch On
			widg.props.image = Gtk.Image.new_from_stock(widg.icon[1], Gtk.ICON_SIZE_BUTTON)
			if widg.func[0]:
				widg.func[0](*data[0])
			# update status
			widg.stat = 1
		else:
			# switch Off
			widg.props.image = Gtk.Image.new_from_stock(widg.icon[0], Gtk.ICON_SIZE_BUTTON)
			if widg.func[1]:
				widg.func[1](*data[1])
			# update status
			widg.stat = 0
#button
	# istanzio un bottone
	butt = Gtk.Button(stock=icon[0])
	# reference icon
	butt.icon = icon
	# reference name
	butt.labe = name
	# reference function
	butt.func = func
	# reference status
	butt.stat = 0
	# lo rendo visibile
	butt.show()
	# elimino la label
	butt.props.image = butt.get_image()
	butt.props.label = ""
#myFrame
	#fram,[labe,xBox]
	fram,othe = myFrame(name, butt, 'black', bFra, sFra, tFra, aFra)

	# in assenza di callback usa quella di debug
	if call == None:
		call = on_clicked
	# passo il riferimento dell'oggetto stesso "butt"
	butt.connect('clicked', call, *data)
# <-        
	#fram, [labe, xBox, butt, call]        
	return fram, [othe[0], othe[1], butt, call]
Example #30
0
def myTxtView(name='myTxtView', colo='black',
					widt=300, heig=70, 
					font="courier 9", edit=False, 
					left=1, righ=1, bord=3,
					bFra=1, sFra=Gtk.SHADOW_ETCHED_OUT, 
					tFra='v', aFra=[False,False,1] ):
	""" crea una textView all'interno di un frame
		
		-> name nome assegnato alla label del Frame
		-> widt larghezza da assegnare allo Scrolled
		-> heig altezza da assegnare allo Scrolled
		-> font font da utilizzare
		-> edit abilta la modifica
		-> left margine sinistro sul textView
		-> righ margine destro sul textView
		-> bord margine esterno dello scroolbar
		-> bFra bordo riservato all'esterno
		-> sFra tipo di cornice
		-> tFra tipo di contenitore v/h 
		-> aFra attributi contenitore 
	"""
#textBuffer
	buff = Gtk.TextBuffer()
#textView
	# istanzio un TextView
	text = Gtk.TextView(buffer=buff)
	text.show()
	text.modify_font(Pango.FontDescription(font))
	text.set_property ('can-focus', edit)
	text.set_editable(edit)
	text.set_cursor_visible(edit)
	# text.set_sensitive(edit)
	# text.set_overwrite (True)
	# text.set_wrap_mode(True)
	text.set_left_margin(left)
	text.set_right_margin(righ)
	#  blocca il size visibile con lo scroll
	#(width, higth)
	#text.set_size_request(100,100)
#myScrolled
	scro = myScrolled(obje=text, bord=bord, 
					  widt=widt, heig=heig, 
					  shad=Gtk.SHADOW_ETCHED_IN, 
					  poli=(Gtk.POLICY_AUTOMATIC, Gtk.POLICY_AUTOMATIC))
#tag
	buff.create_tag("blaWhi",foreground="black",background="white")
	buff.create_tag("redWhi",foreground="red",background="white")
	buff.create_tag("greWhi",foreground="green",background="white")
	buff.create_tag("bluWhi",foreground="blue",background="white")
	buff.create_tag("redBla",foreground="red",background="black")
	buff.create_tag("whiBlu",foreground="white",background="blue")
	cTag = ["blaWhi",]
	# curs = buff.get_end_iter()
#myFrame
	# fram, [labe, xBox]
	fram, othe = myFrame(name=name, obje=scro, colo=colo, 
						 bord=bFra, shad=sFra, tBox=tFra, aBox=aFra)
#callback
	def clear(*args):
		""" pulitura del textBuffer """
		sta, end = buff.get_bounds()
		buff.delete(sta, end)
		# curs = buff.get_end_iter()
	def read(*args):
		"funzione di lettura dell'intero buffer"
		sta, end = buff.get_bounds()
		return buff.get_text(sta, end)
	def write(*msg):
		"funzione di scrittura per il redirect"
		for ele in msg:
			if len(ele) > 0:
				writeTag(ele, cTag[0])
	def writeTag(str="", tag="blkWhi"):
		"inserisco la stringa nel buffer"
		#ite = curs
		ite = buff.get_end_iter()
		# printD("\nite: %d %d" %(ite.get_line(), ite.get_line_offset()))

		# inserisco testo con tag
		buff.insert_with_tags_by_name(ite, str, tag)
		# aggiorno lo scrollbar
		text.scroll_mark_onscreen(buff.get_insert())
		# risolve il bug della prima scrittura
		# text.grab_focus()

		if 0:
			if '\r' in str:
				ite.backward_line()

		# # aggiorno le linee acquisite
		# num = buff.get_line_count()
		# printD("%s(%d)" %(str, num), '')

	def test(*msg):
		# sovrascrittura del metodo per permettere la scrittura con i colori
		sys.stdout = write
		print "%s" %msg
		# torno al default
		sys.stdout = sys.__stdout__

	# def cursor(*args):
	# 	x, y = text.get_pointer()
	# 	printD("\na) %d %d" %(x,y)) 
	# 	x, y = text.window_to_buffer_coords(Gtk.TEXT_WINDOW_WIDGET, x, y)
	# 	printD("\nb) %d %d" %(x,y)) 
	# 	# if text.get_iter_at_location(x, y).has_tag(errTag):
	# 	# # Code here
# <-
	#          0,   1,   2,   3,   4,    5,    6,       7 
	# fram,[labe,xBox,buff,text,cTag,clear,write,writeTag]
	return fram,[othe[0],othe[1],buff,text,cTag,clear,write,writeTag] #,cursor]