takes 1 positional argument but 2 were given takes 1 positional argument but 2 were given tkinter tkinter

takes 1 positional argument but 2 were given


It is because you are providing it a positional argument here:

button = Button(self.parent, text="Check Device", command= self.adb("devices"))

command want's a callback function. and you are passing it the response from the adb method. (see here fore more: http://effbot.org/tkinterbook/button.htm)

when that line is being called, self.adb("devices") is being called. if you look at your definition of adb

def adb(self, **args):

You are only asking for 1 positional argument self and any number of keyword arguments **args then you are calling it self.adb("devices") with 2 positional arguments of self and "devices"

What you will need to do is have an intermediate method, if you want to have the adb method more general, or just put "devices" into the adb method.

edit

See also here: http://effbot.org/zone/tkinter-callbacks.htm See the section "Passing Argument to Callbacks"

edit 2: code example

If you do this, it should work:

button = Button(self.parent, text="Check Device", command=lambda:  self.adb("devices"))

and then change your function to a single * inlieu of a ** (keyword arg expansion) See here: https://stackoverflow.com/a/36908/6030424 for more explanation.

def adb(self, *args):    process = subprocess.Popen(['adb.exe', args], stdout=subprocess.PIPE, shell=True)    print(process.communicate())    #return x.communicate(stdout)


The problem is in the way you declare args: it should be *args (one asterisk) instead of **args (two asterisks). One asterisk specifies any number of positional arguments, where as two asterisks means any number of named arguments.

Also, you need to pass args correct to adb.exe:

def adb(self, *args):    process = subprocess.Popen(['adb.exe'] + args, stdout=subprocess.PIPE, shell=True)