You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to request an additional Layout: BoxLayout.
Here is a use case from a project I am working on: I am using a GridLayout to simplify laying out the information on the screen. I have defined 4 rows and 1 column in the grid. I want each row to contain multiple Labels and a TileGrid bitmap. The allows me to position these objects without having to manually calculate all of the horizontal positions.
I created a primitive horizontal boxlayout that works with Label and TileGrid to create a Group that can be placed in the GridLayout.
Here is the code I used this works for my limited use case:
classHBoxLayout(Group):
@propertydefwidth(self):
_width=0forwinself:
ifisinstance(w, TileGrid):
_width+=w.width*w.tile_widthelse:
_width+=w.width*w.scale#_width = sum([w.width * w.scale for w in self]) #TileGrid does not have a scale attributereturn_width@propertydefheight(self):
returnmax([w.heightforwinself]) # also needs scale - but not needed for my use case.defappend(self, layer):
ifnotlen(self):
layer.x=0# the first widget starts at zeroelse:
layer.x=self.widthsuper().append(layer)
As you can see in the code above, the HBoxLayout adds height and width properties to Group, and overrides the append method to automatically position "widgets".
I would like to request an additional Layout: BoxLayout.
Here is a use case from a project I am working on: I am using a GridLayout to simplify laying out the information on the screen. I have defined 4 rows and 1 column in the grid. I want each row to contain multiple Labels and a TileGrid bitmap. The allows me to position these objects without having to manually calculate all of the horizontal positions.
I created a primitive horizontal boxlayout that works with Label and TileGrid to create a Group that can be placed in the GridLayout.
Here is the code I used this works for my limited use case:
As you can see in the code above, the HBoxLayout adds height and width properties to Group, and overrides the append method to automatically position "widgets".
Here is a simple example of the class in use:
A more robust solution would include a more general BoxLayout that supports vertical and horizontal orientations.
The text was updated successfully, but these errors were encountered: