repl.it
@yulin1127/

python-basic-hw21-2

Tkinter

No description

fork
loading
Files
  • main.py
  • nohup.out
main.py
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
46
47
import tkinter as tk
import math

window = tk.Tk()
window.title('Cube Volume Calculater App')
window.geometry('800x600')
window.configure(background='white')

def calculate_cube_volume():
    length = int(length_entry.get())
    width = int(width_entry.get())
    height = int(height_entry.get())
    cube_volume = length * width * height
    result = 'cube volume: ' + str(cube_volume) + ' cm3'
    result_label.configure(text=result)

header_label = tk.Label(window, text='Cube Volume Calculater')
header_label.pack()

length_frame = tk.Frame(window)
length_frame.pack(side=tk.TOP)
length_label = tk.Label(length_frame, text='length(cm)')
length_label.pack(side=tk.LEFT)
length_entry = tk.Entry(length_frame)
length_entry.pack(side=tk.LEFT)

width_frame = tk.Frame(window)
width_frame.pack(side=tk.TOP)
width_label = tk.Label(width_frame, text='width(cm)')
width_label.pack(side=tk.LEFT)
width_entry = tk.Entry(width_frame)
width_entry.pack(side=tk.LEFT)

height_frame = tk.Frame(window)
height_frame.pack(side=tk.TOP)
height_label = tk.Label(height_frame, text='height(cm)')
height_label.pack(side=tk.LEFT)
height_entry = tk.Entry(height_frame)
height_entry.pack(side=tk.LEFT)

result_label = tk.Label(window)
result_label.pack()

calculate_btn = tk.Button(window, text='calculate', command=calculate_cube_volume)
calculate_btn.pack()

window.mainloop()