Calificación:
  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5
Buscador en Tkinter
#1
Thumbs Up 
Cita:muy buenas, quieria saber como puedo hacer algo asi como un buscador en tkinter, osea que se habra una ventana y por una lista que ya tengo puesta pueda escriber en una caja de texto y al presionar el botos que diga buscar, me aparesca la info de los que busco y asi, porfavor me serviria de mucho su ayuda e estado buscando pero no encuentro
heroes = [
{
'id': 'dc-batman',
'superhero':'Batman',
'publisher':'DC Comics',
'alter_ego':'Bruce Wayne',
'first_appearance':'Detective Comics #27',
'characters':'Bruce Wayne'
},
{
'id': 'dc-superman',
'superhero':'Superman',
'publisher':'DC Comics',
'alter_ego':'Kal-El',
'first_appearance':'Action Comics #1',
'characters':'Kal-El'
},
{
'id': 'dc-flash',
'superhero':'Flash',
'publisher':'DC Comics',
'alter_ego':'Jay Garrick',
'first_appearance':'Flash Comics #1',
'characters':'Jay Garrick, Barry Allen, Wally West, Bart Allen'
},
{
'id': 'dc-green',
'superhero':'Green Lantern',
'publisher':'DC Comics',
'alter_ego':'Alan Scott',
'first_appearance':'All-American Comics #16',
'characters':'Alan Scott, Hal Jordan, Guy Gardner, John Stewart, Kyle Raynor, Jade, Sinestro, Simon Baz'
},
{
'id': 'dc-arrow',
'superhero':'Green Arrow',
'publisher':'DC Comics',
'alter_ego':'Oliver Queen',
'first_appearance':'More Fun Comics #73',
'characters':'Oliver Queen'
},
{
'id': 'dc-wonder',
'superhero':'Wonder Woman',
'publisher':'DC Comics',
'alter_ego':'Princess Diana',
'first_appearance':'All Star Comics #8',
'characters':'Princess Diana'
},
{
'id': 'dc-martian',
'superhero':'Martian Manhunter',
'publisher':'DC Comics',
'alter_ego':'J'onn J'onzz',
'first_appearance':'Detective Comics #225',
'characters':'Martian Manhunter'
},
{
'id': 'dc-robin',
'superhero':'Robin/Nightwing',
'publisher':'DC Comics',
'alter_ego':'Dick Grayson',
'first_appearance':'Detective Comics #38',
'characters':'Dick Grayson'
},
{
'id': 'dc-blue',
'superhero':'Blue Beetle',
'publisher':'DC Comics',
'alter_ego':'Dan Garret',
'first_appearance':'Mystery Men Comics #1',
'characters':'Dan Garret, Ted Kord, Jaime Reyes'
},
{
'id': 'dc-black',
'superhero':'Black Canary',
'publisher':'DC Comics',
'alter_ego':'Dinah Drake',
'first_appearance':'Flash Comics #86',
'characters':'Dinah Drake, Dinah Lance'
},
{
'id': 'marvel-spider',
'superhero':'Spider Man',
'publisher':'Marvel Comics',
'alter_ego':'Peter Parker',
'first_appearance':'Amazing Fantasy #15',
'characters':'Peter Parker'
},
{
'id': 'marvel-captain',
'superhero':'Captain America',
'publisher':'Marvel Comics',
'alter_ego':'Steve Rogers',
'first_appearance':'Captain America Comics #1',
'characters':'Steve Rogers'
},
{
'id': 'marvel-iron',
'superhero':'Iron Man',
'publisher':'Marvel Comics',
'alter_ego':'Tony Stark',
'first_appearance':'Tales of Suspense #39',
'characters':'Tony Stark'
},
{
'id': 'marvel-thor',
'superhero':'Thor',
'publisher':'Marvel Comics',
'alter_ego':'Thor Odinson',
'first_appearance':'Journey into Myster #83',
'characters':'Thor Odinson'
},
{
'id': 'marvel-hulk',
'superhero':'Hulk',
'publisher':'Marvel Comics',
'alter_ego':'Bruce Banner',
'first_appearance':'The Incredible Hulk #1',
'characters':'Bruce Banner'
},
{
'id': 'marvel-wolverine',
'superhero':'Wolverine',
'publisher':'Marvel Comics',
'alter_ego':'James Howlett',
'first_appearance':'The Incredible Hulk #180',
'characters':'James Howlett'
},
{
'id': 'marvel-daredevil',
'superhero':'Daredevil',
'publisher':'Marvel Comics',
'alter_ego':'Matthew Michael Murdock',
'first_appearance':'Daredevil #1',
'characters':'Matthew Michael Murdock'
},
{
'id': 'marvel-hawkeye',
'superhero':'Hawkeye',
'publisher':'Marvel Comics',
'alter_ego':'Clinton Francis Barton',
'first_appearance':'Tales of Suspense #57',
'characters':'Clinton Francis Barton'
},
{
'id': 'marvel-cyclops',
'superhero':'Cyclops',
'publisher':'Marvel Comics',
'alter_ego':'Scott Summers',
'first_appearance':'X-Men #1',
'characters':'Scott Summers'
},
{
'id': 'marvel-silver',
'superhero':'Silver Surfer',
'publisher':'Marvel Comics',
'alter_ego':'Norrin Radd',
'first_appearance':'The Fantastic Four #48',
'characters':'Norrin Radd'
}
]
esta es la lista si me podria dar un indice y asi se lo agradeceria un monton
Responder
#2
Hola, bienvenido.

