MCPcopy Create free account
hub / github.com/PyQt5/PyQt / __init__

Method __init__

QMessageBox/CountDownClose.py:24–37  ·  view source on GitHub ↗
(self, *args, count=5, time=1000, auto=False, **kwargs)

Source from the content-addressed store, hash-verified

22class MessageBox(QMessageBox):
23
24 def __init__(self, *args, count=5, time=1000, auto=False, **kwargs):
25 super(MessageBox, self).__init__(*args, **kwargs)
26 self._count = count
27 self._time = time
28 self._auto = auto # 是否自动关闭
29 assert count > 0 # 必须大于0
30 assert time >= 500 # 必须>=500毫秒
31 self.setStandardButtons(self.Close) # 关闭按钮
32 self.closeBtn = self.button(self.Close) # 获取关闭按钮
33 self.closeBtn.setText('关闭(%s)' % count)
34 self.closeBtn.setEnabled(False)
35 self._timer = QTimer(self, timeout=self.doCountDown)
36 self._timer.start(self._time)
37 print('是否自动关闭', auto)
38
39 def doCountDown(self):
40 self.closeBtn.setText('关闭(%s)' % self._count)

Callers

nothing calls this directly

Calls 2

setTextMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected