Advertisement
Guest User

Ajuda_Berbardo.py

a guest
May 6th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. import wx
  2.  
  3. class Form1(wx.Panel):
  4.     def __init__(self, parent, id):
  5.         wx.Panel.__init__(self, parent, id)
  6.  
  7.         self.button =wx.Button(self, 10, "MULTIPLICA", wx.Point(20,10))
  8.         wx.EVT_BUTTON(self, 10, self.OnClick)
  9.  
  10.         self.button =wx.Button(self, 20, "SOMA", wx.Point(20,100))
  11.         wx.EVT_BUTTON(self, 20, self.OnClick)
  12.  
  13.     def OnClick(self, event):
  14.  
  15.         if event.GetId()==10: #Run import
  16.             a = 10
  17.             b = 20
  18.             return a*b
  19.  
  20.         if event.GetId()==20: #Run import
  21.             a = 10
  22.             b = 20
  23.             return a+b
  24.  
  25.  
  26.  
  27. if __name__ == "__main__":
  28.  
  29.     app = wx.PySimpleApp()
  30.     frame = wx.Frame(None, -1, "test GUI", pos=(0,0), size=(200,200))
  31.     Form1(frame,-1)
  32.     frame.Show(1)
  33.  
  34.     app.MainLoop()
  35.  
  36. import unittest
  37.  
  38. class teste(unittest.TestCase):
  39.     def test_Onclick():
  40.         form = Form1(<parent>, <id>)
  41.         resultado = form.OnClick(<event>)
  42.  
  43.         #Assim para id==10
  44.         self.assertEqual(resultado, <a*b>)
  45.  
  46.         #Assim para id==20
  47.         self.assertEqual(resultado, <a+b>)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement