Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw a K chart of Maotai stock in GUI window

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to draw a Maotai stock K chart in the GUI window. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Integrating graphical tools in GUI is a common feature of many desktop programs, the most common of which is the price trend chart in various investment trading tools. For example, the index trend of the stock, the K-chart of the stock and so on.

There are many ways to integrate drawing functions into PyQt applications, such as:

OpenGL: a powerful 2D and 3D professional graphics drawing tool

A classic graphics drawing module in Matplotlib:Python

PyQtGraph: based on the Qt platform, it provides interactive data display and graphic rendering.

All kinds of graphics rendering schemes have their own advantages, but in terms of integration with PyQt programs, it still belongs to PyQtGraph.

PyQtGraph has many advantages in drawing graphics:

Have a rich variety of graphics

Can quickly update drawing data in real time

Be able to operate interactively

Multiple tagging functions

……

The installation of PyQtGraph is simple, and you can install it directly using pip:

After installation, you can use the import introduction directly in the Python code.

PyQtGraph comes with a rich sample module, which we enter in the code:

The GUI program of the sample manual is automatically opened:

We can choose an example to run:

Let's take a look at how to call the graphics drawn by PyQtGraph in PyQt

Integrate pyqtgraph graphics in GUI

Festive customs

In PyQtGraph, there are several ways to draw graphics:

Pyqtgraph.plot (): create a new drawing window to display data

PlotWidget.plot (): add a new set of data to an existing drawing widget

PlotItem.plot (): add a new set of data to an existing drawing widget

GraphicsLayout.addPlot (): add a new drawing to a graphics layer

According to the drawing methods of PyQtGraph, we can display graphics in the widget or in a new window in PyQt.

Below we show the K diagram of Maotai stock in the past half a year in the widget as an example of integrated display of PyQtGraph graphics in PyQt.

First, add a tab to the GUI we created earlier and place a VerticalLayout layer layout in it:

Then, in accordance with the convention, convert the UI file to a Python file and create a new Python file to import.

Based on the example of PyQtGraph, let's create a new class CandlestickItem that draws a K-diagram:

Then, we create a function chart (), which is used to get the historical data of the stock through the tushare module, and pass the data into the previously defined class used to generate the K diagram:

Next, the call is made in _ init_ (self) of the main class MainWindow () of the GUI program:

Finally, we run the code:

In this way, PyQtGraph's graphics are integrated into the tab as a widget.

On how to draw a Maotai stock K diagram in the GUI window to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report