[PYTHON] Introduction to PyQt4 Part 1

Overview

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 **

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.

pyqt01.png

Bonus about windows

Describes window size and title bar settings

Window size

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.

Title bar

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.

Reference site

[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

Introduction to PyQt4 Part 1
Introduction to PyQt
Introduction to Ansible Part ③'Inventory'
Introduction to Ansible Part ④'Variable'
Introduction to Python Hands On Part 1
Introduction to Ansible Part 1'Hello World !!'
Introduction to MQTT (Introduction)
Introduction to Scrapy (1)
Introduction to Scrapy (3)
Introduction to Supervisor
Introduction to Tkinter 1: Introduction
Introduction to Scrapy (2)
[Linux] Introduction to Linux
Introduction to Scrapy (4)
Introduction to discord.py (2)
Introduction to discord.py
Kaggle: Introduction to Manual Feature Engineering Part 1
[Introduction to cx_Oracle] (Part 3) Basics of Table Reference
Introduction to Web Scraping
Introduction to Nonparametric Bayes
Introduction to Python language
Introduction to TensorFlow-Image Recognition
Introduction to OpenCV (python)-(2)
Introduction to Dependency Injection
Introduction to Private Chainer
[Introduction to cx_Oracle] (Part 7) Handling of bind variables
Introduction to machine learning
[Introduction to cx_Oracle] (Part 11) Basics of PL / SQL Execution
[Introduction to cx_Oracle] (Part 13) Connection using connection pool (client side)
Introduction to Python numpy pandas matplotlib (~ towards B3 ~ part2)
AOJ Introduction to Programming Topic # 1, Topic # 2, Topic # 3, Topic # 4
Introduction to electronic paper modules
A quick introduction to pytest-mock
Introduction to dictionary lookup algorithm
[Learning memorandum] Introduction to vim
Introduction to PyTorch (1) Automatic differentiation
opencv-python Introduction to image processing
Introduction to Python Django (2) Win
Kubernetes Scheduler Introduction to Homebrew
An introduction to machine learning
[Introduction to cx_Oracle] Overview of cx_Oracle
Part 1 Attempt to code mathematics (∈)
[Introduction to pytorch-lightning] First Lit ♬
Introduction to Anomaly Detection 1 Basics
[Introduction to Systre] Fibonacci Retracement ♬
Introduction to Nonlinear Optimization (I)
AOJ Introduction to Programming Topic # 5, Topic # 6
Introduction to Deep Learning ~ Learning Rules ~
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Python Programming
[Introduction to cx_Oracle] (8th) cx_Oracle 8.0 release
Introduction to discord.py (3) Using voice
An introduction to Bayesian optimization
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
Super introduction to machine learning
Series: Introduction to cx_Oracle Contents
[Introduction] How to use open3d
Introduction to Python For, While
Introduction to Deep Learning ~ Backpropagation ~
Introduction to vi command (memorandum)