Monthly Archives: April 2017

pyqt5 sliders

PyQt5 comes with sliders out of the box. Sliders can be either vertical or horizontal. We can connect them with a method the same way as we do with buttons. A slider is often used in conjunction with a spinbox, QSpinBox. In this example we won’t use a spinbox, as that’s optional. You can connect […]

pyqt textarea

QPlainTextEdit is a multiline text area in PyQt. To set the text, we use its method insertPlainText(). We can set its position and size using the methods move() and resize(). Textarea The example below creates a text area using PyQt5. We will create the usual QMainWindow to add the widget to. It is just for […]

pyqt checkbox

A checkbox can be created using the QCheckBox widget. When creating an new checkbox with the QCheckBox class, the first parameter is the label. To apply actions to the toggle switch, we call .stateChanged.connect() followed by a callback method. When this method is called, it sends a boolean as state parameter. If checked, its the […]

pyqt combobox

A combobox can be created with the QComboBox class. Items are added using the class method addItem, followed by a string parameter. Sometimes its called a listbox, as it shows a list of items a user can select from. If you want a user to choose from a set of items, the listbox is the […]

pyqt clipboard

The clipboard holds data you copy and paste. You can copy text from one program to another, like copying text from a website into notepad. We will create a program that has access to the clipboard using PyQt. If we copy text from any program, it will be added into the textarea of the PyQt […]

webkit browser

The widget QWebView can be used to render webpages. QWebView uses the QtWebkit web browsing module. To show a website simply call the load(url) method. QWebview suports navigational functions: forward(), back(), reload(), stop(). Note: QWebView only shows the webpage contents. Code for a python webbrowser below. python webbrowser In the example below we have a […]

pyqtgraph bar chart

The module pyqtgraph supports all kinds of charts and scientific graphics. Underneath, pyqtgraph uses PyQt4 / PySide and numpy. Its been tested to work on Linux, Windows, and OSX. In this article we’ll create an example bar chart. The output will be this awesome chart: pyqtgraph barchart We create the data to plot (x y1) […]

pyqtgraph plot

A simple plot can be created with the module pyqtgraph. Mind you, it’s one of the libraries for plotting, there are others like matplotlib. We start with importing pyqtgraph and defing the plotting data (x and y). Then we plot the data using pg.plot(). pyqtgraph plot The example below creates a plot using pyqtgraph.

[…]