#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui
global username
username = " "
class Home(QtGui.QWidget):
def __init__(self):
super(Home, self).__init__()
self.initUI()
def initUI(self):
font = QtGui.QFont("Arial",10,QtGui.QFont.Bold,False)
username = QtGui.QLabel('Username',self)
username.move(10,40)
username.setFont(font);
usernameEdit = QtGui.QLineEdit(self)
usernameEdit.move(100,35)
usernameEdit.textChanged[str].connect(self.onChangedusername)
usernameEdit.setFocus()
btn = QtGui.QPushButton('Login', self)
btn.move(10, 80)
btn.setFixedWidth(130)
btn.setFixedHeight(50)
btn.setStyleSheet("background-color: #FF0000") #red color
btn.clicked.connect(self.begin)
btn.setFont(font)
self.setGeometry(5, 30, 600, 300)
self.setWindowTitle('CSCI237') #Update window title to CSCI237
self.show()
def onChangedusername(self, text):
global username
username = str(text)
def begin(self):
print username
def main():
app = QtGui.QApplication(sys.argv)
ex = Home()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
- Update the window title to CSCI237 - Course Registration
- Change the Login button color. Hint: Use hex color codes
- Update the code to print ‘Hello –username-’ when the Login button is clicked.
- Add a new button called Logout that prints ‘Goodbye’ when clicked.