PyQt5 tutorial(Drag & drop)

Fri 13 October 2017 by Little Captain

In computer graphical user interfaces, drag-and-drop is the action of (or support for the action of) clicking on a virtual object and dragging it to a different location or onto another virtual object. In general, it can be used to invoke many kinds of actions, or create various types of …

read more

PyQt5 tutorial(Widgets II)

Fri 13 October 2017 by Little Captain

QPixmap

  • A QPixmap is one of the widgets used to work with images. It is optimized for showing images on screen.
from PyQt5.QtWidgets import (QWidget, QHBoxLayout,
                             QLabel, QApplication)
from PyQt5.QtGui import QPixmap
import sys


class Example(QWidget):
    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):
        hbox …
read more

PyQt5 tutorial(Widgets)

Fri 13 October 2017 by Little Captain
  • Widgets are basic building blocks of an application. PyQt5 has a wide range of various widgets, including buttons, check boxes, sliders, or list boxes. In this section of the tutorial, we will describe several useful widgets: a QCheckBox, a QPushButton in tooggle mode, a QSlider, a QProgressBar, and a QCalendarWidget …
read more

PyQt5 tutorial(Dialogs)

Fri 13 October 2017 by Little Captain
  • Dialog windows or dialogs are an indispensable part of most modern GUI applications. A dialog is defined as a conversation between two or more persons. In a computer application a dialog is a window which is used to "talk" to the application. A dialog is used to input data, modify …
read more

PyQt5 tutorial(Events and signals)

Fri 13 October 2017 by Little Captain

Events

GUI applications are event-driven. Events are generated mainly by the user of an application. But they can be generated by other means as well; e.g. an Internet connection, a window manager, or a timer. When we call the application's exec_() method, the application enters the main loop. The …

read more

PyQt5 tutorial(Layout management)

Fri 13 October 2017 by Little Captain

Layout management is the way how we place the widgets on the application window. We can place our widgets using absolute positioning or with layout classes. Managing the layout with layout managers is the preferred way of organizing our widgets.

Absolute positioning

  • The programmer specifies the position and the size …
read more

PyQt5 tutorial(Menus and toolbars)

Fri 13 October 2017 by Little Captain

QMainWindow

The QMainWindow class provides a main application window. This enables to create a classic application skeleton with a statusbar, toolbars, and a menubar.

Statusbar

A statusbar is a widget that is used for displaying status information.

import sys
from PyQt5.QtWidgets import QMainWindow, QApplication


class Example(QMainWindow):
    def __init__ …
read more

PyQt5 tutorial(First programs)

Thu 12 October 2017 by Little Captain

Simple example

  • 用于理解程序的基本原理
import sys
from PyQt5.QtWidgets import QApplication, QWidget # The basic widgets are located in PyQt5.QtWidgets module

if __name__ == '__main__':
    # Every PyQt5 application must create an application object.
    # The sys.argv parameter is a list of arguments from a command line.
    # Python scripts can be run from …
read more

PyQt5 tutorial(Date and time)

Thu 12 October 2017 by Little Captain

QDate, QTime, QDateTime

  • PyQt5 has QDate, QDateTime, QTime classes to work with date and time.
  • The QDate is a class for working with a calendar date in the Gregorian calendar. It has methods for determining the date, comparing, or manipulating dates.
  • The QTime class works with a clock time. It …
read more

PyQt5 tutorial(Introduction)

Thu 12 October 2017 by Little Captain

PyQt5 modules

  • PyQt5's classes are divided into several modules
module function
QtCore The QtCore module contains the core non-GUI functionality. This module is used for working with time, files and directories, various data types, streams, URLs, mime types, threads or processes.
QtGui The QtGui contains classes for windowing system integration …
read more