Python Forum
[Kivy] Type error:takes 1 positional argument but 2 required
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] Type error:takes 1 positional argument but 2 required
#1
From what i found online, below error should be satisfied if the called method has self included as an argument. To me it appears i have that part satisfied but i still get the error. calling the on_button method from btnAccept.bind(on_press=self.on_button)

Error:
Exception has occurred: TypeError (note: full exception trace is shown but execution is paused at: <module>) on_button() takes 1 positional argument but 2 were given File "/home/mark/Python Environments/FirstEnvProject/ClassTest6.py", line 107, in <module> (Current frame) CreateApp().run()
class MyApp(TabbedPanel):
    def __init__(self,data_base):
        super(MyApp, self).__init__()
      ...
            if str(i)=='Add':
                myTPHM.content=self.enterScreen()
        
       

    def enterScreen(self):    
        stkEnter=StackLayout(orientation='lr-tb',spacing=4)
        lbl1=Label(text='Tag No',size_hint=(.1,.04))
        lbl2=Label(text='Location',size_hint=(.1,.04))
        ...
        stkEnter.add_widget(btnAccept)

        btnAccept.bind(on_press=self.on_button)
        return stkEnter

    def on_button(self):
        self.db.insert_cattledata(self.txtTag.text,self.txtLoc.text,self.txtSex.text,self.txtType.text)
        self.txtTag.text=''
        self.txtLoc.text=''
        self.txtSex.text=''
        self.txtType.text=''
        
...
Reply


Messages In This Thread
Type error:takes 1 positional argument but 2 required - by hammer - Nov-08-2021, 11:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax Error: Positional argument follows keyword argument Rama02 3 4,158 Feb-09-2021, 06:10 PM
Last Post: deanhystad
  [Tkinter] Button command getting TypeError: radsa() missing 3 required positional arguments nonzzo 2 3,407 Apr-22-2019, 12:36 PM
Last Post: Larz60+
  Error TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk Camember_beret_baguette 1 3,853 Dec-11-2018, 08:09 PM
Last Post: Larz60+
  Qt and QtPy Edit window & argument 1 has unexpected type 'Ui_MainWindow' Error Athul 6 21,338 Aug-20-2018, 02:09 PM
Last Post: Axel_Erfurt
  [Tkinter] Takes 1 Positional Argument but 2 were Given Anysja 2 50,298 Aug-08-2018, 07:08 PM
Last Post: Anysja
  [Kivy] Error:__init__ takes no parameters antonmichel 2 3,953 Feb-12-2018, 08:27 PM
Last Post: antonmichel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020