Skip to content Skip to sidebar Skip to footer

How Do I Increase The Width Of The Dropdown List Within A Spinner?

How do I increase the width of the dropdown list within a spinner? My button as you can see in the photo is small, and the values ​​in my drop-down list do not appear completel

Solution 1:

Here is an extension of Spinner that honors an option_width property:

class SpinnerWithOptionWidth(Spinner):
    option_width = NumericProperty(0)  # the new property

    def __init__(self, **kwargs):
        self.invisible_attacher = None
        super(SpinnerWithOptionWidth, self).__init__(**kwargs)


    def on_is_open(self, instance, value):
        # This method is modified from Spinner
        attacher = self
        if value:
            if self.option_width > 0:
                if self.invisible_attacher is None:
                    # The DropDown is the same width as the widget it attaches to
                    # so make an invisible widget with the desired width
                    self.invisible_attacher = Widget(opacity=0, size_hint=(None, None))
                    self.add_widget(self.invisible_attacher)
                self.invisible_attacher.pos = (self.center_x - self.option_width/2, self.y)
                self.invisible_attacher.size = (self.option_width, self.height)
                attacher = self.invisible_attacher
            # open th DropDown
            self._dropdown.open(attacher)
        else:
            if self._dropdown.attach_to:
                if self.invisible_attacher:
                    self.remove_widget(self.invisible_attacher)
                    self.invisible_attacher = None
                self._dropdown.dismiss()

Post a Comment for "How Do I Increase The Width Of The Dropdown List Within A Spinner?"