sábado, 14 de noviembre de 2020

Ventana de Dialogos con Python

 

import tkinter as tk
from tkinter import ttk

class Aplicacion:

    def __init__(self):
        self.ventana1=tk.Tk()
        self.ventana1.title("Dialogos")
        self.agregar_menu()
        self.ventana1.mainloop()

    def agregar_menu(self):
        self.menubar1 = tk.Menu(self.ventana1)
        self.ventana1.config(menu=self.menubar1)
        self.opciones1 = tk.Menu(self.menubar1, tearoff=0)
        self.opciones1.add_command(label="Configurar ventana"command=self.configurar)
        self.menubar1.add_cascade(label="Opciones"menu=self.opciones1)    

    def configurar(self):
        dialogo1 = DialogoTamano(self.ventana1)
        s=dialogo1.mostrar()
        self.ventana1.geometry(s[0]+"x"+s[1])
        

class DialogoTamano:

    def __init__(selfventanaprincipal):
        self.dialogo=tk.Toplevel(ventanaprincipal)
        self.label1=ttk.Label(self.dialogo, text="Ingrese ancho:")
        self.label1.grid(column=0row=0padx=5pady=5)
        self.dato1=tk.StringVar()
        self.entry1=ttk.Entry(self.dialogo, textvariable=self.dato1)
        self.entry1.grid(column=1row=0padx=5pady=5)
        self.entry1.focus()
        self.label2=ttk.Label(self.dialogo, text="Ingrese alto:")
        self.label2.grid(column=0row=1padx=5pady=5)
        self.dato2=tk.StringVar()
        self.entry2=ttk.Entry(self.dialogo, textvariable=self.dato2)
        self.entry2.grid(column=1row=1padx=5pady=5)
        self.boton1=ttk.Button(self.dialogo, text="Confirmar"command=self.confirmar)
        self.boton1.grid(column=1row=2padx=5pady=5)
        self.dialogo.protocol("WM_DELETE_WINDOW"self.confirmar)
        self.dialogo.resizable(0,0)
        self.dialogo.grab_set()

    def mostrar(self):
        self.dialogo.wait_window()
        return (self.dato1.get(), self.dato2.get())

    def confirmar(self):
        self.dialogo.destroy()


aplicacion1=Aplicacion() 

Hallar las raizes de Cualquier Ecuacion con Excel 365

  Se establece un intervalo de x de -20 a 20 para hallar los f(x) que cambian de signo, X aumenta en 1.   Se halla el cambio de signo de f(x...