Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Kako izbrisati više selektovanih itema iz listbox?

[es] :: Python :: Kako izbrisati više selektovanih itema iz listbox?

[ Pregleda: 4927 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

wraith46

Član broj: 336363
Poruke: 29



+1 Profil

icon Kako izbrisati više selektovanih itema iz listbox?01.04.2017. u 19:51 - pre 85 meseci
Pravim jednostavan GUI program, nešto kao To Do List.

Uspeo sam da ubacim funkcionalnost za dodavanje itema u listbox, ali sada treba da ih obrišem iz listbox i iz list (zato što, ispravite me ako grešim, u C# kada kreirate ListView, kreirali ste samu ListView (objekat na ekranu), ali ste naknadno morali da kreirate i List<> da biste čuvali objekte iz ListView. Nedavno sam naučio, ako nisam pogrešno shvatio, da END parameter "is used to append items to the list". Je l' se ovde misli na nešto kao što je List<> u C# - pa to što sam iskoristio END parametar je isto kao da sam dodao objekat u List<>?

Ako je tako i u Pythonu, hoću da obrišem sve selektovane iteme i iz liste, i iz listboxa.

Evo šta sam uradio:

Code:
# priorities.py
# GUI program to manage priorities

from tkinter import *

class GuiPart(Frame):

   def __init__(self, master):
       Frame.__init__(self, master)
       self.master = master
       self.master.resizable(width = False, height = False)
       self.master.title("Priorities")
       self.create_widgets()

   def create_widgets(self):

       self.buttonAdd = Button(self.master, text = "Add", command = self.addItem).grid(row = 2, column = 0, sticky = W + E)

       self.buttonRemove = Button(self.master, text = "Remove", command = self.removeItem).grid(row = 2, column = 1, sticky = W + E)

       self.buttonEdit = Button(self.master, text = "Edit", command = self.editItem).grid(row = 2, column = 2, sticky = W + E)

       self.listBox = Listbox(self.master, width=30)
       self.listBox.grid(row = 1, sticky = W + E, columnspan = 3)

       self.textBox = Text(self.master, height=5, width = 30)
       self.textBox.grid(row=3, columnspan=3, sticky=W + E + N + S)


   def get_priority_subject(self):
       return self.textBox.get('1.0', '1.0 lineend')

   def get_priority_order(self):
       return self.textBox.get('2.0', '2.0 lineend')

   def addItem(self):
       self.listBox.insert(END, self.get_priority_subject()+'  '+ self.get_priority_order())
       self.clearAll()

   def removeItem(self):
       self.listBox.delete(END)
       pass

   def editItem(self):
       pass

   def clearAll(self):
       self.textBox.delete('1.0', END)

class Client:
    pass


if __name__ == "__main__":
    root = Tk()
    GuiPart(root)
    root.mainloop()
 
Odgovor na temu

[es] :: Python :: Kako izbrisati više selektovanih itema iz listbox?

[ Pregleda: 4927 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.