Skip to main content
Revertido a la revisión 2
Origen Enlace
FJSevilla
  • 62.1k
  • 7
  • 43
  • 68
def mostrar_nombre(pestaña, event):
    listbox = event.widget
   import indextkinter =as listbox.curselection()tk
   from valuetkinter =import listbox.get(index[0])ttk
    if pestaña == limit_before:
        limit_before_list[0]limit_before_list = pestaña[0]
        limit_before_list[1]max_posts_list = value[0]
    elif pestañamax_comments_list === max_posts:[0]
        max_posts_list[0]limit_before = pestaña'limit_before'
        max_posts_list[1]max_posts = value'max_posts'
    elif pestaña == max_comments:
        max_comments_list[0] = pestaña'max_comments'
        max_comments_list[1] = value
    elif pestaña ==
def IWantRetweetsmostrar_nombre(event):
        IWantRetweets_list[0]listbox = pestañaevent.widget
        IWantRetweets_list[1]index = value
    else:
        print('Algo paso')


def conf_createlistbox.curselection():
    global limit_before_list, max_posts_list, max_comments_list, IWantRetweets_list
    limit_before_listvalue = [0, 0]listbox.get(index[0])
    max_posts_list = [0, 0]
print(pestaña)  # Aca max_comments_listesta =mi [0problema, 0]
   me IWantRetweets_listdevuelve =la [0,ultima 0]ingresada
    note = ttk.Notebookprint(ventanavalue)
     

pestañas = {
        limit_before: list(range(0, 160, 10)),
        max_posts: list(range(0, 410, 10)),
        max_comments: list(range(0, 4100, 100)),
        IWantRetweets: ['true', 'false']
    }

  note = ttk.Notebook()

for pestaña, items in pestañas.items():
        frame = ttk.Frame(note)
        note.add(frame, text=pestaña)
        listbox = tk.Listbox(frame, exportselection=False)
        listbox.grid(row=0, column=0)
        listbox.bind(
            "<<ListboxSelect>>",
            functools.partial(
                mostrar_nombre,
                pestaña
            )
        )

        for item in items:
            listbox.insert(tk.END, item)

    tab4 = Button(note, text="DONE?", command=note.destroy)
    note.addpack(tab4, text="DONE")
    note.packmainloop(side="top", fill="both", expand=True)
def mostrar_nombre(pestaña, event):
    listbox = event.widget
    index = listbox.curselection()
    value = listbox.get(index[0])
    if pestaña == limit_before:
        limit_before_list[0] = pestaña
        limit_before_list[1] = value
    elif pestaña == max_posts:
        max_posts_list[0] = pestaña
        max_posts_list[1] = value
    elif pestaña == max_comments:
        max_comments_list[0] = pestaña
        max_comments_list[1] = value
    elif pestaña == IWantRetweets:
        IWantRetweets_list[0] = pestaña
        IWantRetweets_list[1] = value
    else:
        print('Algo paso')


def conf_create():
    global limit_before_list, max_posts_list, max_comments_list, IWantRetweets_list
    limit_before_list = [0, 0]
    max_posts_list = [0, 0]
    max_comments_list = [0, 0]
    IWantRetweets_list = [0, 0]
    note = ttk.Notebook(ventana)
    pestañas = {
        limit_before: range(0, 160, 10),
        max_posts: range(0, 410, 10),
        max_comments: range(0, 4100, 100),
        IWantRetweets: ['true', 'false']
    }

    for pestaña, items in pestañas.items():
        frame = ttk.Frame(note)
        note.add(frame, text=pestaña)
        listbox = tk.Listbox(frame, exportselection=False)
        listbox.grid(row=0, column=0)
        listbox.bind(
            "<<ListboxSelect>>",
            functools.partial(
                mostrar_nombre,
                pestaña
            )
        )

        for item in items:
            listbox.insert(tk.END, item)

    tab4 = Button(note, text="DONE?", command=note.destroy)
    note.add(tab4, text="DONE")
    note.pack(side="top", fill="both", expand=True)
import tkinter as tk
from tkinter import ttk

limit_before_list = [0]
max_posts_list = [0]
max_comments_list = [0]
limit_before = 'limit_before'
max_posts = 'max_posts'
max_comments = 'max_comments'


def mostrar_nombre(event):
    listbox = event.widget
    index = listbox.curselection()
    value = listbox.get(index[0])
    print(pestaña)  # Aca esta mi problema, me devuelve la ultima ingresada
    print(value)
 

pestañas = {
    limit_before: list(range(0, 160, 10)),
    max_posts: list(range(0, 410, 10)),
    max_comments: list(range(0, 4100, 100)),
}

note = ttk.Notebook()

for pestaña, items in pestañas.items():
    frame = ttk.Frame(note)
    note.add(frame, text=pestaña)
    listbox = tk.Listbox(frame, exportselection=False)
    listbox.grid(row=0, column=0)
    listbox.bind("<<ListboxSelect>>", mostrar_nombre)

    for item in items:
        listbox.insert(tk.END, item)


note.pack()
note.mainloop()
se añadieron 782 caracteres en el cuerpo
Origen Enlace
Martin Bouhier
  • 747
  • 3
  • 20
  • 42
