Skip to content

Instantly share code, notes, and snippets.

@ishanjain28
Created February 17, 2017 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishanjain28/fa041b57d9dc31cb917e134d62b61196 to your computer and use it in GitHub Desktop.
Save ishanjain28/fa041b57d9dc31cb917e134d62b61196 to your computer and use it in GitHub Desktop.
An Application to keep Placement Records. It takes Username, Email, Mobile Number, percentage in 12th Standard and Branch and then saves it in a text file and a CSV File and also stores Email IDs in a seperate file Made in a python work shop in College
from PyQt4 import QtGui
import sys
import math
class Placement(QtGui.QMainWindow):
def __init__(self):
super(Placement, self).__init__()
self.DrawLayout()
self.DrawFields()
self.show()
def DrawLayout(self):
self.setGeometry(100, 100, 500, 500)
self.setWindowTitle("Placement Records")
def DrawFields(self):
header = QtGui.QLabel('<h1>Placement Record</h1>', self)
header.resize(400, 100)
header.move(130, 30)
username = QtGui.QLabel('User Name', self)
username.move(20, 150)
usernameInput = QtGui.QLineEdit('', self)
usernameInput.move(100, 150)
usernameInput.resize(150, 30)
email = QtGui.QLabel('Email', self)
email.move(20, 200)
emailInput = QtGui.QLineEdit('', self)
emailInput.move(100, 200)
emailInput.resize(150, 30)
mobile = QtGui.QLabel('Mobile', self)
mobile.move(20, 250)
mobileInput = QtGui.QLineEdit('', self)
mobileInput.move(100, 250)
mobileInput.resize(150, 30)
branch = QtGui.QLabel('Branch', self)
branch.move(20, 300)
branchInput = QtGui.QLineEdit('', self)
branchInput.move(100, 300)
branchInput.resize(150, 30)
percentage = QtGui.QLabel('12th %age', self)
percentage.move(20, 350)
percentageInput = QtGui.QLineEdit('', self)
percentageInput.move(100, 350)
percentageInput.resize(150, 30)
submit = QtGui.QPushButton('Submit', self)
submit.move(180, 400)
submit.resize(140, 40)
def SubmitRecord(self):
username = usernameInput.text()
email = emailInput.text().lower()
branch = branchInput.text().upper()
percentage = percentageInput.text().split("%")[0]
mobile = mobileInput.text()
list = [username, email, branch, percentage, mobile]
fileRecord = open('placement.txt', 'a')
fileData = fileRecord.write('' + str(list) + '\n')
fileRecord.close()
emailFile = open('email.txt', 'a')
emailData = emailFile.write('' + email + '\n')
emailFile.close()
excelFile = open('placement.csv', 'a')
excelFile.write('' + username + ', ' + email + ', ' + mobile + ', ' + branch + ', ' + percentage + '\n')
excelFile.close()
usernameInput.setText('')
emailInput.setText('')
mobileInput.setText('')
percentageInput.setText('')
branchInput.setText('')
submit.clicked.connect(SubmitRecord)
app = QtGui.QApplication(sys.argv)
x = Placement()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment