Aug-14-2018, 02:39 PM
(Aug-14-2018, 01:52 PM)buran Wrote:def function1(): var1 = 1 var2 = 5 result = function2(var1, var2) print(result) def function2(num1, num2): return num1 + num2 function1()in the function definition you can specify positional and/or keyword parameters. Then you will pass actual values as arguments when you call the function
http://stupidpythonideas.blogspot.com/20...eters.html
I have tried this but i get errors when i try integrating it into my code.
def entry_field_accept(): Output_IP_Address1 = "00.000.000.1" Output_IP_Address2 = "00.000.000.2" Output_Result = IPP_Test(Output_IP_Address1, Output_IP_Address2) print(Output_Result)
def IPP_Test(Output_IP_Address1, Output_IP_Address2): print("Test Start") return Output_IP_Address1 + Output_IP_Address2 print("Ping Test: ", Output_IP_Address1) print("Ping Test:", Output_IP_Address2)TypeError: IPP_Test() missing 2 required positional arguments: 'Output_IP_Address1'and'Output_IP_Address2'
If i then change my TkInter code and add the args
IPTest_Button = tk.Button(IPP, text = 'Test', command = IPP_Test(Output_IP_Address1, Output_IP_Address2), background ="#01AEAC", width=12, height=2,)NameError: name 'Output_IP_Address1 is not defined
any ideas?