import tkinterdef asmostrar_nombre(pestaña, tkevent):
from tkinter import ttk

limit_before_list listbox = [0]event.widget
max_posts_list    index = [0]listbox.curselection()
max_comments_list    value = [0]listbox.get(index[0])
    if pestaña == limit_before:
        limit_before_list[0] = 'limit_before'pestaña
        limit_before_list[1] = value
    elif pestaña == max_posts:
        max_posts_list[0] = 'max_posts'pestaña
max_comments        max_posts_list[1] = 'max_comments'value
    elif pestaña == max_comments:
        max_comments_list[0] = pestaña
        max_comments_list[1] = value
def mostrar_nombre(event)   elif pestaña == IWantRetweets:
    listbox    IWantRetweets_list[0] = event.widgetpestaña
    index    IWantRetweets_list[1] = listbox.curselectionvalue
    else:
        print('Algo paso')


def conf_create():
    valueglobal limit_before_list, max_posts_list, max_comments_list, IWantRetweets_list
    limit_before_list = listbox.get(index[0])[0, 0]
    print(pestaña)max_posts_list = #[0, Aca0]
 esta mi problema max_comments_list = [0, me0]
 devuelve la ultima ingresadaIWantRetweets_list = [0, 0]
    printnote = ttk.Notebook(valueventana)

 
    pestañas = {
        limit_before: list(range(0, 160, 10)),
        max_posts: list(range(0, 410, 10)),
        max_comments: list(range(0, 4100, 100)),
}
        IWantRetweets: ['true', 'false']
note = ttk.Notebook()  }

    for pestaña, items in pestañas.items():
        frame = ttk.Frame(note)
        note.add(frame, text=pestaña)
        listbox = tk.Listbox(frame, exportselection=False)
        listbox.grid(row=0, column=0)
        listbox.bind(
            "<<ListboxSelect>>",
            functools.partial(
                mostrar_nombre,
                pestaña
            )
        )

        for item in items:
            listbox.insert(tk.END, item)

    tab4 = Button(note, text="DONE?", command=note.destroy)
    note.packadd(tab4, text="DONE")
    note.mainlooppack(side="top", fill="both", expand=True)
import tkinter as tk
from tkinter import ttk

limit_before_list = [0]
max_posts_list = [0]
max_comments_list = [0]
limit_before = 'limit_before'
max_posts = 'max_posts'
max_comments = 'max_comments'


def mostrar_nombre(event):
    listbox = event.widget
    index = listbox.curselection()
    value = listbox.get(index[0])
    print(pestaña)  # Aca esta mi problema, me devuelve la ultima ingresada
    print(value)

 
pestañas = {
    limit_before: list(range(0, 160, 10)),
    max_posts: list(range(0, 410, 10)),
    max_comments: list(range(0, 4100, 100)),
}

note = ttk.Notebook()

for pestaña, items in pestañas.items():
    frame = ttk.Frame(note)
    note.add(frame, text=pestaña)
    listbox = tk.Listbox(frame, exportselection=False)
    listbox.grid(row=0, column=0)
    listbox.bind("<<ListboxSelect>>", mostrar_nombre)

    for item in items:
        listbox.insert(tk.END, item)


note.pack()
note.mainloop()
def mostrar_nombre(pestaña, event):
    listbox = event.widget
    index = listbox.curselection()
    value = listbox.get(index[0])
    if pestaña == limit_before:
        limit_before_list[0] = pestaña
        limit_before_list[1] = value
    elif pestaña == max_posts:
        max_posts_list[0] = pestaña
        max_posts_list[1] = value
    elif pestaña == max_comments:
        max_comments_list[0] = pestaña
        max_comments_list[1] = value
    elif pestaña == IWantRetweets:
        IWantRetweets_list[0] = pestaña
        IWantRetweets_list[1] = value
    else:
        print('Algo paso')


def conf_create():
    global limit_before_list, max_posts_list, max_comments_list, IWantRetweets_list
    limit_before_list = [0, 0]
    max_posts_list = [0, 0]
    max_comments_list = [0, 0]
    IWantRetweets_list = [0, 0]
    note = ttk.Notebook(ventana)
    pestañas = {
        limit_before: range(0, 160, 10),
        max_posts: range(0, 410, 10),
        max_comments: range(0, 4100, 100),
        IWantRetweets: ['true', 'false']
    }

    for pestaña, items in pestañas.items():
        frame = ttk.Frame(note)
        note.add(frame, text=pestaña)
        listbox = tk.Listbox(frame, exportselection=False)
        listbox.grid(row=0, column=0)
        listbox.bind(
            "<<ListboxSelect>>",
            functools.partial(
                mostrar_nombre,
                pestaña
            )
        )

        for item in items:
            listbox.insert(tk.END, item)

    tab4 = Button(note, text="DONE?", command=note.destroy)
    note.add(tab4, text="DONE")
    note.pack(side="top", fill="both", expand=True)
título editado
Enlace
FJSevilla
  • 62.1k
  • 7
  • 43
  • 68

Imprimir valor y procedenciaitem seleccionado de cadauna ListBox en TKInter - Pythony el nombre de la pestaña del Notebook a la que pertenece

Origen Enlace
Martin Bouhier
  • 747
  • 3
  • 20
  • 42
Loading