Everybody has each choice I have Python 3 Tkinter Rail route Ticket Reservation The executives Framework Utilizing MySQL Data set GUI Work area Application I have the choice to compose this article. I’m composing this article to determine your questions. We ask that you comprehend this article well.
Python 3 Tkinter Railway Ticket Reservation Management System Using MySQL Database GUI Desktop App
from binhex import openrsrc
from PIL import Image, ImageDraw, ImageFont
import qrcode
import random
import os
import datetime
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',password='L2zylpdt',db='trs',port='3306')
def pnr():
num = str(input("Enter the PNR number : "))
if (num.isdigit()):
sql = "SELECT * FROM user WHERE pnr ="+num
myc = mydb.cursor(buffered=True,dictionary=True)
myc.execute(sql)
myresult = myc.fetchall()
if myresult:
for x in myresult:
data = str(x)
data=data.replace("'","")
data=data.replace("{","")
data=data.replace("}","")
data=data.replace(",","n")
print("nYour PNR status is : n",data,"n")
else:
print("Sorry no status found with PNR number : ",num)
else:
print("Please input numbers only")
rtry = int(input("1. for try againn2. for main menun"))
if rtry ==1:
pnr()
elif rtry==2:
pass
def ticketGenrate():
image = Image.new('RGB', (1920, 720), (255, 255, 255)) # properties of new image to be saved
draw = ImageDraw.Draw(image) # saving a new blank image to work it on
# Change arial to any other like Calibri, Its up to you
font = ImageFont.truetype('arial', size=45)
os.system("Title ID CARD")
list1 = ["Gomti Exp.", "Lichhwi Exp.", "Hamsafar Exp.", "Poorva Exp,.", "Janta Exp.", "Durnto Exp.", "Shatabdi Exp."]
print('nnWe Require Some Details of you')
# to store information of college
(x, y) = (560, 50)
# college = input('nEnter Your College Name: ')
title = 'Indian Railways Wishing You A Happy Journey'
color = 'rgb(0, 0, 0)'
font = ImageFont.truetype('arial', size=42)
draw.text((x, y), title, fill=color, font=font)
# to store information of college address
(x, y) = (700, 95)
# college = input('nEnter Your College Address: ')
subtitle = 'This is online generated ticket'
color = 'rgb(0, 0, 0)'
font = ImageFont.truetype('arial', size=38)
draw.text((x, y), subtitle, fill=color, font=font)
# adding an unique id number using random finction and concatinating string
(x, y) = (50, 250)
idno = random.randint(1000, 9000)
message = str('19220' + str(idno))
color = 'rgb(0, 0, 0)' # black color
font = ImageFont.truetype('arial', size=30)
draw.text((x, y), 'PNR No. ' + message, fill=color, font=font)
(x, y) = (500, 250)
rdate = str(date.strftime(" %d-%m-%Y %I:%M:%S %p"))
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Reservation date - ' + date.strftime(" %d-%m-%Y %I:%M:%S %p"), fill=color, font=font)
# to get user enterd information
(x, y) = (50, 300)
name = input('Enter Your Full Name: ')
color = 'rgb(0, 0, 0)' # black color
font = ImageFont.truetype('arial', size=30)
draw.text((x, y), 'Name - ' + name, fill=color, font=font)
(x, y) = (500, 300)
jfrom = 'Ghaziabad'
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), "Journey from - "+jfrom, fill=color, font=font)
(x, y) = (50, 350)
Gender = input('Enter Your Gender: ')
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Gender - ' + Gender, fill=color, font=font)
(x, y) = (500, 350)
jto = input('Enter your destination : ')
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Journey to - ' +jto, fill=color, font=font)
(x, y) = (50, 400)
dob = input('Enter Your age: ')
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Age - ' + dob, fill=color, font=font)
(x, y) = (500, 400)
price = str(len(jto) * 35);
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Fare - ' + price, fill=color, font=font)
(x, y) = (50, 450)
bg = input('Enter Your Blood Group: ')
color = 'rgb(255, 0, 0)' # black color
draw.text((x, y), 'Blood Group - ' + bg, fill=color, font=font)
(x, y) = (500, 450)
tno = str(len(jto) * 35 + idno);
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Train No. - ' + tno, fill=color, font=font)
(x, y) = (50, 500)
mob = input('Enter Your Mobile Number: ')
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Mobile - ' + mob, fill=color, font=font)
(x, y) = (500, 500)
tn = str(random.choice(list1));
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Train Name. - ' + tn, fill=color, font=font)
(x, y) = (50, 550)
cn = str(random.randint(11000, 91000))
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Coach No. - ' + cn, fill=color, font=font)
(x, y) = (500, 550)
sn = str(random.randint(10, 100))
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Seat No. - ' + sn, fill=color, font=font)
(x, y) = (500, 600)
doj = datetime.datetime.today() + datetime.timedelta(days=random.randint(5, 30))
doj = str(doj.strftime("%d/%m/%Y %I:%M %p"))
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Date & time of Journey. - ' + doj, fill=color, font=font)
(x, y) = (50, 600)
Address = input('Enter Your Address: ')
color = 'rgb(0, 0, 0)' # black color
draw.text((x, y), 'Address - ' + Address, fill=color, font=font)
# save the edited image in current directory.
image.save(str(name) + '.png')
# this info. is added in QR code, also add other things in str function
img = qrcode.make(str('PNR No. ' + message) + str('nName - ' + name) + str('nCoach No. - ' + cn, ) +
str('nSeat No. - ' + sn) + str('nTrain No. - ' + tno) + str('nTrain Name. - ' + tn) + str('nDate & time of Journey. - ' + doj))
img.save(str(idno) + '.bmp')
# open saved named file and save it to final image
til = Image.open(name + '.png')
# open saved qr code to save it on final image
im = Image.open(str(idno) + '.bmp')
# ph=Image.open('ds.jpg')#to open ds named photo
til.paste(im, (1300, 100)) # pasted image on named file
til.save(name + message + '.png') # saving name image with Qr as final image
# #to insert data in DB
myc = mydb.cursor(buffered=True)
query ="INSERT INTO user(pnr,name,gender,age,bg,mobile,cn,address,rdate,jf,jto,fare,tno,tna,sn,doj) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
data = (message,name,Gender,dob,bg,mob,cn,Address,rdate,jfrom,jto,price,tno,tn,sn,doj)
sql=myc.execute(query,data)
c=mydb.commit()
di=(sql,c)
if (di):
print("DAta INserted SUccessfullyn")
else:
print("no Data INserTEdn")
print('nYour Ticket Successfully generated in a PNG file ' + name + message + '.png')
img = Image.open(name + message + '.png')
img.show()
input('nPress any key to main menu') # use input yo hold the screen
print("nnWelcome! To Ticket Booking Systemn")
date = datetime.datetime.now()
formatdate = date.strftime(" %d-%m-%YtttTicket Reservation Systemttt%I:%M:%S %p")
print(
'***********************************************************************************')
print(formatdate)
print(
'********************************BY DANISH MCA**************************************')
restart = ('Y')
while restart != ('N', 'NO', 'n', 'no'):
print("nn1.Check pnr status")
print("2.Ticket Reservation")
print("3.Exit")
option = int(input("nEnter your option : "))
if option == 1:
pnr()
elif option == 2:
ticketGenrate()
elif option == 0:
exit()
from PIL import Image, ImageDraw, ImageFont
import qrcode
import random
import os
import datetime
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',password='L2zylpdt',db='trs',port='3306')
def pnr():
num = str(input("Enter the PNR number : "))
if (num.isdigit()):
sql = "SELECT * FROM user WHERE pnr ="+num
myc = mydb.cursor(buffered=True,dictionary=True)
myc.execute(sql)
myresult = myc.fetchall()
if myresult:
for x in myresult:
data = str(x)
data=data.replace("'","")
data=data.replace("{","")
data=data.replace("}","")
data=data.replace(",","n")
print("nYour PNR status is : n",data,"n")
else:
print("Sorry no status found with PNR number : ",num)
else:
print("Please input numbers only")
rtry = int(input("1. for try againn2. for main menun"))
if rtry ==1:
pnr()
elif rtry==2:
pass
def ticketGenrate():
os.system("Title ID CARD")
list1 = ["Gomti Exp.", "Lichhwi Exp.", "Hamsafar Exp.", "Poorva Exp,.", "Janta Exp.", "Durnto Exp.", "Shatabdi Exp."]
print('nnWe Require Some Details of you')
title = 'Indian Railways Wishing You A Happy Journey'
subtitle = 'This is online generated ticket'
idno = random.randint(1000, 9000)
message = str('19220' + str(idno))
rdate = str(date.strftime(" %d-%m-%Y %I:%M:%S %p"))
name = input('Enter Your Full Name: ')
jfrom = 'Ghaziabad'
Gender = input('Enter Your Gender: ')
jto = input('Enter your destination : ')
dob = input('Enter Your age: ')
price = str(len(jto) * 35);
bg = input('Enter Your Blood Group: ')
tno = str(len(jto) * 35 + idno);
mob = input('Enter Your Mobile Number: ')
tn = str(random.choice(list1));
cn = str(random.randint(11000, 91000))
sn = str(random.randint(10, 100)
)
doj = datetime.datetime.today() + datetime.timedelta(days=random.randint(5, 30))
doj = str(doj.strftime("%d/%m/%Y %I:%M %p"))
Address = input('Enter Your Address: ')
myc = mydb.cursor(buffered=True)
query ="INSERT INTO user(pnr,name,gender,age,bg,mobile,cn,address,rdate,jf,jto,fare,tno,tna,sn,doj) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
data = (message,name,Gender,dob,bg,mob,cn,Address,rdate,jfrom,jto,price,tno,tn,sn,doj)
sql=myc.execute(query,data)
c=mydb.commit()
di=(sql,c)
if (di):
print("DAta INserted SUccessfullyn")
else:
print("no Data INserTEdn")
input('nPress any key to main menu') # use input yo hold the screen
date = datetime.datetime.now()
formatdate = date.strftime("%d/%m/%YtttttTicket Reservation Systemttttt%I:%M:%S%p")
print(
'**************************************************************************************************************************')
print(formatdate)
print(
'**************************************************************************************************************************')
restart = ('Y')
while restart != ('N', 'NO', 'n', 'no'):
print("nn1.Check pnr status")
print("2.Ticket Reservation")
print("3.Exit")
option = int(input("nEnter your option : "))
if option == 1:
pnr()
elif option == 2:
ticketGenrate()
elif option == 0:
exit()
Final Words
We trust the Python 3 Tkinter Railroad Ticket Reservation The board Framework Utilizing MySQL Information base GUI Work area Application article fills your questions. Furthermore, let us know as to whether you feel a little wary. We settle your questions Much obliged.