¿Tenés algún código en el que hayas intentado algo? ¿Dónde tenés el problema específicamente?

Saludos
¡No te pierdas nuestro curso oficial en Udemy para aprender Python, bases de datos SQL, orientación a objetos, tkinter y mucho más!

También ofrecemos consultoría profesional de desarrollo en Python para personas y empresas.
Responder
#3
Big Grin 
(02-02-2021, 01:04 PM)Francisco escribió: Hola, bienvenido.

¿Tenés algún código en el que hayas intentado algo? ¿Dónde tenés el problema específicamente?

Saludos
muy buenas tardes,  mi profesor me indico que tenia que hacer un bunscador en ventana con esta lista y adicional mente hacer un menu con unos botones los cuales al pulsar me lleve a una ventana en la cual haya perosonajes de marvel y otra con personajes de dc y el buscador como ya habia indicado pero ya tengo lo de las ventanas con los personajes de dc y marvel y alpusar su imagen les da info de los heroes, pero e estado buscando de como  hacer una ventana con buscador pero no e podido encontar como hacerla ni tampoco e podido hacer la sin ventana ya que no comprendo comom hacerlo si me podria dar un indice de como hacerlo se lo agradeceria un monton


Código:
import tkinter as tk
from tkinter import *
from tkinter import ttk
from PIL import ImageTk, Image
import pygame

window = Tk()
window.title(" ")
window.geometry('720x600+350+50')
im=PhotoImage (file ="mdc.png")
widget=Label (window, image =im ) .place (x= -2, y=0)
window.state(newstate = "normal")
window.resizable(False,False)
file = 'intro.mp3'
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(file)
pygame.mixer.music.play(-1)

