'python'에 해당되는 글 16건
- 2023.02.14 :: 초보자를 위한 PyQt 프로그래밍
- 2022.12.19 :: Python UDP CLient / Server example
- 2022.04.15 :: PyQt - QThread 사용, thread 간 통신
- 2021.08.09 :: (NG, not good/not working)python subprocess kill on exit
- 2021.08.02 :: PyQt ProgressBar
- 2021.08.02 :: filename and line number of Python script
구글검색: pyqt getvalue emit example
'python' 카테고리의 다른 글
pypi snmp (0) | 2023.02.14 |
---|---|
[Python] 임의의 OID로 답변하는 snmp agent 만들기 (0) | 2023.02.14 |
Python UDP CLient / Server example (0) | 2022.12.19 |
PyQt - QThread 사용, thread 간 통신 (0) | 2022.04.15 |
(NG, not good/not working)python subprocess kill on exit (0) | 2021.08.09 |
-
https://pythontic.com/modules/socket/udp-client-server-example
UDP - Client and Server example programs in Python | Pythontic.com
UDP Overview: UDP is the abbreviation of User Datagram Protocol. UDP makes use of Internet Protocol of the TCP/IP suit. In communications using UDP, a client program sends a message packet to a destination server wherein the destination server also runs on
pythontic.com
- UDPEchoClient.java
'python' 카테고리의 다른 글
[Python] 임의의 OID로 답변하는 snmp agent 만들기 (0) | 2023.02.14 |
---|---|
초보자를 위한 PyQt 프로그래밍 (0) | 2023.02.14 |
PyQt - QThread 사용, thread 간 통신 (0) | 2022.04.15 |
(NG, not good/not working)python subprocess kill on exit (0) | 2021.08.09 |
PyQt ProgressBar (0) | 2021.08.02 |
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class MyMainGUI(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.qtxt1 = QTextEdit(self)
self.btn1 = QPushButton("Start", self)
self.btn2 = QPushButton("Stop", self)
self.btn3 = QPushButton("add 100", self)
self.btn4 = QPushButton("send instance", self)
vbox = QVBoxLayout()
vbox.addWidget(self.qtxt1)
vbox.addWidget(self.btn1)
vbox.addWidget(self.btn2)
vbox.addWidget(self.btn3)
vbox.addWidget(self.btn4)
self.setLayout(vbox)
self.setGeometry(100, 50, 300, 300)
class Test:
def __init__(self):
name = ""
class MyMain(MyMainGUI):
add_sec_signal = pyqtSignal()
send_instance_singal = pyqtSignal("PyQt_PyObject")
def __init__(self, parent=None):
super().__init__(parent)
self.btn1.clicked.connect(self.time_start)
self.btn2.clicked.connect(self.time_stop)
self.btn3.clicked.connect(self.add_sec)
self.btn4.clicked.connect(self.send_instance)
self.th = Worker(parent=self)
self.th.sec_changed.connect(self.time_update) # custom signal from worker thread to main thread
self.add_sec_signal.connect(self.th.add_sec) # custom signal from main thread to worker thread
self.send_instance_singal.connect(self.th.recive_instance_singal)
self.show()
@pyqtSlot()
def time_start(self):
self.th.start()
self.th.working = True
@pyqtSlot()
def time_stop(self):
self.th.working = False
@pyqtSlot()
def add_sec(self):
print(".... add singal emit....")
self.add_sec_signal.emit()
@pyqtSlot(str)
def time_update(self, msg):
self.qtxt1.append(msg)
@pyqtSlot()
def send_instance(self):
t1 = Test()
t1.name = "SuperPower!!!"
self.send_instance_singal.emit(t1)
class Worker(QThread):
sec_changed = pyqtSignal(str)
def __init__(self, sec=0, parent=None):
super().__init__()
self.main = parent
self.working = True
self.sec = sec
# self.main.add_sec_signal.connect(self.add_sec) # 이것도 작동함. # custom signal from main thread to worker thread
def __del__(self):
print(".... end thread.....")
self.wait()
def run(self):
while self.working:
self.sec_changed.emit('time (secs):{}'.format(self.sec))
self.sleep(1)
self.sec += 1
@pyqtSlot()
def add_sec(self):
print("add_sec....")
self.sec += 100
@pyqtSlot("PyQt_PyObject")
def recive_instance_singal(self, inst):
print(inst.name)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
form = MyMain()
app.exec_()
|
'python' 카테고리의 다른 글
초보자를 위한 PyQt 프로그래밍 (0) | 2023.02.14 |
---|---|
Python UDP CLient / Server example (0) | 2022.12.19 |
(NG, not good/not working)python subprocess kill on exit (0) | 2021.08.09 |
PyQt ProgressBar (0) | 2021.08.02 |
filename and line number of Python script (0) | 2021.08.02 |
(NG, not good/not working)python subprocess kill on exit
SNMP Viewer / 종료해도 타스크매니저에서 프로세스가 보일때(종료안될때) ,
python subprocess kill on exit
관련 링크:
import atexit process = subprocess.Popen(args.server_file_path) atexit.register(process.terminate) pid = process.pid
- 실제
>subprocess.Popen 으로 호출후 종료시에 서브프로세스를 같이 종료하게 해줌.
> 변경전 소스: ED_SNMP_Setup.py
class LocalSetupDialog(QtWidgets.QDialog): def __init__(self): QtWidgets.QDialog.__init__(self) self.ui = local_setup.Ui_Dialog() self.ui.setupUi(self) self.setupData() self.ui.buttonBox.accepted.connect(self.popupConfirm) self.ui.pushButton.clicked.connect(self.snmpViewer) ...... def snmpViewer(self): self.accept() argList = ['ED_SNMP_Viewer.exe', config['ipAddress'], config['snmpCommunity_read'], config['snmpCommunity_write'], config['snmpPort'], config['trapPort']] |
> 변경후 소스:
class LocalSetupDialog(QtWidgets.QDialog): def __init__(self): QtWidgets.QDialog.__init__(self) self.ui = local_setup.Ui_Dialog() self.ui.setupUi(self) self.setupData() self.ui.buttonBox.accepted.connect(self.popupConfirm) self.ui.pushButton.clicked.connect(self.snmpViewer) ...... def snmpViewer(self): self.accept() argList = ['ED_SNMP_Viewer.exe', config['ipAddress'], config['snmpCommunity_read'], config['snmpCommunity_write'], config['snmpPort'], config['trapPort']] m_process = subprocess.Popen(argList) import atexit atexit.register(m_process.terminate) |
'python' 카테고리의 다른 글
Python UDP CLient / Server example (0) | 2022.12.19 |
---|---|
PyQt - QThread 사용, thread 간 통신 (0) | 2022.04.15 |
PyQt ProgressBar (0) | 2021.08.02 |
filename and line number of Python script (0) | 2021.08.02 |
python UDP socket timeout examples (0) | 2021.08.02 |
https://riptutorial.com/pyqt5/example/29500/basic-pyqt-progress-bar
pyqt5 Tutorial => Basic PyQt Progress Bar
Learn pyqt5 - Basic PyQt Progress Bar
riptutorial.com
'python' 카테고리의 다른 글
PyQt - QThread 사용, thread 간 통신 (0) | 2022.04.15 |
---|---|
(NG, not good/not working)python subprocess kill on exit (0) | 2021.08.09 |
filename and line number of Python script (0) | 2021.08.02 |
python UDP socket timeout examples (0) | 2021.08.02 |
PyQt5 -- QThread 사용하기 & thread 간 통신 (0) | 2021.08.02 |
https://stackoverflow.com/questions/3056048/filename-and-line-number-of-python-script
filename and line number of Python script
How can I get the file name and line number in a Python script? Exactly the file information we get from an exception traceback. In this case without raising an exception.
stackoverflow.com
'python' 카테고리의 다른 글
(NG, not good/not working)python subprocess kill on exit (0) | 2021.08.09 |
---|---|
PyQt ProgressBar (0) | 2021.08.02 |
python UDP socket timeout examples (0) | 2021.08.02 |
PyQt5 -- QThread 사용하기 & thread 간 통신 (0) | 2021.08.02 |
PyQt5 QTableWidget 자료 (0) | 2021.08.02 |