filmov
tv
Plot Forex data in GUI using PyQT5 Python, Embed Matplotlib

Показать описание
Plotting ForexData(any data) on GUI using PyQT5 and Matplotlib
you can find program below... you need to add folder location and place the file in the folder.
Let me know your comments
#---------------------------------------------------------------
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QCalendarWidget,QDateEdit
from PyQt5 import QtWidgets
from PyQt5.QtGui import QColor,QPalette
import sys
import numpy as np
import os
import pandas as pd
class Window(QMainWindow):
def __init__(self):
super().__init__()
# Title for GUI , top/left is how far from top left corner desktop screen , width/height is for GUI
title = "FOREX Plotting using PyQT5"
top = 100
left = 100
width = 1200
height = 800
# GUI property
# This is for the canvas created to use Matplotlib figure
#MyStaticMplCanvas is called to a object called canvas
#canvas function plot is called to plot random numbers
self.Readbutton = QPushButton("Read Forex data",self)
self.Read_DataPressed = 0
def ButtonAction(self):
files = ['EURUSD_M1_202002', 'EURGBP_M1_202002']
def symbol_to_path(file, base_dir=r'Folder Location starting with C: or D:'):
"""Return CSV file path given ticker symbol."""
def get_data(file):
for file in files:
index_col=0,
usecols=[0, 1],
header=None,
names=['date', 'value'])
if file == 'EURUSD_M1_202002':
df = df_temp
else:
return df
self.Read_DataPressed = 1
def ButtonAction2(self):
if self.Read_DataPressed == 1:
else:
print('Read the Data First')
class MyMplCanvas(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
FigureCanvas.__init__(self, fig)
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
def plot(self):
pass
class MyStaticMplCanvas(MyMplCanvas):
def plot(self,input_List):
window = Window()
you can find program below... you need to add folder location and place the file in the folder.
Let me know your comments
#---------------------------------------------------------------
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QCalendarWidget,QDateEdit
from PyQt5 import QtWidgets
from PyQt5.QtGui import QColor,QPalette
import sys
import numpy as np
import os
import pandas as pd
class Window(QMainWindow):
def __init__(self):
super().__init__()
# Title for GUI , top/left is how far from top left corner desktop screen , width/height is for GUI
title = "FOREX Plotting using PyQT5"
top = 100
left = 100
width = 1200
height = 800
# GUI property
# This is for the canvas created to use Matplotlib figure
#MyStaticMplCanvas is called to a object called canvas
#canvas function plot is called to plot random numbers
self.Readbutton = QPushButton("Read Forex data",self)
self.Read_DataPressed = 0
def ButtonAction(self):
files = ['EURUSD_M1_202002', 'EURGBP_M1_202002']
def symbol_to_path(file, base_dir=r'Folder Location starting with C: or D:'):
"""Return CSV file path given ticker symbol."""
def get_data(file):
for file in files:
index_col=0,
usecols=[0, 1],
header=None,
names=['date', 'value'])
if file == 'EURUSD_M1_202002':
df = df_temp
else:
return df
self.Read_DataPressed = 1
def ButtonAction2(self):
if self.Read_DataPressed == 1:
else:
print('Read the Data First')
class MyMplCanvas(FigureCanvas):
"""Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
FigureCanvas.__init__(self, fig)
QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Expanding)
def plot(self):
pass
class MyStaticMplCanvas(MyMplCanvas):
def plot(self,input_List):
window = Window()
Комментарии