• Fuentes

 #477139  por Doddy
 31 Ago 2015, 17:50
Explotando mi limitado tiempo al pedo decidi aprovecharme nuevamente de la API de la pagina tinyurl.com para hacer una nueva version de este simple script.

Una imagen de como quedo :

Imagen

El codigo
#!usr/bin/python
#URL Shorter 0.2
#Coded By Doddy H

import sys,urllib2,re
from PyQt4 import QtCore,QtGui

def toma(web) :
 nave = urllib2.Request(web)
 nave.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5');
 op = urllib2.build_opener()
 return op.open(nave).read()

def cortar():
 new.resul.setText(toma("http://tinyurl.com/api-create.php?url="+str(new.url.text())))

app = QtGui.QApplication(sys.argv)

new = QtGui.QWidget()

new.setWindowTitle("URL Shorter 0.2 || Coded By Doddy H")
new.resize(350,150)
new.setStyleSheet("QWidget {background-color: #000000;color: #FFFF00}")

new.label1 = QtGui.QLabel("URL : ",new)
new.label1.setStyleSheet("QWidget {background-color: #000000;color: #FFFF00;font: normal 17px Verdana}")
new.label1.setGeometry(20,23,80,20)

new.url = QtGui.QLineEdit(new)
new.url.setStyleSheet("QWidget {background-color: #000000; color: #FFFF00;border: 2px solid #FFFF00}")
new.url.setGeometry(75,23,247,25)

new.label2 = QtGui.QLabel("Result : ",new)
new.label2.setStyleSheet("QWidget {background-color: #000000;color: #FFFF00;font: normal 17px Verdana}")
new.label2.setGeometry(20,60,80,20)

new.resul = QtGui.QLineEdit(new)
new.resul.setStyleSheet("QWidget {background-color: #000000; color: #FFFF00;border: 2px solid #FFFF00}")
new.resul.setGeometry(95,60,230,25)

new.search = QtGui.QPushButton("Short",new)
new.search.setGeometry(90,110,170,28)
new.search.setStyleSheet("QWidget {background-color: #000000; color: #FFFF00;border: 2px solid #FFFF00}")

new.connect(new.search,QtCore.SIGNAL("clicked()"),cortar)

new.show()

sys.exit(app.exec_())

# The End ?