Showing posts with label Python GUI Programming. Show all posts
Showing posts with label Python GUI Programming. Show all posts

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()

11 January 2018

Set Window Icon in Python Gui Programing

import sys
from PyQt4 import QtGui

class Example(QtGui.QWidget):
   
    def __init__(self):
       super(Example,self).__init__()
       self.initUi()

    def initUi(self):
       self.setGeometry(10,10,300,300)
       self.setWindowTitle('Windo ICON')
       self.setWindowIcon(QtGui.QIcon('icon.png'))
       self.show()



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


if __name__ == '__main__':
    main()

Python Basic Gui

#To make a simple gui follow the instructions. You need to at first install PyQt4 in your system. If you use linux run the code sudo apt-get install python3-pyqt4. For another system you just need to setup an application file. Google it for this. After installing pyqt4 modulo just write down the foling code. it will show you a simple gui.

import sys
from PyQt4 import QtGui


def main():
   
    app = QtGui.QApplication(sys.argv)

    w = QtGui.QWidget()
    #w.resize(250, 150)
    #w.move(300, 300)
    w.setGeometry(10,10,400,400)
    w.setWindowTitle('Simple GUI in Python')
    w.show()
   
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()

UVA 10679 - I Love Strings!!