Example #1
0
File: main.py Project: rocel/stage
 def __init__(self, parent=None): 
     frm = Frame(parent)
     frm.pack(fill=X)
     Button(frm, text='Save',  command=self.onSave).pack(side=LEFT)
     Button(frm, text='Cut',   command=self.onCut).pack(side=LEFT)
     Button(frm, text='Copy',   command=self.onCopy).pack(side=LEFT)
     Button(frm, text='Paste', command=self.onPaste).pack(side=LEFT)
     Button(frm, text='Find',  command=self.onFind).pack(side=LEFT)
     Quitter(frm).pack(side=LEFT)
     
     frm2 = Frame(parent)
     frm2.pack(side=LEFT,fill=Y)
     
     self.canvas = Canvas(parent, width=400, height=400,bg='white')
     self.canvas.pack(side='top', fill='both',expand='yes')
 
     Button(frm2, text='Imagem', command=self.onImage,width=7).grid(row=1,column=1)
     
     BtHandler = ButtonHandler(self.canvas)
     BtHandler.addBtDesign(Button(frm2, text='Desenhar',width=7))
     BtHandler.addBtText(Button(frm2, text='Escrever',width=7))
     BtHandler.addBtSelection(Button(frm2, text='Selecionar',width=7))
     BtHandler.addBtPaint(Button(frm2, text='Pintar',width=7))
     BtHandler.addBtOval(Button(frm2, text='Elipse',width=7))
     BtHandler.addBtRectangule(Button(frm2, text='Retângulo',width=7))
     BtHandler.addBtLine(Button(frm2, text='Reta',width=7))
 
     frmCores = Frame(parent)
     frmCores.pack(side=BOTTOM)
     BtHandler.addBtColors(frmCores)
     self.imagem = []
Example #2
0
 def test_Controlador(self):
     from controlador import ButtonHandler
     instancia = Tk()
     frm = Frame(instancia)
     canvas = Canvas(frm, width=400, height=400,bg='white')
     #addButton
     bhA = ButtonHandler(canvas)
     bhA.addBtColors(frm)
     self.assertEquals(bhA.botoesColors.__len__(),8) #it has instanciated all the 8 buttons
     
     #Design button
     bhD = ButtonHandler(canvas)
     bhD.addBtDesign(Button(frm, text='Desenhar',width=7))
     bhD.white(None)
     self.assertEquals(bhD.designer.CURRENT_COLOR,"white")
     #Writer button
     bhE = ButtonHandler(canvas)
     bhE.addBtText(Button(frm, text='Escrever',width=7))
     bhE.black(None)
     self.assertEquals(bhE.writer.CURRENT_COLOR,"black")
     #pintar button
     bhP = ButtonHandler(canvas)
     bhP.addBtPaint(Button(frm, text='Pintar',width=7))
     bhP.red(None)
     self.assertEquals(bhP.painter.CURRENT_COLOR,"red")
     #ellipse button
     bhEL = ButtonHandler(canvas)
     bhEL.addBtOval(Button(frm, text='Elipse',width=7))
     bhEL.green(None)
     self.assertEquals(bhEL.elipse.CURRENT_COLOR,"green")
     #rectangulo button
     bhR = ButtonHandler(canvas)
     bhR.addBtRectangule(Button(frm, text='Retangulo',width=7))
     bhR.blue(None)
     self.assertEquals(bhR.retangulo.CURRENT_COLOR,"blue")
     #other colors
     bhR.cyan(None)
     self.assertEquals(bhR.retangulo.CURRENT_COLOR,"cyan")
     bhR.yellow(None)
     self.assertEquals(bhR.retangulo.CURRENT_COLOR,"yellow")
     bhR.magenta(None)
     self.assertEquals(bhR.retangulo.CURRENT_COLOR,"magenta")
     
     #retiraEventos
     bhR.retiraEventos()
     #self.assertEquals(bhR.canvas.)
     
     #desabilitaBotoesbhR = ButtonHandler(canvas)
     butt = Button(frm, text='Retangulo',width=7)
     bhR.addBtRectangule(butt)
     bhR.desabilitaBotoes(butt)
     self.assertNotEqual(butt["relief"],Tkconstants.SUNKEN)
     self.assertEqual(butt["relief"],Tkconstants.RAISED)