한국어
파이썬
 

 import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *


class MyApp(QWidget):
    def __init__(self,*args,**kwargs):
        QWidget.__init__(self,*args,**kwargs)
        self.current_timer = None
        self.layout = QVBoxLayout(self)
        self.button = QPushButton('start timer')
        self.button.clicked.connect(self.start_timer)
        self.layout.addWidget(self.button)

    def start_timer(self):
        if self.current_timer:
            self.current_timer.stop()
            self.current_timer.deleteLater()
        self.current_timer = QTimer()
        self.current_timer.timeout.connect(self.print_hello)
        self.current_timer.setSingleShot(True)
        self.current_timer.start(3000)

    def print_hello(self):
        print 'hello'


# Create QApplication and QWidget
qapp = QApplication(sys.argv)  
app = MyApp()
app.show()
qapp.exec_()



번호 제목 글쓴이 날짜 조회 수
24 [PyQt4]여러가지 버튼 예제 file pjk 2014.08.29 19615
23 외부 프로그램 실행 pjk 2015.02.10 17433
22 [PyQt4]폴더 또는 파일을 드레그하여 그 경로를 LineEdit로 가져오기 file pjk 2014.08.22 15238
» [pyqt4]QTimer 예제 - 버튼을 누르면 3초후 함수 또는 메소드 호출 makersweb 2015.04.01 12159
20 Boost Python을 이용하여 python을 위한 C++ API 바인딩 [5] file makersweb 2017.01.08 11753
19 [Python]EXE또는 DLL파일의 버전정보를 알아내기위한 몇가지 방법 makersweb 2015.06.25 11055
18 Python + QML with PyQt4 makersweb 2015.03.24 10035
17 [PyQt4]스레드 및 ProgressBar 예제 코드 file pjk 2014.08.26 9880
16 [PyQt4]윈도우창에 별 찍기 예제 file pjk 2014.08.19 9830
15 [PyQt4]개발 프로그램 버전표시 메세지 박스 pjk 2014.09.02 9770
14 [PyQt4]multiprocess 예제 코드 pjk 2014.08.26 9729
13 Python으로 작성된 프로그램을 윈도우응용프로그램(exe)으로 빌드하기 file pjk 2014.08.03 9637
12 Python 문자열 관련 함수 레퍼런스 pjk 2014.08.29 9014
11 파이썬으로 작성된 소스를 py2exe을 이용하여 윈도우 응용프로그램 빌드시 콘솔창 숨기기 pjk 2014.07.29 9000
10 [PyQt4]마우스 클릭 이벤트 예제 코드 pjk 2014.08.26 8050
9 print를 로그파일로 생성하기 (log출력 Redirection) makersweb 2015.03.18 7796
8 How to Use Freeze pjk 2014.09.06 6949
7 Qt For Python(PySide2) QML 프로젝트 예제 file makersweb 2019.10.17 6919
6 pybind11 에 대해서 makersweb 2023.07.23 6525
5 QML 및 Window 투명처리 file makersweb 2015.04.22 6258