Advertisement
dimkiriakos

Διαίρεση

Jan 22nd, 2022
1,110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tkinter as tk
  2.  
  3. def divide():
  4.     try:    
  5.         divider1 = float(divider1_entry.get())
  6.         divider2 = float(divider2_entry.get())
  7.         if divider2 !=0:
  8.             result = divider1 / divider2
  9.             result_label.config(text=str(result))
  10.     except Exception as e:
  11.         print(e)
  12.  
  13.  
  14. root = tk.Tk()
  15. root.title('Διαίρεση σε παραθυρικό περιβάλον')
  16. root.geometry('200x200')
  17.  
  18.  
  19. divider1_label = tk.Label(text='Διερεταίος')
  20. divider1_label.pack()
  21.  
  22. divider1_entry = tk.Entry(root, justify=tk.CENTER)
  23. divider1_entry.pack()
  24.  
  25. divider2_label = tk.Label(text='Διερέτης', justify='center')
  26. divider2_label.pack(pady=10)
  27.  
  28.  
  29. divider2_entry = tk.Entry(root, justify=tk.CENTER)
  30. divider2_entry.pack()
  31.  
  32. divide_button = tk.Button(text='Εκτέλεση', justify='center', command=divide)
  33. divide_button.pack(pady=20)
  34.  
  35. result_label = tk.Label(text='Πυλίκο', justify='center')
  36. result_label.pack()
  37.  
  38.  
  39. root.mainloop()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement