Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import ttk
  3.  
  4. limit_before_list = [0]
  5. max_posts_list = [0]
  6. max_comments_list = [0]
  7. limit_before = 'limit_before'
  8. max_posts = 'max_posts'
  9. max_comments = 'max_comments'
  10.  
  11.  
  12. def mostrar_nombre(event):
  13. listbox = event.widget
  14. index = listbox.curselection()
  15. value = listbox.get(index[0])
  16. print(pestaña) # Aca esta mi problema, me devuelve la ultima ingresada
  17. print(value)
  18.  
  19.  
  20. pestañas = {
  21. limit_before: list(range(0, 160, 10)),
  22. max_posts: list(range(0, 410, 10)),
  23. max_comments: list(range(0, 4100, 100)),
  24. }
  25.  
  26. note = ttk.Notebook()
  27.  
  28. for pestaña, items in pestañas.items():
  29. frame = ttk.Frame(note)
  30. note.add(frame, text=pestaña)
  31. listbox = tk.Listbox(frame, exportselection=False)
  32. listbox.grid(row=0, column=0)
  33. listbox.bind("<<ListboxSelect>>", mostrar_nombre)
  34.  
  35. for item in items:
  36. listbox.insert(tk.END, item)
  37.  
  38.  
  39. note.pack()
  40. note.mainloop()
  41.  
  42. import functools
  43. import tkinter as tk
  44. from tkinter import ttk
  45.  
  46.  
  47. limit_before_list = [0]
  48. max_posts_list = [0]
  49. max_comments_list = [0]
  50. limit_before = 'limit_before'
  51. max_posts = 'max_posts'
  52. max_comments = 'max_comments'
  53.  
  54.  
  55. def mostrar_nombre(pestaña, event):
  56. listbox = event.widget
  57. index = listbox.curselection()
  58. value = listbox.get(index[0])
  59. print(pestaña) # Aca esta mi problema, me devuelve la ultima ingresada
  60. print(value)
  61.  
  62.  
  63. pestañas = {
  64. limit_before: range(0, 160, 10),
  65. max_posts: range(0, 410, 10),
  66. max_comments: range(0, 4100, 100),
  67. }
  68.  
  69. note = ttk.Notebook()
  70.  
  71. for pestaña, items in pestañas.items():
  72. frame = ttk.Frame(note)
  73. note.add(frame, text=pestaña)
  74. listbox = tk.Listbox(frame, exportselection=False)
  75. listbox.grid(row=0, column=0)
  76. listbox.bind("<<ListboxSelect>>", functools.partial(mostrar_nombre, pestaña))
  77.  
  78. for item in items:
  79. listbox.insert(tk.END, item)
  80.  
  81.  
  82. note.pack()
  83. note.mainloop()
  84.  
  85. def mostrar_nombre(event):
  86. listbox = event.widget
  87. index = listbox.curselection()
  88. value = listbox.get(index[0])
  89. notebook = listbox.master.master
  90. pestaña = notebook.tab(notebook.select(), "text")
  91. print(pestaña)
  92. print(value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement