def runtest(testname):
usrdef_sship = sship_e.get()
usrdef_username = username_e.get()
usrdef_pass = pass_e.get()
testresult = cpdiag.testname(cpdiag.ssh(usrdef_sship, usrdef_username, usrdef_pass))
messagebox.showinfo( "Results", testresult)
#Button for disk Test
disktest = Button(top, text="Disk Test", command = lambda: runtest("diskTest")
disktest.grid(row=3,column=0, sticky=W)
#Button for cpwd Test
cpwdtest = Button(top, text="CPWD Test", command = lambda: runtest("cpwdTest")
cpwdtest.grid(row=4,column=0, sticky=W)
Tried to shrink the code for what is necessary. Full code at https://github.com/elta13/cpdiag. The above code, I've been banging my head on it for some time. I'm fairly new to python and have been learning as needed during this, my first project.
I'm using Tkinter to display 3 entry fields which are working to obtain usrdef variables. Then I'm using several buttons, each will call a function from another local file cpdiag.py. Right now, I have been rewriting function for each remote function I call with the only thing that changes being the line with cpdiag."testname".(cpdaig.ssh"etc".)
Current problems: If I pass on the button runtest(diskTest), inside runtuest this prints as "function diskTest at x0xxxxx" And the code crashes with it trying to call "cpdiag.testname" which doesn't exist in the other local file cpdiag.py.
So then I figured out I could pass runtest("diskTest"), and it would print inside of runtest(). But runtest still tries to call "cpdiag.testname" from the other file. I'm realizing at this point, I don't understand how to call something remotely with a local variable.
So then I tried passing runtest("cpdiag.diskTest"), for which I incurred "'str' can't be called" or of the like.
How can I pass "testname" into runtest(), where "testname" is a function defined in other file cpdiag.py?!?!?