-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (36 loc) · 1.08 KB
/
main.py
File metadata and controls
45 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import tkinter as tk
# from tkinter import ttk
import ttkbootstrap as ttk
def main():
def convert():
mile_input = entry_int.get()
km_output = mile_input * 1.61
print(entry_int.get())
output_string.set(km_output)
# window
window = ttk.Window(themename="darkly")
window.title("Demo")
window.geometry("300x150")
# title
title_label = ttk.Label(master=window, text="Miles to kilometers", font="Arial 20")
title_label.pack()
# input_field
input_frame = ttk.Frame(master=window)
entry_int = tk.IntVar()
entry = ttk.Entry(master=input_frame, textvariable=entry_int)
button = ttk.Button(master=input_frame, text="Convert", command=convert)
entry.pack(side="left", padx=10)
button.pack(side="left")
input_frame.pack(pady=10)
# output
output_string = tk.StringVar()
output_label = ttk.Label(
master=window,
text="Output",
font="Calibri 30",
textvariable=output_string)
output_label.pack()
# run
window.mainloop()
if __name__ == '__main__':
main()