racket / racket/gui

List-box class needs rewrite

Open
#147 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
68
Forks
82
PR merge metrics
No merged PRs in 30d

Description

The list-box class needs a re-write in a bad way.

Required fields

image

Instantiating a list-box should not require you to define choices for the list-box. It should be optional, so that the user can populate it when they are ready. This is basic Object-oriented thinking. The list-box could be very useful for presenting search results to a user for selection, but doing so is miserable. For a work-around, I had to use an empty string to initiliaze the choices, keeping the list-box hidden, then use the set method with empty lists (send blah set (list ) (list )) to clear it out before showing the list-box and populating the fields.

Set method

image

Also, the set method is dumb, because it clears the list for no reason. This makes no sense at all. It makes this function completely useless for typical use-cases of list-box.

Append

image

https://docs.racket-lang.org/gui/list-box_.html?q=gui#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._list-box~25%29._append%29%29

Also, the append method does not allow populating all fields when adding a new entry, if there is more than 1 column to populate. This is a weird limitation. As a work-around, I had to first populate the new list item's first column with append and then populate the remainder of the fields using set-string. This is not intuitive at all. Also, the [data] field is confusing. People who are making GUIs will read that to mean "the data I want displayed will go here". This is a bad name for that field. In this context, you cannot use "data" to describe something that is not visible. Try something unused like "arb" You can define an arb data type as "arbitrary data" in another doc entry. This will resolve the conflict between the user's definition of "data" and Racket's definition.

The right way:

  • Make choices optional.
  • Get rid of the set function (replaced by append below)
  • Provide essential methods:
    • append
      (send a-list-box append (list* field1 field2 field3 ...) [(list* arb1 arb2 arb3 ...)]
      
      Creates a new row. Takes a list of strings and a list of arbitraries. Assigns each string to a corresponding field in the row.
      (send a-list-box append
                      (list* (list* field1 field2 field3 ...)
                             (list* field1 field2 field3 ...)
                             .
                             .
                             .
                             )
                      [(list* (list* arb1 arb2 arb3 ...)
                              (list* arb1 arb2 arb3 ...)
                              .
                              .
                              .
                              )])
      
      Appends a list of string-lists (a 2D array), so the user can add n new entries to the list.
    • insert
      (send a-list-box insert (blah))
      
      where blah is the same kind of structure shown above in append.
    • clear - clear the contents.
      (send a-list-box clear)
      

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the list-box class and its documented set, append, and data interfaces, using the linked list-box documentation. Compare the current behavior with the requested optional choices, row insertion and population, clearing, and naming changes; done would require an agreed API redesign plus implementation and validation.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.