Skip to content

Instantly share code, notes, and snippets.

@coppolaemilio
Created March 19, 2013 08:59
Show Gist options
  • Select an option

  • Save coppolaemilio/5194632 to your computer and use it in GitHub Desktop.

Select an option

Save coppolaemilio/5194632 to your computer and use it in GitHub Desktop.
With this program you can get the signal of your current WiFi connection. (Only on Linux)
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2012, 2013 Emilio Coppola [email protected]
import commands, sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QWidget.__init__(self)
quitAction = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q",triggered=QtGui.qApp.quit)
self.addAction(quitAction)
self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.setWindowTitle("Wifi Signal")
#self.setWindowIcon(QtGui.QIcon(""))
self.ProgressBar = QtGui.QProgressBar()
self.setCentralWidget(self.ProgressBar)
self.startProgressBar()
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
event.accept()
def mouseMoveEvent(self, event):
if event.buttons() == QtCore.Qt.LeftButton:
self.move(event.globalPos() - self.dragPosition)
event.accept()
def update(self):
p = str(commands.getstatusoutput('iwconfig wlan0 | grep -i --color signal')).split("=")
d = str(p[2]).split(" ")
e = int(d[0])+100
self.ProgressBar.setValue(e)
def startProgressBar(self):
timer = QtCore.QTimer(self)
timer.timeout.connect(self.update)
timer.start(500)
app = QtGui.QApplication(sys.argv)
frame = MainWindow()
frame.setWindowFlags(frame.windowFlags() | QtCore.Qt.Window)
frame.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment