-
Notifications
You must be signed in to change notification settings - Fork 258
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
Layouts should perhaps not be widgets #9
Comments
If we change this, the way to write app definitions also changes (#10). Actually, it does not, really. The difference is that with LayoutsAsWidgets you could do:
.... but you wouldn't. You would write these "layout descriptions" in each custom (high level) widget, and in the main widget/window/app. |
Idea: add |
You'd want to be able to do something like this: class MyTool(ui.Widget):
def init(self):
with ui.VBox():
self._list = ui.ListBox()
with self.HBox():
ui.Widget(flex=1) # spacer
self._filter = ui.ComboBox()
self._menu = ui.MenuButton()
... set up to make this work
def onMenuChange(self):
... etc
class MainWindow(??):
def init(self):
with ui.HSplitter():
ui.TextField(flex=1)
with ui.VBox():
self._tool = MyTool(flex=1)
self._status = ui.Label() The Actually, if Layouts are not widgets, the same applies to the DOM, so there is no difference in that respect. Where the two approaches do differ is that when Layouts are Widgets. Write an event handler: def onMenuChange(self, event):
... calc new options
self._filter.set_new_options(options)
def onMenuChange(self, event):
... calc new options
filter = event.owner.children[-1]
filter.set_new_options(options) The second one would be problematic with LayoutsAsWidgets. But you should probably use this approach anyway. But if this were a JS callback, we'd have to be able to refer to the filter object. Regardless of the approach, we need a solution for this. |
Note Layouts are Widgets in Kivy |
Layouts are widgets ("panels") in Phosphor now as well. Closing. |
I initially thought that layout being widgets made things simpler, and it also felt natural because layout are html elements too. However, it makes things less flexible. As Chris put it:
Also interesting: in both Qt and wx, a splitter is a widget, but hbox is a layout. In Qt there is the QStackedLayout, but also the QStackedWidget as a convenience.
Disadvantages of Layouts being widgets:
self._some_widget.parent
will typically not refer to self, but to a layout. To get toself
, you may need to.parent
several times. This is not a performance thing, because regardless of what we choose, the nesting is this deep in the DOM. It's about how the gui hierarchy feels to the user.Disadvantages of Layouts being separate:
someWidget.parent = myWidget.hbox
.The text was updated successfully, but these errors were encountered: