Advertisement
Rnery

Temperature converter in ttk

Apr 7th, 2022 (edited)
890
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | Source Code | 1 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. # pip install ttkbootstrap (Instale essa belezinha)
  5.  
  6. import ttkbootstrap as ttk
  7. from ttkbootstrap.constants import *
  8.  
  9. root = ttk.Window(themename="journal")
  10.  
  11. def calcular():
  12.     F = float(textbox_one.get())
  13.     C = (F-32) * 5/9
  14.     valor_final.set(str(round(C, 1)) + 'ºC Graus Celsius')
  15.  
  16.  
  17. valor_final = ttk.StringVar()
  18.  
  19. label_one = ttk.Label(root, text='Graus Fahrenheit:',
  20.                       bootstyle='info')
  21. label_one.place(x=100, y=10)
  22.  
  23. textbox_one = ttk.Entry(root)
  24. textbox_one.place(x=100, y=35)
  25.  
  26. button_one = ttk.Button(root, text='Calcular',command=lambda:calcular(),
  27.                       bootstyle=(INFO, OUTLINE))
  28. button_one.place(x=100, y=75)
  29.  
  30. label_two = ttk.Label(root, textvariable=valor_final, bootstyle='info')
  31. label_two.place(x=100, y=120)
  32.  
  33. root.title('App - Conversor de Temperatura')
  34. root.resizable(False, False)
  35. root.eval('tk::PlaceWindow . center')
  36. root.geometry('350x150')
  37. root.mainloop()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement