Python - Formulario con funciones matemáticas

 
Vista:
Imágen de perfil de Georgiana
Val: 5
Ha aumentado su posición en 566 puestos en Python (en relación al último mes)
Gráfica de Python

Formulario con funciones matemáticas

Publicado por Georgiana (1 intervención) el 20/06/2021 17:04:02
Buenas tardes,

Por favor, ¿pueden ayudarme integrar los siguientes requerimientos en mi código?

Mi código:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import tkinter as tk
window=tk.Tk()
window.title("Python es divertido")
window.geometry('500x700')
window.configure(background='DeepSkyBlue3')
 
image=tk.PhotoImage(file="cice_rgb_positivo_horizontal_ext.gif")
image=image.subsample(1,1)
label=tk.Label(image=image)
#label.place(x=0,y=0,relwidth=1.0,relheight=1.0)
label.pack()
 
element=tk.Label(window,text="Campo1: ",font="bold",bg="MediumBlue",fg="white")
element.pack(padx=5,pady=5,ipadx=5,ipady=5,fill=tk.X)
entry1=tk.Entry(window)
entry1.pack(fill=tk.X,padx=5,pady=5,ipadx=5,ipady=5)
 
element=tk.Label(window,text="Campo2: ",font="bold",bg="MediumBlue",fg="white")
element.pack(padx=5,pady=5,ipadx=5,ipady=5,fill=tk.X)
entry2=tk.Entry(window)
entry2.pack(fill=tk.X,padx=5,pady=5,ipadx=5,ipady=5)
 
element=tk.Label(window,text="Campo3: ",font="bold",bg="MediumBlue",fg="white")
element.pack(padx=5,pady=5,ipadx=5,ipady=5,fill=tk.X)
entry3=tk.Entry(window)
entry3.pack(fill=tk.X,padx=5,pady=5,ipadx=5,ipady=5)
 
window.mainloop()


Requerimientos:

- Debe presentar un formulario en pantalla con 3 cajas para inputs desde el teclado

Txtbox01: sustantivo

Txtbox02: adjetivo

Txtbox03: valor numerico

Al cumplimentar las 3 cajas debe presentar un texto concatenado dentro del propio formulario.

$sustantivo+$verbo+$adjetivo+calculo sobre (valor numerico) en formato %

$verbo debe escogerse de una lista incluida en el codigo de manera aleatoria.

El calculo puede estar hardcoded en el programa, pero debe invocar a una funcion matematica a eleccion.

Ej: ArrayVerbos("es","parece","se muestra") deberá escoger el elemento 1,2 ó 3 segun un patron aleatorio en cada ejecución.

Ejemplo:

Txtbox01: examen

Txtbox02: dificil

Txtbox03: 16

Debe devolver, por ejemplo, si se ha elegido la funcion math.sqrt() (raiz cuadrada)

"Examen parece dificil 4%"


Les agradecería una pequeña ayuda, muchas gracias!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
1
Responder
Imágen de perfil de Francisco Javier
Val: 249
Ha aumentado su posición en 29 puestos en Python (en relación al último mes)
Gráfica de Python

Formulario con funciones matemáticas

Publicado por Francisco Javier (311 intervenciones) el 22/06/2021 01:26:21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import tkinter as tk
import random
import math
from tkinter import messagebox
 
 
def mensaje():
    lista_verbos=["es","parece","se muestra"]
    verbo=random.choice(("es","parece","se muestra"))
    operacion=math.sqrt(int(e3.get()))
    p='{} {} {} {}%'.format(e1.get(),verbo,e2.get(),operacion)
    print(p)
    #e4.set(p)
    messagebox.showinfo(message="Mensaje", title="Título")
 
el mensaje final te lo da por consola, no se si lo prefieras en un Label, messagebox u entry. ya me dices.
Un saludo
 
 
 
window=tk.Tk()
window.title("Python es divertido")
window.geometry("280x310+0+0")
image=tk.PhotoImage(file="enigma.gif")
image=image.subsample(1,1)
label=tk.Label(image=image).pack()
global e1
global e2
global e3
global e4
 
e1=tk.StringVar()
e2=tk.StringVar()
e3=tk.StringVar()
e4=tk.StringVar()
 
element=tk.Label(window,text="Campo: ").pack()
entry1=tk.Entry(window,textvariable=e1).pack()
 
element2=tk.Label(window,text="Campo: ").pack()
entry2=tk.Entry(window,textvariable=e2).pack()
 
element3=tk.Label(window,text="Campo: ").pack()
entry3=tk.Entry(window,textvariable=e3).pack()
 
tk.Label(window).pack()
boton=tk.Button(window,text="Ok",borderwidth=3,width=8,command=mensaje).pack()
resultado=tk.Label(window,textvariable=e4).pack()
 
 
window.mainloop()
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar