Untitled
unknown
plain_text
2 years ago
1.6 kB
1
Indexable
Never
try: from PySide.QtGui import * from PySide.QtCore import * except ImportError: from PySide2.QtWidgets import * from PySide2.QtCore import * from pyautogui import typewrite import sys, time, threading class mainwindow(QWidget): def __init__(self): super(mainwindow, self).__init__() label = QLabel('Seconds to delay:') self.button = QPushButton('TypePaste') self.button.clicked.connect(self.start) self.spinbox = QSpinBox() self.spinbox.setValue(5) self.lcd = QLCDNumber() self.lcd.setDigitCount(2) self.lcd.display(0) Vlayout = QVBoxLayout() Vlayout.addWidget(label) Vlayout.addWidget(self.spinbox) Vlayout.addWidget(self.button) Hlayout = QHBoxLayout() Hlayout.addLayout(Vlayout) Hlayout.addWidget(self.lcd) self.setLayout(Hlayout) self.setWindowTitle('TypePaste') self.setFixedSize(225,90) def start(self): clipboard = QApplication.clipboard() clipboard = str(clipboard.text()) self.button.setEnabled(False) thread = threading.Thread(target=self.TypePaste, args=(clipboard,)) thread.daemon = True thread.setName('TypePaste') thread.start() def TypePaste(self,s): sec = self.spinbox.value() self.lcd.display(sec) for i in range(sec): time.sleep(1) self.lcd.display(sec-1-i) typewrite(s) self.button.setEnabled(True) Mainwindow = mainwindow() Mainwindow.show()