Boxlayout with rounded edges and a border

Widget name: RoundedBoxLayout

This widget provides a custom made boxlayout which can have a choice of background colour, rounded corners with customizable radius and a coloured border with a variable width.

The RoundedBoxLayout class inherits from the BoxLayout class and so has all its properties like orientation, padding, spacing etc.

Following new properties are available with this custom class which can be set during its instance creation through Python or kv language.
  1. back_color - background colour to the layout.
  2. border_color - colour to the border of layout.
  3. corner_radius - curve radius for the corners.
  4. border_width - width of layout border.

Sample Output:






Code (GitHub)


Below given is the code for this custom widget in kv language.



Usage


One can look to use it directly through kv language or by defining a class in Python and adding it to other widgets via add_widget function call.

Adding the widget using kv language


kv file contents:



Python file contents:



Adding the widget through python code



Popular posts from this blog

A Label with border