예제 #1
0
파일: version3.o.py 프로젝트: kcmia/sol-pc
from mis_inputs import inputFloat, fValue
from triangulo import Triangulo
import sys

if __name__ == "__main__":
    base = None
    altura = None
    if len(sys.argv) >= 2:
        base = fValue(sys.argv[1])
        if len(sys.argv) > 2:
            altura = fValue(sys.argv[2])

    if base == None:
        base = inputFloat("Introduce base: ", "base debe ser numérica")
    if altura == None:
        altura = inputFloat("Introduce altura: ", "altura debe ser numérica")

    t = Triangulo(base, altura)

    print("Area del triángulo: {:.2f}".format(t.area()))
예제 #2
0
from PySimpleGUI import PySimpleGUI as sg
from triangulo import Triangulo
import ast

sg.theme("darkgreen")

layout = [[sg.Text("Triangulo")],
          [sg.Text("Base: "),
           sg.Input(key='base', size='9')],
          [sg.Text("Altura: "),
           sg.Input(key='altura', size='9')],
          [sg.Button('Calcula'), sg.Button('sair')]]

window = sg.Window('Area do Triangulo', layout)

while True:
    event, value = window.read()
    if event == sg.WIN_CLOSED or event == 'sair':
        break
    if event == 'Calcula':
        base = ast.literal_eval(value['base'])
        altura = ast.literal_eval(value['altura'])
        tri = Triangulo(base, altura)
        calc = tri.area()
        sg.popup("A área do triângulo (base * altura) / 2 = " + str(calc),
                 title="Triangulo")
window.close()