Inag28

AppMatematicas2

Nov 11th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.91 KB | None | 0 0
  1. import tkinter as tk                # python 3
  2. from tkinter import font  as tkfont
  3. from tkinter import *# python 3
  4.  
  5.  
  6.  
  7. class SampleApp(tk.Tk):
  8.  
  9.  
  10.     def __init__(self, *args, **kwargs):
  11.         tk.Tk.__init__(self, *args, **kwargs)
  12.  
  13.  
  14.         self.title_font = tkfont.Font(family='Helvetica', size=18, weight="bold", slant="italic")
  15.         self.nfont = tkfont.Font(family="Helvetica", size=15, slant="italic")
  16.         # the container is where we'll stack a bunch of frames
  17.         # on top of each other, then the one we want visible
  18.         # will be raised above the others
  19.         container = tk.Frame(self)
  20.         container.pack(side="top", fill="both", expand=True)
  21.         container.grid_rowconfigure(0, weight=1)
  22.         container.grid_columnconfigure(0, weight=1)
  23.  
  24.         self.frames = {}
  25.         for F in (StartPage, Page1, Page2, Page3, Page4, Page5, Page6, Page7, Page8, Page9, Page10, LastPage):
  26.             page_name = F.__name__
  27.             frame = F(parent=container, controller=self)
  28.             self.frames[page_name] = frame
  29.  
  30.             # put all of the pages in the same location;
  31.             # the one on the top of the stacking order
  32.             # will be the one that is visible.
  33.             frame.grid(row=0, column=0, sticky="nsew")
  34.  
  35.         self.show_frame("StartPage")
  36.  
  37.  
  38.  
  39.     def p1():
  40.  
  41.         global n
  42.         n = 1
  43.  
  44.  
  45.     def p2():
  46.  
  47.         global n
  48.         n = n + 2
  49.  
  50.  
  51.     def p3():
  52.  
  53.         global n
  54.         n = n + 4
  55.  
  56.     def p4():
  57.  
  58.         global n
  59.         n = n + 8
  60.  
  61.     def p5():
  62.  
  63.         global n
  64.         n = n + 16
  65.  
  66.  
  67.     def p6():
  68.  
  69.         global n
  70.         n = n + 32
  71.         print (n)
  72.  
  73.     def p7():
  74.  
  75.         global n
  76.         n = n +64
  77.  
  78.     def p8():
  79.  
  80.         global n
  81.         n = n + 128
  82.  
  83.  
  84.     def p9():
  85.  
  86.         global n
  87.         n = n+256
  88.  
  89.     def p10():
  90.  
  91.         global n
  92.         n = n + 512
  93.  
  94.     def show_frame(self, page_name):
  95.         '''Show a frame for the given page name'''
  96.         frame = self.frames[page_name]
  97.         frame.tkraise()
  98.  
  99. class StartPage(tk.Frame):
  100.  
  101.     def __init__(self, parent, controller):
  102.         # Definimos funciones básicas de la ventana
  103.         tk.Frame.__init__(self, parent)
  104.         self.controller = controller
  105.         self.configure(bg="black")
  106.         # Creamos y damos caracteristicas a los frames
  107.         titulo = tk.Label(self, bg="black", text="Bienvenidos...", fg= "white", font=controller.title_font)
  108.         instrucciones = tk.Label(self, bg="black", fg= "white", text="Instrucciones:", font=controller.title_font)
  109.         label = tk.Label(self, bg="black", fg= "white" , text="\nEste es un pequeño juego matemático que consiste en que tú piensas un número \nentre el 1 al 1023, y yo adivino cuál es.", font=controller.nfont)
  110.         label2 = tk.Label(self, bg="black", fg= "white", text="\nVas a pensar en un número antes de empezar. Al momento de que le des al botón, \nsaldrá una imagen con muuuchos números. No te asustes, los números están en orden. \nEs decir que si piensas en el 108, este debe estar entre el 107 y el 109 o lo que más se acerca.", font=controller.nfont)
  111.         # Empaquetamos los labels
  112.         titulo.grid(row=0)
  113.         label.grid(row=1)
  114.         instrucciones.grid(row=2, pady=20)
  115.         label2.grid(row=3, padx=30)
  116.         # Boton
  117.         button1 = tk.Button(self, text="Empezar",
  118.                             command=lambda: controller.show_frame("Page1"), width=20, height=5, relief="raised", borderwidth=5)
  119.         button1.grid(row=4, pady=50)
  120.  
  121. class Page1(tk.Frame):
  122.  
  123.  
  124.     def __init__(self, parent, controller):
  125.         tk.Frame.__init__(self, parent)
  126.         self.controller = controller
  127.         self.configure(bg="black")
  128.         # Declaramos y llamamos la tabla
  129.  
  130.         tabla = PhotoImage( file="tabla00.PNG")
  131.         labeltabla = Label(self, image=tabla)
  132.         labeltabla.image = tabla
  133.         labeltabla.pack()
  134.  
  135.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  136.         label.pack()
  137.        
  138.         si = tk.Button(self, text="Sí", command=SampleApp.p1, width=10, height=2, relief="raised", borderwidth=5)
  139.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  140.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page2"))
  141.         si.pack()
  142.         no.pack()
  143.         pasar.pack()
  144.  
  145.  
  146. class Page2(tk.Frame):
  147.  
  148.     def __init__(self, parent, controller):
  149.         tk.Frame.__init__(self, parent)
  150.         self.controller = controller
  151.         self.configure(bg="black")
  152.         # Declaramos y llamamos la tabla
  153.  
  154.         tabla = PhotoImage( file="tabla01.PNG")
  155.         labeltabla = Label(self, image=tabla)
  156.         labeltabla.image = tabla
  157.         labeltabla.pack()
  158.  
  159.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  160.         label.pack()
  161.        
  162.         si = tk.Button(self, text="Sí", command=SampleApp.p2, width=10, height=2, relief="raised", borderwidth=5)
  163.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  164.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page3"))
  165.         si.pack()
  166.         no.pack()
  167.         pasar.pack()
  168.  
  169. class Page3(tk.Frame):
  170.  
  171.     def __init__(self, parent, controller):
  172.         tk.Frame.__init__(self, parent)
  173.         self.controller = controller
  174.         self.configure(bg="black")
  175.         # Declaramos y llamamos la tabla
  176.  
  177.         tabla = PhotoImage( file="tabla02.PNG")
  178.         labeltabla = Label(self, image=tabla)
  179.         labeltabla.image = tabla
  180.         labeltabla.pack()
  181.  
  182.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  183.         label.pack()
  184.        
  185.         si = tk.Button(self, text="Sí", command=SampleApp.p3, width=10, height=2, relief="raised", borderwidth=5)
  186.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  187.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page4"))
  188.         si.pack()
  189.         no.pack()
  190.         pasar.pack()
  191.  
  192. class Page4(tk.Frame):
  193.  
  194.     def __init__(self, parent, controller):
  195.         tk.Frame.__init__(self, parent)
  196.         self.controller = controller
  197.         self.configure(bg="black")
  198.         # Declaramos y llamamos la tabla
  199.  
  200.         tabla = PhotoImage( file="tabla03.PNG")
  201.         labeltabla = Label(self, image=tabla)
  202.         labeltabla.image = tabla
  203.         labeltabla.pack()
  204.  
  205.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  206.         label.pack()
  207.        
  208.         si = tk.Button(self, text="Sí", command=SampleApp.p4, width=10, height=2, relief="raised", borderwidth=5)
  209.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  210.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page5"))
  211.         si.pack()
  212.         no.pack()
  213.         pasar.pack()
  214.  
  215. class Page5(tk.Frame):
  216.  
  217.     def __init__(self, parent, controller):
  218.         tk.Frame.__init__(self, parent)
  219.         self.controller = controller
  220.         self.configure(bg="black")
  221.         # Declaramos y llamamos la tabla
  222.  
  223.         tabla = PhotoImage( file="tabla04.PNG")
  224.         labeltabla = Label(self, image=tabla)
  225.         labeltabla.image = tabla
  226.         labeltabla.pack()
  227.  
  228.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  229.         label.pack()
  230.        
  231.         si = tk.Button(self, text="Sí", command=SampleApp.p5, width=10, height=2, relief="raised", borderwidth=5)
  232.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  233.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page6"))
  234.         si.pack()
  235.         no.pack()
  236.         pasar.pack()
  237.  
  238. class Page6(tk.Frame):
  239.  
  240.     def __init__(self, parent, controller):
  241.         tk.Frame.__init__(self, parent)
  242.         self.controller = controller
  243.         self.configure(bg="black")
  244.         # Declaramos y llamamos la tabla
  245.  
  246.         tabla = PhotoImage( file="tabla05.PNG")
  247.         labeltabla = Label(self, image=tabla)
  248.         labeltabla.image = tabla
  249.         labeltabla.pack()
  250.  
  251.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  252.         label.pack()
  253.        
  254.         si = tk.Button(self, text="Sí", command=SampleApp.p6, width=10, height=2, relief="raised", borderwidth=5)
  255.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  256.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page7"))
  257.         si.pack()
  258.         no.pack()
  259.         pasar.pack()
  260.  
  261. class Page7(tk.Frame):
  262.  
  263.     def __init__(self, parent, controller):
  264.         tk.Frame.__init__(self, parent)
  265.         self.controller = controller
  266.         self.configure(bg="black")
  267.         # Declaramos y llamamos la tabla
  268.  
  269.         tabla = PhotoImage( file="tabla06.PNG")
  270.         labeltabla = Label(self, image=tabla)
  271.         labeltabla.image = tabla
  272.         labeltabla.pack()
  273.  
  274.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  275.         label.pack()
  276.        
  277.         si = tk.Button(self, text="Sí", command=SampleApp.p7, width=10, height=2, relief="raised", borderwidth=5)
  278.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  279.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page8"))
  280.         si.pack()
  281.         no.pack()
  282.         pasar.pack()
  283.  
  284. class Page8(tk.Frame):
  285.  
  286.     def __init__(self, parent, controller):
  287.         tk.Frame.__init__(self, parent)
  288.         self.controller = controller
  289.         self.configure(bg="black")
  290.         # Declaramos y llamamos la tabla
  291.  
  292.         tabla = PhotoImage( file="tabla07.PNG")
  293.         labeltabla = Label(self, image=tabla)
  294.         labeltabla.image = tabla
  295.         labeltabla.pack()
  296.  
  297.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  298.         label.pack()
  299.        
  300.         si = tk.Button(self, text="Sí", command=SampleApp.p8, width=10, height=2, relief="raised", borderwidth=5)
  301.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  302.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page9"))
  303.         si.pack()
  304.         no.pack()
  305.         pasar.pack()
  306.  
  307. class Page9(tk.Frame):
  308.  
  309.     def __init__(self, parent, controller):
  310.         tk.Frame.__init__(self, parent)
  311.         self.controller = controller
  312.         self.configure(bg="black")
  313.         # Declaramos y llamamos la tabla
  314.  
  315.         tabla = PhotoImage( file="tabla08.PNG")
  316.         labeltabla = Label(self, image=tabla)
  317.         labeltabla.image = tabla
  318.         labeltabla.pack()
  319.  
  320.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  321.         label.pack()
  322.        
  323.         si = tk.Button(self, text="Sí", command=SampleApp.p9, width=10, height=2, relief="raised", borderwidth=5)
  324.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  325.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("Page10"))
  326.         si.pack()
  327.         no.pack()
  328.         pasar.pack()
  329.  
  330. class Page10(tk.Frame):
  331.  
  332.     def __init__(self, parent, controller):
  333.         tk.Frame.__init__(self, parent)
  334.         self.controller = controller
  335.         self.configure(bg="black")
  336.         # Declaramos y llamamos la tabla
  337.  
  338.         tabla = PhotoImage( file="tabla09.PNG")
  339.         labeltabla = Label(self, image=tabla)
  340.         labeltabla.image = tabla
  341.         labeltabla.pack()
  342.  
  343.         label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
  344.         label.pack()
  345.        
  346.         si = tk.Button(self, text="Sí", command=SampleApp.p10, width=10, height=2, relief="raised", borderwidth=5)
  347.         no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
  348.         pasar = tk.Button(self, text="Pasar a la siguiente página", width=20, height=3, relief="raised", borderwidth=5, command=lambda: controller.show_frame("LastPage"))
  349.         si.pack()
  350.         no.pack()
  351.         pasar.pack()
  352.  
  353. class LastPage(tk.Frame):
  354.  
  355.     def __init__(self, parent, controller):
  356.         tk.Frame.__init__(self, parent)
  357.         self.controller = controller
  358.         self.configure(bg="black")
  359.         label = tk.Label(self, bg="black", fg= "white", text="esta es la ultima pagina", font=controller.title_font)
  360.         label.pack()
  361.  
  362.         total = tk.Label(self, bg="black", fg= "white", text=n, font=controller.title_font)
  363.         total.pack()
  364.  
  365.         button = tk.Button(self, text="Regresar al inicio",
  366.                            command=lambda: controller.show_frame("StartPage"))
  367.         button.pack()
  368.  
  369. if __name__ == "__main__":
  370.     app = SampleApp()
  371.     app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment