我的html页面中有import sys, random
from PyQt5.QtWidgets import QWidget, QGridLayout, QApplication, QGraphicsView, QGraphicsScene
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QPainter, QColor, QPen, QBrush, QColor
class Window(QWidget):
WIDTH = 800
HEIGHT = 480
SPEED = 500
def __init__(self):
super().__init__()
self.initUi()
self.initDisplay()
self.show()
def initUi(self):
layout = QGridLayout()
self.scene = GraphicsScene()
self.view = GraphicsView(self, self.scene)
layout.addWidget(self.view)
self.setLayout(layout)
def initDisplay(self):
self.resize(Window.WIDTH, Window.HEIGHT)
self.timer = QTimer()
self.timer.setInterval(Window.SPEED)
self.timer.timeout.connect(self.timerEvent)
self.isStarted = False
self.isPaused = False
self.timer.start()
def start(self):
if self.isPaused:
return
self.isStarted = True
self.timer.start(Display.SPEED)
def pause(self):
if not self.isStarted:
return
self.isPaused = not self.isPaused
if self.isPaused:
self.timer.stop()
else:
self.timer.start(Display.SPEED)
self.update()
def paintEvent(self, event):
print('paint event ...')
def timerEvent(self):
self.update()
self.view.update()
self.scene.update()
print('timer event ...')
class GraphicsView(QGraphicsView):
def __init__(self, parent, scene):
super(GraphicsView, self).__init__()
self.scene = scene
self.parent = parent
self.setScene(self.scene)
def paintEvent(self, event):
QGraphicsView.paintEvent(self, event)#########
self.setScene(self.scene)
self.scene.add_shapes()
print('view paint event')
class GraphicsScene(QGraphicsScene):
def __init__(self):
super(GraphicsScene, self).__init__()
def add_shapes(self):
self.setSceneRect(0.0, 0.0, 700.0, 450.0)
self.addRect(100, 100, 150, 150)
pen = QPen(Qt.SolidLine)
pen.setColor(Qt.red)
brush = QBrush(Qt.Dense3Pattern)
brush.setColor(Qt.darkGreen)
self.addEllipse(300, 300, 100, 100, pen, brush)
print('add shapes')
if __name__ == '__main__':
app = QApplication([])
window = Window()
sys.exit(app.exec_())
元素,它来自服务器上的php请求。
vector<int> orderedSides;
orderedSides.push_back(condition ? 1 : 0);
orderedSides.push_back(condition ? 0 : 1);
每次页面打开时我都需要重新加载此图像。在服务器端,图像始终相同。并且请求URL也一样。
服务器php
getImage.php
img
答案 0 :(得分:2)
服务器:
awk -F, -v OFS=, '{split($3,a,"");$3=a[1]a[2]"/"a[3]a[4]"/"a[5]a[6]a[7]a[8]}1' csvFile
客户端
<img alt=""
src="http://example.com/getImage.php?id=123&rnd=<php echo time(); ?>" />