Here, we will give a rudimentary explanation of PyQt4. Basically, proceed with reference to [this site](http://myenigma.hatenablog.com/entry/2016/01/24/113413 #Create Window). The execution environment is as follows.
--OS: Ubuntu (running in BashOnUbuntuOnWindow) --Python: 2.7 series
If you don't know how to display GUI on BashOnUbuntuOnWindow, please refer to this site to build the environment.
Part 1 explains ** how to make a main window **
makeWindow.py
#coding:utf-8
"""
A program to display a window with the smallest program
"""
import sys
from PyQt4 import QtGui
def main():
app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget() #Creating a window
w.resize(250,150) #Resize window
w.setWindowTitle('QtSample')
w.show()
sys.exit(app.exec_()) #app.exec_()Points to the cross button on the upper right
if __name__ == "__main__":
main()
makeWindow.py is a program for creating windows.
w = QtGui.QWidget()
Create a window by
w.show()
Displays a window by.
When makeWindow.py is executed, the following screen will be displayed.
Describes window size and title bar settings
To change the window size
w.resize(width,height)
Can be changed by using. Specify the width of the window as the first argument and the height of the window as the second argument.
To change the title bar
w.setWindowTitle("title")
Can be changed by using. It is changed by specifying the character string to be displayed in the title bar as an argument.
[Introduction to cross-platform GUI application creation with PyQt in Python](http://myenigma.hatenablog.com/entry/2016/01/24/113413 #Create Window) GUI by Bash on Ubuntu on Windows + Xming
Recommended Posts