I just have a simple tabbed panel with a TextInput object which when clicked should open up a numpad screen which should populate TextInput once enter is clicked. This did work in Kivy 1.90 by my memory though I've heard some new changes have changed the way arguments are inherited.
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.tabbedpanel import TabbedPanel,TabbedPanelItem
from kivy.uix.textinput import TextInput
class ValveInput(TextInput):
def __init__(self, **kwargs):
super(ValveInput, self).__init__(**kwargs)
def my_callback(instance):
self.text = num_pad.ids.num_label.text
self.popup.dismiss()
def on_touch_down(self, touch):
if self.collide_point(touch.x, touch.y):
prompt_content = BoxLayout(orientation='vertical') # Main layout
num_pad = ValveNumWidget()
prompt_content.add_widget(num_pad)
self.popup = Popup(id='num_pad_popup', title='Enter value', content=prompt_content, autodismiss=False)
num_pad.ids.enter_btn.bind(on_press=my_callback)
# Open the pop-up:
self.popup.open()
class RootWidget(FloatLayout):
def __init__(self):
super(RootWidget, self).__init__()
self.button = ValveInput(id='valve_input',text='',values=('0', '1','2','3','4','5'))
home_window = TabbedPanelItem(text="Pumps")
home_window.add_widget(self.button)
main_window = TabbedPanel(do_default_tab=False)
main_window.add_widget(home_window)
self.add_widget(main_window)
def button_clicked(self, button):
print(self.button.text)
class MainApp(App):
def build(self):
return RootWidget()
if __name__ == '__main__':
MainApp().run()
<ValveNumWidget>:
BoxLayout:
size: root.size
pos: root.pos
orientation: 'vertical'
BoxLayout:
size_hint_y: 1
id: num_label
Label
id: num_label
text: ''
BoxLayout:
size_hint_y: 5
orientation: 'vertical'
BoxLayout:
BoxLayout:
Label:
text: 'Switching Valve'
BoxLayout:
NumPadButton:
id: num_zerosw
text: '1'
on_press: num_label.text = '1'
NumPadButton:
id: num_onesw
text: '2'
on_press: num_label.text = '2'
BoxLayout:
BoxLayout:
Label:
text: 'Multi-Channel Pump'
BoxLayout:
NumPadButton:
id: num_O
text: 'O'
on_press: num_label.text = 'O'
NumPadButton:
id: num_I
text: 'I'
on_press: num_label.text = 'I'
BoxLayout:
BoxLayout:
Label:
text: 'Single-Channel'
BoxLayout:
NumPadButton:
text: '0'
id: num_zero
on_press: num_label.text = '0'
NumPadButton:
text: '1'
id: num_one
on_press: num_label.text = '1'
NumPadButton:
text: '2'
id: num_two
on_press: num_label.text = '2'
NumPadButton:
text: '3'
id: num_three
on_press: num_label.text = '3'
NumPadButton:
text: '4'
id: num_four
on_press: num_label.text = '4'
NumPadButton:
text: '5'
id: num_five
on_press: num_label.text = '5'
NumPadButton:
text: '6'
id: num_six
on_press: num_label.text = '6'
BoxLayout:
BoxLayout:
size_hint_x: 3
NumPadButton:
id: enter_btn
text: 'Enter'
Any help appreciated -- I'm fairly sure it is a quick fix but unsure how to proceed.