Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- """"
- Author: Jan Harasym <[email protected]>
- Website: dijit.sh
- Creation Date: 30-06-2014
- Last Modified: Mon 30 Jun 2014 19:10:27 BST
- Description:
- Expected Use:
- """
- from PyQt4 import QtGui
- import urllib
- import sys
- def Get_IP():
- try:
- sock = urllib.urlopen("http://eitin.drk.sc/~dijit/ip.php")
- except:
- sock = urllib.urlopen("http://ifconfig.me/")
- IP = sock.readline().rstrip()
- del sock
- return(IP)
- class Small_Window(QtGui.QWidget):
- def __init__(self):
- super(Small_Window, self).__init__()
- self.initUI()
- def initUI(self):
- lbl1 = QtGui.QLabel(Get_IP(), self)
- lbl1.move(10,5)
- self.resize(120, 30)
- self.center()
- self.setWindowTitle('IP Tracker in Qt/Python')
- self.show()
- def center(self):
- qr = self.frameGeometry()
- cp = QtGui.QDesktopWidget().availableGeometry().center()
- qr.moveCenter(cp)
- self.move(qr.topLeft())
- def main():
- print(Get_IP())
- app = QtGui.QApplication(sys.argv)
- ex = Small_Window()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment