I have created a UI using Python's Kivy with the following code.
#-*- coding: utf-8 -*-from kivy.config import Configfrom kivy.uix.button import ButtonConfig.set('graphics', 'width', 300)Config.set('graphics', 'height', 300)from kivy.lang import BuilderBuilder.load_string("""<AddItemWidget>: BoxLayout: size: root.size orientation: 'vertical' RecycleView: size_hint: 1.0,1.0 BoxLayout: id: box size_hint_y: 1.0 orientation: 'vertical' Spinner: id: root_spinner font_size: 8 size_hint_y: 0.2 text: 'test1' values: 'test1', 'test2', 'test3' Label: size_hint_y: 0.8 id: addButton text: "Test Label"""")from kivy.app import Appfrom kivy.uix.widget import Widgetfrom kivy.uix.button import Buttonfrom kivy.properties import StringPropertyclass AddItemWidget(Widget): def __init__(self, **kwargs): super(AddItemWidget, self).__init__(**kwargs) self.count = 0 def buttonClicked(self): self.count += 1 newButt = Button(text='Button'+ str(self.count),size_hint_y=1.0) self.ids.box.add_widget(newButt, index=1) self.ids.box.size_hint_y = 1.0 + 1.0 * self.countclass TestApp(App): def __init__(self, **kwargs): super(TestApp, self).__init__(**kwargs) def build(self): return AddItemWidget()if __name__ == '__main__': TestApp().run()
When I specified the font size for a Spinner, I noticed that the font size displayed in the dropdown did not change.
By using SpinnerOption, I can change the font size in the dropdown.
<MyOption@SpinnerOption>: font_size: 30Spinner: id: root_spinner font_size: 8 size_hint_y: 0.2 text: 'test1' values: 'test1', 'test2', 'test3' option_cls: "MyOption"
However, in this case, I need to specify the value within the scope of SpinnerOption. I tried something like this, but it didn't work.
<MyOption@SpinnerOption>: font_size: self.font_size
I have also tried the following code, but it does not work.
<MyOption@SpinnerOption>: font_size: AddItemWidget.root_spinner.font_size
How can I make the font size of the dropdown values match the font size of the root_spinner?