forked from space192/IPECECUP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (26 loc) · 768 Bytes
/
main.py
File metadata and controls
30 lines (26 loc) · 768 Bytes
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
29
30
from PyQt5.QtWidgets import *
from PyQt5 import QtCore
import sys
import subprocess
import time
cmd = "ip -4 addr | grep -oP '(?<=inet\s)\d+(\.\d+){3}'"
#cmd2 = "ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'"
temp = "hello"
def system_call(command):
p = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
return p.stdout.read()
app = QApplication(sys.argv)
temp=""
while temp=="":
temp1 = system_call(cmd)
temp1 = str(temp1,'utf-8')
temp = temp1.replace("127.0.0.1\n", "")
time.sleep(5)
label = QLabel()
label.setText("ip: " + temp)
label.setGeometry(0,0,800,400)
label.setAlignment(QtCore.Qt.AlignCenter)
label.setStyleSheet("font: 18pt;")
label.show()
label.setWindowTitle("Afficheur IP")
sys.exit(app.exec_())