# Function for clearing the contents of
# destination_field, distance_field,
# duration_field text entry boxes.
def
del_destination() :
destination_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
# function for clearing the contents of mode_field,
# distance_field, duration_field text entry boxes.
def
del_modes() :
mode_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
# Function for clearing the
# contents of all text entry boxes
def
delete_all() :
source_field.delete(0, END)
destination_field.delete(0, END)
mode_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
# Driver code
if
__name__ ==
"__main__"
:
# Create a GUI window
root =
Tk()
# Set the background colour of GUI window
root.configure(background =
'light green')
# Set the configuration of GUI window
root.geometry("500x300")
# Create a welcome to distance time calculator label
headlabel =
Label(root, text =
'welcome to distance time calculator',
fg =
'black', bg =
"red")
# Create a Source: label
label1 =
Label(root, text =
"Source:",
fg =
'black', bg =
'dark green')
# Create a Destination: label
label2 =
Label(root, text =
"Destination:",
fg =
'black', bg =
'dark green')
# Create a Choose travelling modes: label
label3 =
Label(root, text =
"Choose travelling modes: ",
fg =
'black', bg =
'red')
# Create a Distance: label
label4 =
Label(root, text =
"Distance:",
fg =
'black', bg =
'dark green')
# Create a Duration: label
label5 =
Label(root, text =
"Duration:",
fg =
'black', bg =
'dark green')
# grid method is used for placing
# the widgets at respective positions
# in table like structure .
headlabel.grid(row =
0, column =
1)
label1.grid(row =
1, column =
0, sticky ="E")
label2.grid(row =
2, column =
0, sticky ="E")
label3.grid(row =
3, column =
1)
label4.grid(row =
7, column =
0, sticky ="E")
label5.grid(row =
8, column =
0, sticky ="E")
# Create a text entry box
# for filling or typing the information.
source_field =
Entry(root)
destination_field =
Entry(root)
mode_field =
Entry(root)
distance_field =
Entry(root)
duration_field =
Entry(root)
# grid method is used for placing
# the widgets at respective positions
# in table like structure .
# ipadx keyword argument set width of entry space .
source_field.grid(row =
1, column =
1, ipadx ="100")
destination_field.grid(row =
2, column =
1, ipadx ="100")
mode_field.grid(row =
5, column =
1, ipadx ="50")
distance_field.grid(row =
7, column =
1, ipadx ="100")
duration_field.grid(row =
8, column =
1, ipadx ="100")








暂无数据