import Tkinter
import tkMessageBox
class Interfaz2(Tkinter.Frame):
def __init__(self):
Tkinter.Frame.__init__(self)
self.pack(expand = Tkinter.YES, fill = Tkinter.BOTH)
self.master.title("Second App")
self.master.geometry("350x250")
self.nombre = Tkinter.StringVar()
self.sexo = Tkinter.StringVar()
self.opcion = Tkinter.IntVar()
self.lbNombre = Tkinter.Label(self,text = "Nombre:")
self.lbNombre.place(x = 20, y = 20, width = 80, height = 20)
self.entNombre = Tkinter.Entry(self,textvariable = self.nombre)
self.entNombre.place(x = 105, y = 20, width = 150, height = 20)
self.lbSexo = Tkinter.Label(self,text = "Sexo:")
self.lbSexo.place(x = 50, y = 40, width = 30, height = 80)
self.rbtnSexoM = Tkinter.Radiobutton(self.master, text = "Masculino", variable = self.opcion, value = 1)
self.rbtnSexoM.place(x = 20, y = 100, width = 180, height = 40)
self.rbtnSexoF = Tkinter.Radiobutton(self.master, text = "Femenino", variable = self.opcion, value = 2)
self.rbtnSexoF.place(x = 20, y = 130, width = 180, height = 40)
self.btnOk = Tkinter.Button(self, text = "Ok", command = self.Saludar)
self.btnOk.place(x =(350-80), y = 210, width = 60, height = 20)
self.master.mainloop()
def Saludar(self):
car = ""
if self.nombre.get() == "":
tkMessageBox.showinfo("Hey:", "Falta ingresar el nombre")
else:
if self.opcion.get() == 0:
tkMessageBox.showinfo("???" "Falto indicar su sex!")
else:
if self.opcion.get() == 1:
car = "o"
else:
car = "a"
tkMessageBox.showinfo("Hola!", self.nombre.get()+", Bienvenid" + car + "...")
def main():
app = Interfaz2()
main()