12 January 2018

Making tooltip in GUI by python

import sys
from PyQt4 import QtGui

class Example(QtGui.QWidget):
   
     def __init__(self):
         super(Example,self).__init__()
         self.initUI()
 
     def initUI(self):
         QtGui.QToolTip.setFont(QtGui.QFont('SansSerif',10))
         self.setToolTip('This is a <b>QWidget</b> widget')
         
         btn = QtGui.QPushButton('Button',self)
         btn.setToolTip('This is a <b>QPushButton</b> widget')
         btn.resize(btn.sizeHint())
         btn.move(10,10)
         
         self.setGeometry(10,10,300,300)
         self.setWindowTitle('ToolTips')
         self.show()


def main():
    app = QtGui.QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


if __name__ == '__main__':
   main()

No comments:

Post a Comment

UVA 10679 - I Love Strings!!