You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried to delete selected items in ListBox and to log witch items should be deleted.
Deleting works with DeleteSelected(), but for logging I need to iterate over the list and if I use Selected[i]-property I get an error.
Error in getting property "Selected".
Error: Unknown attribute
Here a minimal:
# from delphivcl import *importdelphivclasvclimportlogginglogging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
classMyApp(vcl.Form):
def__init__(self, Owner):
self.Caption="MyApp"self.SetBounds(100,100,700,500)
# Button delself.del_task_btn=vcl.Button(self)
self.del_task_btn.SetProps(
Parent=self,
Caption="Delete Task",
OnClick=self.__del_task_on_click
)
self.del_task_btn.SetBounds(150, 120, 100, 30)
# Listboxself.list_of_tasks=vcl.ListBox(self)
self.list_of_tasks.SetProps(
Parent=self,
MultiSelect=True,
)
self.list_of_tasks.SetBounds(300, 50, 300, 350)
self.OnClose=self.__on_form_closeself.__fill_list()
def__on_form_close(self, Sender, Action):
Action.Value=vcl.caFreedef__del_task_on_click(self, Sender):
msg=f"{Sender.Caption}"lot=self.list_of_tasks# Delete only if at least one string in the list box is selectediflot.SelCount>0:
logging.debug(f"Selected items: {lot.SelCount}")
msg+=":\n\t"+'\n\t'.join([lot.Items[i] foriinrange(lot.Items.Count) iflot.Selected[i]])
lot.DeleteSelected()
else:
iflot.ItemIndex>-1:
msg+=f": {lot.Items[lot.ItemIndex]}"lot.Items.Delete(lot.ItemIndex)
else:
msg+=f": {lot.Items[0]}"lot.Items.Delete(0)
logging.debug(msg)
def__fill_list(self):
lot=self.list_of_tasksforiinrange(10):
lot.Items.Add(str(i))
defmain():
vcl.Application.Initialize()
vcl.Application.Title="TODO App"app=MyApp(vcl.Application)
app.Show()
# vcl.FreeConsole()vcl.Application.Run()
app.Destroy()
main()
BR ramooon1
The text was updated successfully, but these errors were encountered:
Hi @ramooon1 . I'm able to reproduce the issue. Yes, the Selected property of ListBox is not wrapped properly in the automatic wrapping process. We need to wrap it manually. We will add this wrap in our next release. Thank you for your notice and please keep posting any further issues you might face.
First of all:
I've tried to delete selected items in ListBox and to log witch items should be deleted.
Deleting works with
DeleteSelected()
, but for logging I need to iterate over the list and if I useSelected[i]
-property I get an error.Here a minimal:
BR ramooon1
The text was updated successfully, but these errors were encountered: