1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| from PyQt5 import QtCore, QtGui, QtWidgets, QtMultimedia, QtMultimediaWidgets, uic
from PyQt5.QtWidgets import QApplication, QSizePolicy,QGridLayout,QHBoxLayout, QVBoxLayout, QInputDialog, QLineEdit, QDialog, QSlider, QStyle, QWidget, QLabel, QToolButton
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
from PyQt5.QtCore import QDir, Qt, QUrl, QSize
import matplotlib,sys,os
import matplotlib.figure
from matplotlib.figure import Figure
fn = os.path.join(os.path.dirname(__file__), 'Datas\Images\Field.png')
img=matplotlib.image.imread(fn)
class MatplotlibWidget(Canvas):
def __init__(self, parent=None, title='Title', xlabel='x label', ylabel='y label', dpi=100, hold=False):
super(MatplotlibWidget, self).__init__(Figure())
self.setParent(parent)
self.figure = Figure(figsize=(130,100),dpi=dpi)
self.canvas = Canvas(self.figure)
self.theplot = self.figure.add_subplot(111)
self.theplot.set_ylim(-3,103)
self.theplot.set_xlim(-5,110)
self.theplot.imshow(img,extent=[-6,111,-4,104])
class Ui_IBE(object):
def setupUi(self, IBE):
#Recuperation de la résolution de l'écran et calcul des coeff d'ajustement de la résolution
Get_width = QApplication.desktop().width()
Get_height = QApplication.desktop().height()
Width_Ref = 1366
Height_Ref = 768
Coeff_w = Get_width/Width_Ref
Coeff_h = Get_height/Height_Ref
fontsizer=8
#Creation de la fenetre principale
IBE.setObjectName("IBE")
IBE.resize(Get_width, Get_height)
#color background
p = IBE.palette()
p.setColor(IBE.backgroundRole(), Qt.white)
IBE.setPalette(p)
############# Image terrain de foot ###############
font = QtGui.QFont()
font.setPointSize(fontsizer)
self.mplwidget = MatplotlibWidget(IBE)
self.mplwidget.setGeometry(QtCore.QRect(-40*Coeff_w, 225*Coeff_h, 850*Coeff_w, 500*Coeff_h))
self.mplwidget.setObjectName("mplwidget")
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
if __name__ == "__main__":
import sys,os,screeninfo
app = QtWidgets.QApplication(sys.argv)
IBE = QtWidgets.QDialog()
ui = Ui_IBE()
ui.setupUi(IBE)
IBE.show()
sys.exit(app.exec_()) |
Partager