MCPcopy Index your code
hub / github.com/PyQt5/PyQt / run

Method run

Demo/Lib/BackingPaint.py:67–122  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

65 self._backingStore.flush(QRegion(self._rect))
66
67 def run(self):
68 self.resized.connect(self.resize, Qt.QueuedConnection)
69 full = os.getenv("full")
70 delay = int(1000 / 60)
71 isMac = platform.system() == "Darwin"
72
73 # create backingStore
74 self._oldSize = self._widget.size()
75 self._backingStore = QBackingStore(self._window)
76 self._backingStore.resize(self._oldSize)
77
78 # paint device
79 rect = QRect(QPoint(0, 0), self._oldSize)
80 self._backingStore.beginPaint(QRegion(rect))
81 if not self._backingStore.paintDevice():
82 print("paintDevice is None")
83 return
84 self._backingStore.endPaint()
85
86 while not self._exited.is_set():
87 if self._resized.is_set():
88 self._oldSize = self._size
89 self._backingStore.resize(self._oldSize)
90 self._resized.clear()
91
92 rect = QRect(QPoint(0, 0), self._oldSize)
93 if full is None:
94 rect = QRect(
95 randint(0, max(100, self._oldSize.width() - 100)),
96 randint(0, max(100, self._oldSize.height() - 100)),
97 randint(100, max(200, self._oldSize.width())),
98 randint(100, max(200, self._oldSize.height())),
99 )
100
101 # paint
102 self._backingStore.beginPaint(QRegion(rect))
103 device = self._backingStore.paintDevice()
104 if device:
105 painter = QPainter()
106 painter.begin(device)
107 painter.fillRect(rect, Qt.GlobalColor(randint(4, 19)))
108 painter.end()
109 self._backingStore.endPaint()
110 if isMac:
111 self._rect = rect
112 QMetaObject.invokeMethod(
113 self._widget,
114 "paintOnGui",
115 Qt.QueuedConnection,
116 )
117 else:
118 self._backingStore.flush(QRegion(rect))
119
120 self.msleep(delay)
121
122 print("paint thread end")

Callers

nothing calls this directly

Calls 5

randintFunction · 0.85
resizeMethod · 0.45
clearMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected