Created
April 30, 2013 13:48
-
-
Save daryo918/5488825 to your computer and use it in GitHub Desktop.
wx python calculadora
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import wx | |
class agenda(wx.Frame): | |
def __init__(self, parent, id, title): | |
wx.Frame.__init__(self, parent, id, title) | |
self.parent = parent | |
self.initialize() | |
def initialize(self): | |
grilla = wx.GridBagSizer() | |
self.texto = wx.TextCtrl(self,-1,value=u"#1") | |
self.texto2 = wx.TextCtrl(self,-1,value=u"#2") | |
boton1 = wx.Button(self,label="SUMA") | |
boton1.Bind(wx.EVT_BUTTON, self.sicliqueaboton1) | |
boton2 = wx.Button(self,label="RESTA") | |
boton2.Bind(wx.EVT_BUTTON, self.sicliqueaboton2) | |
boton3 = wx.Button(self,label="MULTIPLICACION") | |
boton3.Bind(wx.EVT_BUTTON, self.sicliqueaboton3) | |
boton4 = wx.Button(self,label="DIVISION") | |
boton4.Bind(wx.EVT_BUTTON, self.sicliqueaboton4) | |
self.label = wx.StaticText(self,-1,label=u"resultado:") | |
grilla.Add(self.texto,(0,1)) | |
grilla.Add(self.texto2,(0,2)) | |
grilla.Add(self.label,(0,3)) | |
grilla.Add(boton1,(1,1)) | |
grilla.Add(boton2,(1,4)) | |
grilla.Add(boton3,(1,2)) | |
grilla.Add(boton4,(1,3)) | |
grilla.AddGrowableCol(0) | |
self.SetSizerAndFit(grilla) | |
self.Show(True) | |
def sicliqueaboton1(self,event): | |
xd = int(self.texto.GetValue()) + int(self.texto2.GetValue()) | |
abu = "%i" % xd | |
self.label.SetLabel(abu) | |
def sicliqueaboton2(self,event): | |
xd = int(self.texto.GetValue()) - int(self.texto2.GetValue()) | |
abu = "%i" % xd | |
self.label.SetLabel(abu) | |
def sicliqueaboton3(self,event): | |
xd = int(self.texto.GetValue()) * int(self.texto2.GetValue()) | |
abu = "%i" % xd | |
self.label.SetLabel(abu) | |
def sicliqueaboton4(self,event): | |
xd = int(self.texto.GetValue()) / int(self.texto2.GetValue()) | |
abu = "%i" % xd | |
self.label.SetLabel(abu) | |
app = wx.App() | |
frame = agenda (None, -1, "calculadora by daryo") | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment