Advertisement
furas

tkinter - code in two files

Apr 16th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. ### main.py ###
  2.  
  3. import tkinter
  4. from calc import calc_from_calc
  5.  
  6. mainWindow = tkinter.Tk()
  7.  
  8. entry1 = tkinter.Entry(mainWindow)
  9. entry1.grid(row=0, column=1)
  10.  
  11. entry2 = tkinter.Entry(mainWindow)
  12. entry2.grid(row=1, column=1)
  13.  
  14. buttonCalc = tkinter.Button(mainWindow, text="Calculate", command=lambda:calc_from_calc(entry1, entry2, labelResult))
  15. buttonCalc.grid(row=3, column=1)
  16.  
  17. labelResult = tkinter.Label(mainWindow, text='Result is:')
  18. labelResult.grid(row=4, column=1)
  19.  
  20. mainWindow.mainloop()
  21.  
  22.  
  23. ### calc.py ###
  24.  
  25. def calc_from_calc(arg1, arg2, arg3):
  26.     result = int(arg1.get()) + int(arg2.get())
  27.     print(result)
  28.     arg3.configure(text="Result is:{}".format(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement