Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListBox does not have all Properties in Python #31

Open
ramooon1 opened this issue Jul 22, 2022 · 2 comments
Open

ListBox does not have all Properties in Python #31

ramooon1 opened this issue Jul 22, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ramooon1
Copy link

First of all:

  • System: Windows 10 x64 Version 2004
  • Python: 3.10.4
  • delphivcl: 0.1.40

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 *
import delphivcl as vcl
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)

class MyApp(vcl.Form):
    
    def __init__(self, Owner):
        self.Caption = "MyApp"
        self.SetBounds(100,100,700,500)
        
        # Button del
        self.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)
        
        # Listbox
        self.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_close
        
        self.__fill_list()

    def __on_form_close(self, Sender, Action):
        Action.Value = vcl.caFree
    
    def __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 selected
        if lot.SelCount > 0: 
            logging.debug(f"Selected items: {lot.SelCount}")
            msg += ":\n\t" +'\n\t'.join([lot.Items[i] for i in range(lot.Items.Count) if lot.Selected[i]])
            lot.DeleteSelected()
        else:
            if lot.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_tasks 
        for i in range(10):
            lot.Items.Add(str(i))
        
    
def main():
    vcl.Application.Initialize()
    vcl.Application.Title = "TODO App"
    app = MyApp(vcl.Application)
    app.Show()
    # vcl.FreeConsole()
    vcl.Application.Run()
    app.Destroy()
        
main()

BR ramooon1

@Priyatham10
Copy link
Member

Priyatham10 commented Jul 23, 2022

Thank you for your interest. Let me reproduce the issue and confirm whether the wrap of Selected property of ListBox component is working or not.

@Priyatham10 Priyatham10 self-assigned this Jul 23, 2022
@Priyatham10
Copy link
Member

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.

@Priyatham10 Priyatham10 added the enhancement New feature or request label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants