2

I´ve written a testprogram to simulate my error. Here´s the code:

from random import *
from tkinter import *

class match:
    def __init__(self):
        self.players = 4*[None]

    def commandos(self):
        print("show commands:")
        print("now commands for you!")

    def choice(self, choose):
        print("No choice")

class Application(Frame):

    def __init__(self, master, match):
        Frame.__init__(self, master)
        self.grid()
        self.create_widgets()
        self.match = match
        self.match.commandos()

    def create_widgets(self):
        self.submit_button = Button(self, text = "Submit", command = self.button_click)
        self.submit_button.grid(row = 2, column = 0, sticky = W)

        self.entry = Entry(self)
        self.entry.grid(row = 1, column = 1, sticky = W)

    def button_click(self):        
        choose = self.entry.get()
        while choose != 'S':
            self.match.choice(choose)
            choose = input()

root = Tk()
root.title("StackQuestion")
root.geometry("250x150")
app = Application(root, match)

root.mainloop()

When I run it I get this error:

Traceback (most recent call last):
  File "H:/Dropbox/Programmering/Python/stachquestion.py", line 40, in <module>
    app = Application(root, match)
  File "H:/Dropbox/Programmering/Python/stachquestion.py", line 22, in __init__
    self.match.commandos()
TypeError: commandos() missing 1 required positional argument: 'self'

How do I fix this? I need to fix this so I can use a GUI in my tennisprogram which I´m working on.

1 Answer 1

2

You did not created match object. (missing ())

Replace following line:

    self.match = match

with

    self.match = match()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.