Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk # python 3
- from tkinter import font as tkfont
- from tkinter import *# python 3
- #import Tkinter as tk # python 2
- #import tkFont as tkfont # python 2
- """
- n = 1
- total = 0
- def MAIN():
- while True:
- global n
- global total
- if n == 1:
- n = n + 1
- break
- elif n== 2:
- total = total + 1
- n = n+1
- break
- elif n== 3:
- total = total + 2
- n = n + 1
- break
- elif n== 4:
- total = total + 4
- n = n+1
- break
- elif n== 5:
- total = total + 8
- n = n+1
- break
- elif n== 6:
- total = total + 16
- n = n+1
- break
- elif n== 7:
- total = total + 32
- n = n+1
- break
- elif n== 8:
- total = total + 64
- n = n+1
- break
- elif n== 9:
- total = total + 128
- n = n+1
- break
- elif n== 10:
- total = total + 256
- n = n+1
- break
- elif n== 11:
- total = total + 512
- n = n+1
- break
- break
- def MAINNO():
- global n
- n = n + 1
- """
- class SampleApp(tk.Tk):
- def __init__(self, *args, **kwargs):
- tk.Tk.__init__(self, *args, **kwargs)
- self.title_font = tkfont.Font(family='Helvetica', size=18, weight="bold", slant="italic")
- self.nfont = tkfont.Font(family="Helvetica", size=15, slant="italic")
- # the container is where we'll stack a bunch of frames
- # on top of each other, then the one we want visible
- # will be raised above the others
- container = tk.Frame(self)
- container.pack(side="top", fill="both", expand=True)
- container.grid_rowconfigure(0, weight=1)
- container.grid_columnconfigure(0, weight=1)
- self.frames = {}
- for F in (StartPage, Page1, Page2, Page3, Page4, Page5, Page6, Page7, Page8, Page9, Page10, LastPage):
- page_name = F.__name__
- frame = F(parent=container, controller=self)
- self.frames[page_name] = frame
- # put all of the pages in the same location;
- # the one on the top of the stacking order
- # will be the one that is visible.
- frame.grid(row=0, column=0, sticky="nsew")
- self.show_frame("StartPage")
- def p1():
- global n
- n = 1
- print ("Probando")
- def p2():
- global n
- n = n + 2
- def p3():
- global n
- n = n + 4
- def p4():
- global n
- n = n + 8
- def p5():
- global n
- n = n + 16
- def p6():
- global n
- n = n + 32
- def p7():
- global n
- n = n +64
- def p8():
- global n
- n = n + 128
- def p9():
- global n
- n = n+256
- def p10():
- global n
- n = n + 512
- global n
- n = 0
- def show_frame(self, page_name):
- '''Show a frame for the given page name'''
- frame = self.frames[page_name]
- frame.tkraise()
- class StartPage(tk.Frame):
- def __init__(self, parent, controller):
- # Definimos funciones básicas de la ventana
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Creamos y damos caracteristicas a los frames
- titulo = tk.Label(self, bg="black", text="Bienvenidos...", fg= "white", font=controller.title_font)
- instrucciones = tk.Label(self, bg="black", fg= "white", text="Instrucciones:", font=controller.title_font)
- 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)
- 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)
- # Empaquetamos los labels
- titulo.grid(row=0)
- label.grid(row=1)
- instrucciones.grid(row=2, pady=20)
- label2.grid(row=3, padx=30)
- # Boton
- button1 = tk.Button(self, text="Empezar",
- command=lambda: controller.show_frame("Page1"), width=20, height=5, relief="raised", borderwidth=5)
- button1.grid(row=4, pady=50)
- class Page1(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 1
- tabla = PhotoImage( file="tabla00.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p1(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page2(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 2
- tabla = PhotoImage( file="tabla01.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p2(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page3(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 4
- tabla = PhotoImage( file="tabla02.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p3(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page4(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 8
- tabla = PhotoImage( file="tabla03.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p4(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page5(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 16
- tabla = PhotoImage( file="tabla04.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p5(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page6(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 32
- tabla = PhotoImage( file="tabla05.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p6(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page7(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 64
- tabla = PhotoImage( file="tabla06.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p7(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page8(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 128
- tabla = PhotoImage( file="tabla07.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p8(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page9(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 256
- tabla = PhotoImage( file="tabla08.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p9(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class Page10(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- # Declaramos y llamamos la tabla
- x = 512
- tabla = PhotoImage( file="tabla09.PNG")
- labeltabla = Label(self, image=tabla)
- labeltabla.image = tabla
- labeltabla.pack()
- label = tk.Label(self, bg="black", fg= "white", text="¿Tu número se encuentra en esa tabla?", font=controller.title_font)
- label.pack()
- si = tk.Button(self, text="Sí", command=SampleApp.p10(), width=10, height=2, relief="raised", borderwidth=5)
- no = tk.Button(self, text="No", width=10, height=2, relief="raised", borderwidth=5)
- 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"))
- si.pack()
- no.pack()
- pasar.pack()
- class LastPage(tk.Frame):
- def __init__(self, parent, controller):
- tk.Frame.__init__(self, parent)
- self.controller = controller
- self.configure(bg="black")
- label = tk.Label(self, bg="black", fg= "white", text="esta es la ultima pagina", font=controller.title_font)
- label.pack()
- global total
- total = tk.Label(self, bg="black", fg= "white", text=n, font=controller.title_font)
- total.pack()
- button = tk.Button(self, text="Regresar al inicio",
- command=lambda: controller.show_frame("StartPage"))
- button.pack()
- if __name__ == "__main__":
- app = SampleApp()
- app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment