how to print the text inputs from the loop in kivy

Hashem

i want to print all user text inputs when i press the button. the problem when i press the button to print the inputs appear the error TypeError: p() takes 1 positional argument but 2 were given. just to know the number to text inputs may vary from user to other

from kivy.uix.textinput import TextInput
from kivy.app import App
from kivy.uix.button import Button
from kivy.lang.builder import Builder

kv=Builder.load_string('''
ScrollView:
    GridLayout:
        id:inputs
        cols:1
        row_force_default:True
        row_default_height:30
        size_hint_y:None
        height:self.minimum_height
''')

class Accounting(App):
    def build(self):return kv

    def on_start(self):
        self.return_list = [] #print this list
        w = Button(text='print all the text inputs',on_press=self.p)
        self.return_list.append(w)
        self.root.ids.inputs.add_widget(w)
        for i in range(5):
            w = TextInput()
            self.return_list.append(w)
            self.root.ids.inputs.add_widget(w)
        return self.return_list

    def p(self):print(self.return_list)#here

Accounting().run()
furas

When you click button then Kivy runs it with extra argument p(widget) so you can assign function to many buttons and you will see which button was clicked.

But it means you have to get this value in function

    def p(self, widget):

Minimal working code.

If you want text only from TextInput then removed Button from return_list.

from kivy.uix.textinput import TextInput
from kivy.app import App
from kivy.uix.button import Button
from kivy.lang.builder import Builder

kv = Builder.load_string('''
ScrollView:
    GridLayout:
        id:inputs
        cols:1
        row_force_default:True
        row_default_height:30
        size_hint_y:None
        height:self.minimum_height
''')

class Accounting(App):
    
    def build(self):
        return kv

    def on_start(self):
        self.return_list = [] #print this list
        
        w = Button(text='print all the text inputs', on_press=self.p)
        self.return_list.append(w)
        self.root.ids.inputs.add_widget(w)
        
        for i in range(5):
            w = TextInput()
            self.return_list.append(w)
            self.root.ids.inputs.add_widget(w)

        return self.return_list

    def p(self, widget):
        print('widget:', widget)
        print('text  :', widget.text)
        
        for item in self.return_list:
            print(item.text)

Accounting().run()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to print the output out of for loop when users in enters inputs

How to loop & print line 1 then line 2 from 2 different text files

How to search from API based on text inputs in REACT

How to print a different value from a list in a loop?

How to get inputs from user and save them in a list(Python Kivy)?

Kivy: How to update 'Label's' text with text from 'TextInput'?

How to print a text value on Kivy Screen

Generating a loop from multiple inputs

Kivy: How to load images from a list by a for loop?

How to check if text inputs and a select are different from original value?

How to print button text value on console in Kivy

print text from while loop on a single line in python

How do I take all of the user inputs in a while loop and put them into a print statement

how to print a for loop output into a text file?

How to print one answer from two different inputs in Python 3?

How to add multiple Inputs from the same loop

how i can save inputs from html page to text file

Not able to print the text taken from kivy.uix.textinput.TextInput in KIVY Python

How to Print Images From The Web In a For Loop

how to return value from widget in the loop in kivy

How can we add inputs in a loop and then further print these inputs in other nested loop?

How to use a loop to print a statement a number of times defined by user inputs on visual basic

How do I print the total from the users inputs?

How to grab the text from a kivy button?

How to print all inputs of string from a for loop?

How can I render multiple text inputs with a for loop?

How to populate text inputs with data values from Chosen multiselect?

How to make a dataframe from print result in for loop

How to print parameters of an output from a loop in R?