-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyscript_3.py
More file actions
43 lines (34 loc) · 1.03 KB
/
Copy pathmyscript_3.py
File metadata and controls
43 lines (34 loc) · 1.03 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
import tkinter as tk
from tkinter import ttk
import ttkbootstrap as ttk
window = tk.Tk()
window.title("Demo")
window.geometry("300x150")
# title
title_abel = ttk.Label(master=window,
text="Miles to kilometer",
font="calibre 24 bold")
title_abel.pack()
def convert_func():
mile_input = entry_int.get()
km_output = mile_input*1.61
output_string.set(km_output)
# input field
input_frame = ttk.Frame(master=window)
entry_int = tk.IntVar()
input_frame.pack(pady=10)
entry = ttk.Entry(master=input_frame,
textvariable=entry_int)
entry.pack(side="left", padx=10)
button = ttk.Button(master=input_frame,
text="Convert",
command=convert_func)
button.pack(side="left")
# output
output_string = tk.StringVar()
output_label = ttk.Label(master=window,
text="Output",
font="Calibre 20",
textvariable=output_string)
output_label.pack(pady=5)
window.mainloop()