-
-
Notifications
You must be signed in to change notification settings - Fork 674
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
SimpleTree widget #1767
Comments
Agreed that this is a problem that needs a solution - Tree on Winforms (and Android/iOS for that matter) is one of the last big missing pieces. Obviously the ideal case would be a fully-featured "TreeTable" on Winforms; but that's obviously going to be a complicated prospect given the "native" control that is available. I'm not sure how I feel about having multiple tree widgets; If we're going to take this approach, the second option ("Tree" and "TreeTable") is the more appealing - but I'm not sure how we'd deal with the issue with backwards compatibility. However, I don't think the third approach is necessarily as "magical" as you describe. I can see 2 possible API-level signals to control what style of tree is displayed:
In the macOS/GTK case, we'd change the behavior to hide the header row unless the user explicitly specified a header (which would then necessitate that they define an accessor list). The rest of the widget would be largely as-is. We might also want to modify "accessors" to allow for a single string accessor, in addition to a list of accessors. In the Windows case, we'd only (initially) support a reduced feature set:
Looking at iOS/Android, I'm guessing Tree won't manifest as a traditional desktop "expand the triangle to see the child tree nodes" tree, but as a Navigation hierarchy - show the list of top level items; if you click on one, you navigate "deeper" into the tree. Does that make sense as an approach? |
I like this idea. If the user doesn't specify headings, what else could we do?
You mean the
That indeed makes for a straightforward implementation . But a bit odd in the case of the most basic usage of the widget, e.g.:
Maybe we should synthesize an accessor for this case? |
We could potentially synthesise headings from the accessors... but I don't think that's an especially good idea. Best to keep the two
Yes, I was referring to the In terms of the two edge cases you describe:
I'm not sure I follow where the confusion/problem is though. What I'm proposing is a strict separation of concerns:
Accessors can be inferred from headings, if headings are provided. If you're not displaying headings, you need to give some signal to the tree on what needs to be displayed (with one caveat for the 'basic usage' that you mention - discussed below)
Agreed - I guess I should clarify my API specification as:
tl;dr - Tree will try to make the most of whatever it's given. Specifying headings is an explicit signal to display them; accessors describe how many columns there will be; accessors can be implied from headings, if they're provided, or the data allows. |
Thank you for the detailed reply - I'm always impressed how much thought you put into these. I still a few questions: 1.
You mean If you mean 2.There's one case missing in yout API specification (the Tree widget is really very versatile):
Here's an example:
3.Off-topic from the header issue, but on-topic for the tree widget: in the case of "a dict of list/tuples as keys" (the example above) for some reason the items are sorted by the Tree widget. Weird. |
Yeah - I didn't think about that enough. What I was aiming for was using "cardinality of the first leaf node" as an indicator of the number of columns; however, as you've pointed out, that's potentially ambiguous: is Mapping primitive data structures into trees is always going to be a little ambiguous; the best we can do is try to make sure that it's at least predictably ambiguous. I'm definitely open to suggestions here - and I'm not fundamentally opposed to breaking some existing use cases if it makes the overall situation more explicit and less ambiguous.
I think that follows - although there's possibly an ambiguity around a 2-item tuple where the first item is an icon. The more I think about this, the more I'm becoming convinced it might be desirable to lock down the number of possible forms that truly "free-form" primitive data can take, with a view to being very clear about how many columns there are, and what those columns are. It's annoying that this may lock out some existing use cases, but otherwise we're going to tie ourselves in knots trying to reason about what input data "means" in terms of tree rendering.
I can't say for sure, but my guess is that this was done for testing consistency. Some of this code predates Python 3.6, and prior to Python 3.6, dictionary order wasn't guaranteed - so testing was unreliable as you couldn't guarantee iteration order. Dictionary iteration is now guaranteed to be insertion order, so the sort is probabaly not needed. Probably :-) |
I'm back. Apologies for the long absence. Below is my try at documenting the form primitive data can take. I made up some concept names (collection, nodes, cells). I'm not a huge fan of the names I came up with, but I found it hard to explain without assigning names to the concepts. In the meantime, I'm working on tests (and migrating to pytest). I'll submit a PR soon.
|
Welcome back :-) I'm not sure if you've noticed, but we're in the process of doing a complete audit of all the widgets, including trying to get them all to 100% pytest coverage and fully documented, including documenting the related data constructs. |
Reopening this since we opted to not implement it as part of this pass of Tree. |
The issue I raised has been implemented: providing no Of course, there's still no winforms implementation, but that's a different issue. The implementation for "primitive data" is quite different from the discussion on this ticket, but at least it is documented now. So, as far as I'm concerned, this issue can be closed. |
Yeah - it's probably better to close this, and open a separate ticket (once the audit is complete) to backfill the Windows Tree widget specifically. |
What is the problem or limitation you are having?
My use case calls for a Tree widget with a single column.
The current implementation (on macOS) always displays the header. The result is weird.
I also noticed the winforms implementation of the Tree widget is
not_implemented
. Which makes sense, because it seems winforms' TreeView only allows for a single column.Describe the solution you'd like
I purpose a new
SimpleTree
widget that implements this behavior. Basically aTree
widget that allows only a single column, and does not show a header.The
SimpleTree
could be implemented in winforms.Describe alternatives you've considered
header_visible
parameter to the Tree widget. But the winforms implementation would still be incomplete.Tree
, and the current widget be renamedTreeTable
orHierarchicalTable
. But that might be too much of a breaking change.Additional context
How to hide the header:
macOS
I couldn't find apple docs on it, but there are online sources, e.g. https://stackoverflow.com/questions/3514210/hiding-nstableview-header#63551501
GTK
https://docs.gtk.org/gtk3/method.TreeView.set_headers_visible.html
The text was updated successfully, but these errors were encountered: