Menu

Column of checkboxes

2022-12-16
2023-01-05
  • Nikolaos S.

    Nikolaos S. - 2022-12-16

    I am new in python and struggling to find a nice resizable and sortable listbox widget.
    Your fancy_multilistbox example is superb, but I would like to add a column of checkboxes.
    I show that in mailwasher demo of https://tktreectrl.sourceforge.net/

    Is this possible in MultiListbox widget, and how can I achieve that?

    An idea is to use an icon, like the one in fancy_multilistbox, that it would change upon click.

     

    Last edit: Nikolaos S. 2022-12-16
  • klappnase

    klappnase - 2022-12-18

    Hi,
    I have been planning to add an extended version of the MultiListbox class to the library for some time now. It is a bit of work in progress still and basically requires further testing. There may or may not be parts of the class where some API changes might be advisable, right now I am not sure about that.
    Still, I think it should be already usable as a custom widget that you could add to your own code. Among other new features it has support for checkboxes already built in.
    For now I added it to the wiki's CustomClasses page at https://sourceforge.net/p/tkintertreectrl/wiki/CustomClasses/ .
    The ExtMultiListbox module has some (for now) rather silly test code at the bottom, so you can run it as a standalone "program". The icons in column0 of this demo are checkboxes with custom icons, if you press F3 you should get the default checkbox icons instead. The other buttons F1-F7 should do some other more or less useful tests.
    If you want to give this module a try, I would appreciate any feedback about the usability of the widget's API, and of course, in case you encounter a bug an as detailed as possible bug report.

    Best regards
    Michael

     
  • Nikolaos S.

    Nikolaos S. - 2022-12-18

    I am very happy reading your reply to my request so quickly. I am going to test your new module as soon as possible.

     
  • Nikolaos S.

    Nikolaos S. - 2022-12-29

    I am testing your code today. It works quite well. I am hoping for a ScrolledExtMultiListbox class.

     

    Last edit: Nikolaos S. 2022-12-29
  • klappnase

    klappnase - 2022-12-30

    If it makes it it into the library there will certainly be a ScrolledExtMultiListbox class.
    For now you should be able to easily set one up yourself using the ScrolledWidget class. I haven't tested this, I believe it should work though, just add this snippet to ExtMultiListbox.py right before the demo code:

    class ScrolledMultiListbox(ScrolledWidget):
        '''ExtMultiListbox widget with one or two static or automatic scrollbars.
        Subwidgets are:
            listbox - TkTreectrl.ExtMultiListbox widget
            hbar - horizontal Tkinter.Scrollbar or ttk.Scrollbar
            vbar - vertical Tkinter.Scrollbar or ttk.Scrollbar
        The widget itself is a Tkinter.Frame or ttk.Frame with one additional
        configuration option:
            scrollmode - may be one of "x", "y", "both" or "auto".'''
        def __init__(self, *args, **kw):
            ScrolledWidget.__init__(self, *args, **kw)
        def _setScrolledWidget(self):
            self.listbox = ExtMultiListbox(self)
            return self.listbox
    
     

    Last edit: klappnase 2022-12-30
  • Nikolaos S.

    Nikolaos S. - 2022-12-30

    It wasn't that simple, but I managed to add ScrolledExtMultiListbox class to your library, I will upload the whole code with a demo soon.
    The only bug that I found, that is also common in ScrolledMultiListbox, is that if the widget starts with a vertical scrollbar shown then the first row that is visible is the second row (someone could accidentally miss the first row).

     
  • klappnase

    klappnase - 2023-01-01

    You are right, the ScrolledMultiListbox class should go into the ScrolledTreectrl module, sorry for that.
    The vertical scrollbar problem appears to be a treectrl issue, I don't think that something is wrong with my code here. Calling yview_moveto(0.0) after creating the contents should do the trick here.

     
  • Nikolaos S.

    Nikolaos S. - 2023-01-03

    The promised library with some test code.

     
    • klappnase

      klappnase - 2023-01-05

      Thanks for sharing.
      If someone is interested, I added a new version of the ExtMultiListbox module that includes a ScrolledExtMultiListbox class to the wiki page.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.