Skip to content

Commit a08eb8e

Browse files
committed
Added Indian Trains Railway Details in Python Scripts
1 parent 74dc273 commit a08eb8e

File tree

14 files changed

+4193
-0
lines changed

14 files changed

+4193
-0
lines changed

Python/Indian Trains Details/All_Indian_Trains.csv

Lines changed: 4025 additions & 0 deletions
Large diffs are not rendered by default.
155 KB
Loading
174 KB
Loading
169 KB
Loading
123 KB
Loading
153 KB
Loading
213 KB
Loading
192 KB
Loading
185 KB
Loading
136 KB
Loading
529 KB
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ✔ INDIAN TRAINS DETAILS
2+
- ### A "Indian Trains Details" is an application created in python with tkinter gui.
3+
- ### In this application, user can get the information about how many trains are there in India with given Train Name.
4+
- ### Along with that, this scripts also gives us details about Train No., Starting Junction and Ending Junction of each train with same Train Name.
5+
- ### for the data, used the All_Indian_Trains.csv data, and read using pandas library.
6+
7+
****
8+
9+
# REQUIREMENTS :
10+
- ### python 3
11+
- ### tkinter module
12+
- ### from tkinter messagebox module
13+
- ### pandas
14+
15+
****
16+
17+
# How this Script works :
18+
- ### User just need to download the file and run the all_indian_trains.py on their local system.
19+
- ### Now on the main window of the application the user needs to select the name of Train from the drop down OptionMenu.
20+
- ### After user has chosen the name of Train, when user clicks on the TRAIN button, he/she will be able to see the details like, how many trains are there with that name, and for each of those train, the details about Train No., Starting Junction and Ending Junction are also provided.
21+
- ### Also there is a ABOUT button, clicking on which user can see about history of indian Railway.
22+
- ### Also there is a RESET button, clicking on which user can resets both the Option Menu to default element name "Indian Institute of Technology Madras".
23+
- ### Also there is an EXIT button, clicking on which exit dialog box appears asking for the permission of the user for closing the window.
24+
25+
# Purpose :
26+
- ### This scripts helps us to easily get the details about Train No., Starting Junction and Ending Junction of all the train with selected Train Name.
27+
28+
# Compilation Steps :
29+
- ### Install tkinter, pandas
30+
- ### After that download the code file, and run ll_indian_trains.py on local system.
31+
- ### Then the script will start running and user can scroll down the drop down Option Menu of Train Names and see details for any train name.
32+
33+
****
34+
35+
# SCREENSHOTS :
36+
37+
****
38+
39+
<p align="center">
40+
<img width = 800 src="Images/1.jpg" /><br>
41+
<img width = 800 src="Images/2.jpg" /><br>
42+
<img width = 800 src="Images/3.jpg" /><br>
43+
<img width = 800 src="Images/4.jpg" /><br>
44+
<img width = 800 src="Images/5.jpg" /><br>
45+
<img width = 800 src="Images/6.jpg" /><br>
46+
<img width = 800 src="Images/7.jpg" /><br>
47+
<img width = 800 src="Images/8.jpg" /><br>
48+
<img width = 800 src="Images/9.jpg" /><br>
49+
</p>
50+
51+
****
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
3+
import tkinter
4+
from tkinter import *
5+
import tkinter as tk
6+
import tkinter.messagebox as mbox
7+
import pandas as pd
8+
9+
10+
11+
window = Tk()
12+
window.geometry("1000x700")
13+
window.title("All India Trains")
14+
15+
# ---------------------------------------------------------
16+
frameCnt = 4
17+
frames = [PhotoImage(file='Images/trains.gif',format = 'gif -index %i' %(i)) for i in range(frameCnt)]
18+
19+
cnt = 0.0
20+
def update(ind):
21+
global cnt
22+
frame = frames[ind]
23+
if(cnt == 1.0):
24+
cnt = 0
25+
cnt = cnt + 0.2
26+
ind += int(cnt)
27+
if ind == frameCnt:
28+
ind = 0
29+
label.configure(image=frame)
30+
window.after(100, update, ind)
31+
label = Label(window)
32+
label.place(x = 250, y = 100)
33+
window.after(0, update, 0)
34+
# --------------------------------------------------------------------
35+
36+
data = pd.read_csv("All_Indian_Trains.csv")
37+
train_no = data['Train no.'].tolist()
38+
train_name = data['Train name'].tolist()
39+
train_start = data['Starts'].tolist()
40+
train_end = data['Ends'].tolist()
41+
42+
train_name_distinct_set = set(train_name)
43+
train_name_distinct_list = list(train_name_distinct_set)
44+
train_name_distinct_list.sort()
45+
46+
47+
def about_fun():
48+
mbox.showinfo("Indian Train Details", "Indian Railways (IR) is a statutory body under the jurisdiction of Ministry of Railways, Government of India that operates India's national railway system.\n\nIt manages the fourth-largest railway network in the world by size, with a route length of 67,956 km (42,226 mi) as of 31 March 2020. 45,881 km (28,509 mi) or 71% of all the broad-gauge routes are electrified with 25 kV 50 Hz AC electric traction as of 1 April 2020.\n\nThe first railway proposals for India were made in Madras in 1832. The India's first train, Red Hill Railway (built by Arthur Cotton to transport granite for road-building), ran from Red Hills to the Chintadripet bridge in Madras in 1837.")
49+
50+
def train_fun():
51+
selected_name = name_var.get()
52+
s1 = "Train Name : "
53+
s1 = s1 + str(selected_name)
54+
cnt = 0
55+
s = ""
56+
for i in range(0,len(train_name)):
57+
if(train_name[i] == selected_name):
58+
s = s + "\n\n1.) Train No. : "
59+
s = s + str(train_no[i])
60+
s = s + "\n2.) Starting Junction : "
61+
s = s + str(train_start[i])
62+
s = s + "\n3.) Ending Junction : "
63+
s = s + str(train_end[i])
64+
cnt = cnt + 1
65+
66+
s2 = "\n\nThere are "
67+
s2 = s2 + str(cnt)
68+
s2 = s2 + " trains."
69+
70+
s = s1 + s2 + s
71+
# mbox.showinfo(selected_name + " Details", "Train Name : " + str(selected_name) + "\n\n1.) Train No. : " + str(train_no[i]) + "\n\n2.) Starting Junction : " + str(train_start[i]) + "\n\n3.) Ending Junction : " + str(train_end[i]))
72+
mbox.showinfo(selected_name + " Details", s)
73+
74+
# top label
75+
start1 = tk.Label(text = "ALL INDIAN TRAINS", font=("Arial", 50), fg="magenta",underline=0) # same way bg
76+
start1.place(x = 180, y = 10)
77+
78+
# label for train name ---------------------------------------------------------------------------------
79+
sel_label = tk.Label(text = "Train Name : ", font=("Arial", 30), fg="brown") # same way bg
80+
sel_label.place(x = 100, y = 480)
81+
82+
# creating the drop down menu button for selecting train name
83+
name_var = tk.StringVar()
84+
# as icon size are really small, we defined the following 7 sizes
85+
name_choices = train_name_distinct_list
86+
name_menu = OptionMenu(window, name_var, *name_choices)
87+
name_menu.config(font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3)
88+
name_menu["menu"].config(font=("Arial", 10), bg = "light yellow", fg = "blue")
89+
name_menu.place(x=350, y=480)
90+
name_var.set("Andhra Pradesh Express") # size 1 is selected as by default, and we can
91+
92+
aboutb = Button(window, text="ABOUT",command=about_fun,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
93+
aboutb.place(x =150 , y =580 )
94+
95+
trainb = Button(window, text="TRAIN",command=train_fun,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
96+
trainb.place(x =360 , y =580 )
97+
98+
def reset_label():
99+
name_var.set("Andhra Pradesh Express")
100+
101+
resetb = Button(window, text="RESET",command=reset_label,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
102+
resetb.place(x =550 , y =580 )
103+
104+
105+
def exit_win():
106+
if mbox.askokcancel("Exit", "Do you want to exit?"):
107+
window.destroy()
108+
109+
exitb = Button(window, text="EXIT",command=exit_win,font=("Arial", 20), bg = "red", fg = "blue", borderwidth=3, relief="raised")
110+
exitb.place(x =730 , y =580 )
111+
112+
113+
window.protocol("WM_DELETE_WINDOW", exit_win)
114+
window.mainloop()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
libraries used : tkinter
2+
messagebox
3+
pandas

0 commit comments

Comments
 (0)