def MARVEL():
    window2 = Toplevel()
    window2.geometry('720x600+350+50')
    window2.title("MARVEL")
    window2.resizable(False,False)
    file = 'marvel.mp3'
    pygame.init()
    pygame.mixer.init()
    pygame.mixer.music.load(file)
    pygame.mixer.music.play(1)
    window.state(newstate = "withdraw")
    window2.state(newstate = "withdraw")
    window2.state(newstate = "normal" )
    mf = Frame(window2)
    mf.pack(fill=BOTH, expand=1)
    mca = Canvas(mf)
    mca.pack(side=LEFT, fill=BOTH, expand=1)
    mscrollbar = ttk.Scrollbar(mca, orient=VERTICAL, command=mca.yview)
    mscrollbar.pack(side=RIGHT, fill=Y)
    mca.configure(yscrollcommand=mscrollbar.set)
    mca.bind('<Configure>', lambda e: mca.configure(scrollregion = mca.bbox("all")))
    sfra = Frame(mca)
    mca.create_window((0,0), window=sfra, anchor="n")
   
    def regresar():
        window2.state(newstate = "normal")
        window2.state(newstate = "withdraw" )
        window.state(newstate = "normal")
        file = 'intro.mp3'
        pygame.init()
        pygame.mixer.init()
        pygame.mixer.music.load(file)
        pygame.mixer.music.play(-1)
       
    regresar= Button(window2, text="MENÚ", font=("Times New Roman", 14), bg="black", fg="white",command = regresar).place(x=625, y=560)
    for thing in range(50):
        lbl = Label(sfra, text=f"{thing}------------------------------------------------------------------------",font=("Times New Roman", 20),bg="white",fg="WHITE").grid(row=thing,column=0)
   
    def cp():
        cpa = Toplevel()
        cpa.geometry('720x600+350+50')
        cpa.title("dc")
        cpa.resizable(False,False)
        window2.state(newstate = "withdraw")
        cpa.state(newstate = "withdraw")
        cpa.state(newstate = "normal" )
        pathtophoto = Image.open("capii.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(cpa, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            cpa.state(newstate = "normal")
            cpa.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(cpa, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    cap=PhotoImage (file ="cap.png")
    cap.configure=Button (sfra, image =cap,command=cp).place (x= 350, y=1155)

    def wh():
        ww = Toplevel()
        ww.geometry('720x600+350+50')
        ww.title("dc")
        ww.resizable(False,False)
        window2.state(newstate = "withdraw")
        ww.state(newstate = "withdraw")
        ww.state(newstate = "normal" )
        pathtophoto = Image.open("wanw.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(ww, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            ww.state(newstate = "normal")
            ww.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(ww, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    wan=PhotoImage (file ="wan.png")
    wan.configure=Button (sfra, image =wan,command=wh).place (x= 350, y=775)

    def sp():
        spd = Toplevel()
        spd.geometry('720x600+350+50')
        spd.title("dc")
        spd.resizable(False,False)
        window2.state(newstate = "withdraw")
        spd.state(newstate = "withdraw")
        spd.state(newstate = "normal" )
        pathtophoto = Image.open("spid.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(spd, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            spd.state(newstate = "normal")
            spd.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(spd, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    spi=PhotoImage (file ="spi.png")
    spi.configure=Button (sfra, image =spi,command=sp).place (x= 350, y=400)

    def vn():
        vdn = Toplevel()
        vdn.geometry('720x600+350+50')
        vdn.title("dc")
        vdn.resizable(False,False)
        window2.state(newstate = "withdraw")
        vdn.state(newstate = "withdraw")
        vdn.state(newstate = "normal" )
        pathtophoto = Image.open("viud.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(vdn, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            vdn.state(newstate = "normal")
            vdn.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(vdn, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    viu=PhotoImage (file ="viu.png")
    viu.configure=Button (sfra, image =viu,command=vn).place (x= 350, y=35)

    def vso():
        vsr = Toplevel()
        vsr.geometry('720x600+350+50')
        vsr.title("dc")
        vsr.resizable(False,False)
        window2.state(newstate = "withdraw")
        vsr.state(newstate = "withdraw")
        vsr.state(newstate = "normal" )
        pathtophoto = Image.open("visi.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(vsr, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            vsr.state(newstate = "normal")
            vsr.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(vsr, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    vis=PhotoImage (file ="vis.png")
    vis.configure=Button (sfra, image =vis,command=vso).place (x= 2, y=1535)

    def odi():
        tor = Toplevel()
        tor.geometry('720x600+350+50')
        tor.title("dc")
        tor.resizable(False,False)
        window2.state(newstate = "withdraw")
        tor.state(newstate = "withdraw")
        tor.state(newstate = "normal" )
        pathtophoto = Image.open("thor.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(tor, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            tor.state(newstate = "normal")
            tor.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(tor, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    tho=PhotoImage (file ="tho.png")
    tho.configure=Button (sfra, image =tho,command=odi).place (x= 2, y=1155)

    def hulk():
        hul = Toplevel()
        hul.geometry('720x600+350+50')
        hul.title("dc")
        hul.resizable(False,False)
        window2.state(newstate = "withdraw")
        hul.state(newstate = "withdraw")
        hul.state(newstate = "normal" )
        pathtophoto = Image.open("hulk.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(hul, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            hul.state(newstate = "normal")
            hul.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(hul, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    hul=PhotoImage (file ="hul.png")
    hul.configure=Button (sfra, image =hul,command=hulk).place (x= 2, y=775)

    def ojon():
        ojin = Toplevel()
        ojin.geometry('720x600+350+50')
        ojin.title("dc")
        ojin.resizable(False,False)
        window2.state(newstate = "withdraw")
        ojin.state(newstate = "withdraw")
        ojin.state(newstate = "normal" )
        pathtophoto = Image.open("ojoh.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(ojin, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            ojin.state(newstate = "normal")
            ojin.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(ojin, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    ojo=PhotoImage (file ="ojo.png")
    ojo.configure=Button (sfra, image =ojo,command=ojon).place (x= 2, y=400)

    def ira():
        iro = Toplevel()
        iro.geometry('720x600+350+50')
        iro.title("dc")
        iro.resizable(False,False)
        window2.state(newstate = "withdraw")
        iro.state(newstate = "withdraw")
        iro.state(newstate = "normal" )
        pathtophoto = Image.open("ironm.png")
        image = ImageTk.PhotoImage(pathtophoto)
        panel = Label(iro, image=image)
        panel.image = image #keep a reference
        panel.place(x=-7,y=0)
        def regresar():
            iro.state(newstate = "normal")
            iro.state(newstate = "withdraw" )
            window2.state(newstate = "normal")
        regresar= Button(iro, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    ir=PhotoImage (file ="iron.png")
    iro.configure=Button (sfra, image =ir,command=ira).place (x= 2, y=35)

   
marvel=PhotoImage(file="mar.png")
bmar=Button(window,image=marvel,height=90,width = 200,command= MARVEL).place (x=217,y=4)

def DC():
    m = Toplevel()
    m.geometry('720x600+350+50')
    m.title("dc")
    m.resizable(False,False)
    file = 'dc.mp3'
    pygame.init()
    pygame.mixer.init()
    pygame.mixer.music.load(file)
    pygame.mixer.music.play(-1)
    window.state(newstate = "withdraw")
    m.state(newstate = "withdraw")
    m.state(newstate = "normal" )
    maframe = Frame(m)
    maframe.pack(fill=BOTH, expand=1)
    mycanva = Canvas(maframe)
    mycanva.pack(side=LEFT, fill=BOTH, expand=1)
    myscrollbar = ttk.Scrollbar(mycanva, orient=VERTICAL, command=mycanva.yview)
    myscrollbar.pack(side=RIGHT, fill=Y)
    mycanva.configure(yscrollcommand=myscrollbar.set)
    mycanva.bind('<Configure>', lambda e: mycanva.configure(scrollregion = mycanva.bbox("all")))
    seframe = Frame(mycanva)
    mycanva.create_window((0,0), window=seframe, anchor="n")
   
    def regresar():
        m.state(newstate = "normal")
        m.state(newstate = "withdraw" )
        window.state(newstate = "normal")
        pygame.init()
        pygame.mixer.init()
        pygame.mixer.music.load(file)
        pygame.mixer.music.play(-1)
   
    regresar= Button(m, text="MENÚ", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
    regresar.place(x=625, y=560)
    for thing in range(50):
        lbl = Label(seframe, text=f"{thing}------------------------------------------------------------------------",font=("Times New Roman", 20),bg="white",fg="WHITE").grid(row=thing,column=0)

    def cyb():
        cy = Toplevel()
        cy.geometry('720x600+350+50')
        cy.title("dc")
        cy.resizable(False,False)
        m.state(newstate = "withdraw")
        cy.state(newstate = "withdraw")
        cy.state(newstate = "normal" )
        pathtophoto = Image.open("cyb.png")
        image1 = ImageTk.PhotoImage(pathtophoto)
        panel1 = Label(cy, image=image1)
        panel1.image = image1 #keep a reference
        panel1.place(x=-7,y=0)
        def regresar():
            cy.state(newstate = "normal")
            cy.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(cy, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)
    cy=PhotoImage (file ="cy.png")
    cy.configure=Button (seframe, image =cy,command=cyb).place (x= 350, y=775)

    def de():
        dec = Toplevel()
        dec.geometry('720x600+350+50')
        dec.title("dc")
        dec.resizable(False,False)
        m.state(newstate = "withdraw")
        dec.state(newstate = "withdraw")
        dec.state(newstate = "normal" )
        pathtophoto = Image.open("dect.png")
        image1 = ImageTk.PhotoImage(pathtophoto)
        panel1 = Label(dec, image=image1)
        panel1.image = image1 #keep a reference
        panel1.place(x=-7,y=0)
        def regresar():
            dec.state(newstate = "normal")
            dec.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(dec, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)
    dec=PhotoImage (file ="dec.png")
    dec.configure=Button (seframe, image =dec,command=de).place (x= 350, y=400)

    def l():
        li = Toplevel()
        li.geometry('720x600+350+50')
        li.title("dc")
        li.resizable(False,False)
        m.state(newstate = "withdraw")
        li.state(newstate = "withdraw")
        li.state(newstate = "normal" )
        pathtophoto = Image.open("green.png")
        image1 = ImageTk.PhotoImage(pathtophoto)
        panel1 = Label(li, image=image1)
        panel1.image = image1 #keep a reference
        panel1.place(x=-1,y=0)
        def regresar():
            li.state(newstate = "normal")
            li.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(li, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)
    li=PhotoImage (file ="li.png")
    li.configure=Button (seframe, image =li,command=l).place (x= 350, y=35)

    def wo():
        w = Toplevel()
        w.geometry('720x600+350+50')
        w.title("dc")
        w.resizable(False,False)
        m.state(newstate = "withdraw")
        w.state(newstate = "withdraw")
        w.state(newstate = "normal" )
        pathtophoto = Image.open("won.png")
        image3 = ImageTk.PhotoImage(pathtophoto)
        panel3 = Label(w, image=image3)
        panel3.image = image3 #keep a reference
        panel3.place(x=-1,y=0)
        def regresar():
            w.state(newstate = "normal")
            w.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(w, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)
    wow=PhotoImage (file ="wow.png")
    wow.configure=Button (seframe, image =wow,command=wo).place (x= 2, y=1535)

    def ac():
        a = Toplevel()
        a.geometry('720x600+350+50')
        a.title("dc")
        a.resizable(False,False)
        m.state(newstate = "withdraw")
        a.state(newstate = "withdraw")
        a.state(newstate = "normal" )
        pathtophoto = Image.open("aqu.png")
        image1 = ImageTk.PhotoImage(pathtophoto)
        panel1 = Label(a, image=image1)
        panel1.image = image1 #keep a reference
        panel1.place(x=-7,y=0)
        def regresar():
            a.state(newstate = "normal")
            a.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(a, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)
    acu=PhotoImage (file ="acu.png")
    acu.configure=Button (seframe, image =acu,command=ac).place (x= 2, y=1155)

    def fla():
        f = Toplevel()
        f.geometry('720x600+350+50')
        f.title("dc")
        f.resizable(False,False)
        m.state(newstate = "withdraw")
        f.state(newstate = "withdraw")
        f.state(newstate = "normal" )
        pathtophoto = Image.open("fla.png")
        image1 = ImageTk.PhotoImage(pathtophoto)
        panel1 = Label(f, image=image1)
        panel1.image = image1 #keep a reference
        panel1.place(x=-7,y=0)
       
        def regresar():
            f.state(newstate = "normal")
            f.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(f, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)
   
    flash=PhotoImage (file ="flash.png")
    flash.configure=Button (seframe, image =flash,command=fla).place (x= 2, y=775)

    def bat():
        b = Toplevel()
        b.geometry('720x600+350+50')
        b.title("dc")
        b.resizable(False,False)
        m.state(newstate = "withdraw")
        b.state(newstate = "withdraw")
        b.state(newstate = "normal" )
        bati= Image.open("batn.png")
        image2 = ImageTk.PhotoImage(bati)
        panel2 = Label(b, image=image2)
        panel2.image = image2 #keep a reference
        panel2.place(x=-1,y=0)
        def regresar():
            b.state(newstate = "normal")
            b.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        regresar= Button(b, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar)
        regresar.place(x=625, y=560)

    dcbat=PhotoImage (file ="bat.png")
    bat.configure=Button (seframe, image =dcbat,command=bat).place (x= 2, y=400)

    def su():
        s = Toplevel()
        s.geometry('720x600+350+50')
        s.title("dc")
        s.resizable(False,False)
        m.state(newstate = "withdraw")
        s.state(newstate = "withdraw")
        s.state(newstate = "normal" )
       
        def regresar():
            s.state(newstate = "normal")
            s.state(newstate = "withdraw" )
            m.state(newstate = "normal")
        pathtophoto = Image.open("susu.png")
        image1 = ImageTk.PhotoImage(pathtophoto)
        panel1 = Label(s, image=image1)
        panel1.image = image1 #keep a reference
        panel1.place(x=-1,y=0)
        regresar= Button(s, text="regresar", font=("Times New Roman", 14), bg="black", fg="white",command = regresar).place(x=625, y=560)
       
    dcsuper=PhotoImage (file ="super.png")
    sup.configure=Button (seframe, image =dcsuper,command=su).place (x= 2, y=35)   
   
dc=PhotoImage(file="dc1.png")
btdc=Button(window,image=dc,height=90,width = 150,command= DC).place (x=427,y=4)   
   

def cerrar():
    window.destroy()

botoncierra=Button(window,text="Salir",padx = 15, pady = 8, bg="black", fg="white", font = ("Kartika", 13, "bold"), command=cerrar)
botoncierra.place(x = 315, y= 395)
window.mainloop()
Responder
#4
Hola, para el buscador podrías usar una ventana (como hiciste, con tk.Toplevel) con una caja de texto donde se escriba lo que se quiere buscar y un botón para realizar la búsqueda. Para mostrar los resultados te convendría usar un listbox. Para el proceso de búsqueda solo deberías recorrer tu lista de héroes con un bucle for y un condicional.

Saludos
¡No te pierdas nuestro curso oficial en Udemy para aprender Python, bases de datos SQL, orientación a objetos, tkinter y mucho más!

También ofrecemos consultoría profesional de desarrollo en Python para personas y empresas.
Responder
#5
bueno ya pude hacer lo del buscador creo
pero necesito saber como puedo navergar entre ventanas ya que tengo una que es menu una es de dc y una es de marvel y cada uno tiene informacion de un heroe y tengo una ventana de buscador y queria saber como puedo ir de la ventana de buscador a uan ventana en especifica de un heroe
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)