반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 네이버 로그인 영수증 해결
- 파이썬네이버부동산
- 파이썬 환경설정
- 네이버커머스API
- Selenium 셀렉터잡기
- 가상환경설치
- 커머스API
- 날짜 정규식
- Python
- 네이버 로그인 하기
- 파이썬 네이버 로그인
- UiPath
- Uipath 기초
- pywinauto 윈도우제어
- uipath 입문
- 파이썬 가상환경 설치
- 왕초보 파이썬 실행
- 파이썬 가상환경 설치방법
- pycdas.exe
- 네이버부동산크롤링
- pycdc.exe
- Uipath 설치방법
- pywinauto 윈도우
- Element is not clickable at point
- 네이버매물크롤링
- 네이버 로그인 캡챠해결
- venv 설치
- pywinauto
- vscode venv 설치
- selenium
Archives
- Today
- Total
콘솔워크
[pyqt5] 두개의 버튼이 하나의 함수를 실행할 때 어떤 버튼이 클릭되었는지 구분하는 법 본문
반응형
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton
from PyQt5.QtCore import QObject, pyqtSignal
class MyWindow(QMainWindow):
def __init__(self):
super().__init__()
# 버튼 생성
self.button1 = QPushButton("Button 1", self)
self.button2 = QPushButton("Button 2", self)
# 버튼 위치 조정
self.button1.move(50, 50)
self.button2.move(150, 50)
# 버튼 클릭 시그널에 함수 연결
self.button1.clicked.connect(self.onButtonClicked)
self.button2.clicked.connect(self.onButtonClicked)
def onButtonClicked(self):
# sender()를 이용하여 어떤 버튼이 호출했는지 확인
button = self.sender()
if button == self.button1:
print("Button 1 clicked")
elif button == self.button2:
print("Button 2 clicked")
if __name__ == '__main__':
app = QApplication([])
window = MyWindow()
window.show()
app.exec_()
sender()를 이용해서 어떤 버튼이 클릭되었는지 구분할 수 있다.
반응형
'프로그래밍 > python' 카테고리의 다른 글
클립보드에 있는 내용을 배열로 직접 받아오는 방법 (0) | 2023.04.12 |
---|---|
html 태그를 제외한 문자열을 추출하는 정규식 (0) | 2023.04.11 |
[selenium] 크롬 드라이버로 작업 시 팝업창이 허용 되어있지 않은 경우 해결 방법 (0) | 2023.04.07 |
[openpyxl] 엑셀의 행과 열 좌표를 지정해서 값을 바꾸는 방법 (0) | 2023.04.06 |
반복문을 돌며 csv 파일에 새로운 데이터를 한 줄씩 추가하는 방법 (0) | 2023.04.04 |