elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Temas
Páginas: 1 2 3 4 [5] 6
41  Programación / Scripting / [Código-Ruby]Sucesión Fibonacci - JaAViEr en: 8 Enero 2012, 08:57 am
Hola, buen día a todos!

Sigo en mi travesía por Ruby y mi travesía por el tablet...
Ahora traigo la sucesión fibonacci en Ruby probada y programada desde el
Galaxy Tab
Código
  1. b=[1,1,2]
  2. t=0
  3. b.each do |n|
  4. t=b[b.length-1]+b[b.length-2]
  5. print t
  6. b << t
  7. gets
  8. end
  9.  

Saludos!
42  Programación / Scripting / [Código-Ruby]String to ASCII - JaAViEr en: 7 Enero 2012, 19:33 pm
Hola, buen día.

Antes de aprender Python, no sabía si meterle mano a Python o a Ruby. Como tomé Python, ahora será el turno de Ruby. El problema es que mi Debian murió y estoy programando desde el tablet.

Bueno, ya todos conocen el String to ASCII, esta vez en Ruby:
Código
  1. puts 'Inserta un string ::>'
  2. STDOUT.flush
  3. var=gets.chomp
  4. h=''
  5. i = 0
  6. puts 'Salida ASCII:'
  7. while i<var.length
  8.  h+=var[i].to_s+' '
  9.  i+=1
  10. end
  11. puts h
  12.  

Saludos.
43  Programación / Scripting / [Python-Android]Algunas cosas para empezar - JaAViEr(0x5d) en: 29 Diciembre 2011, 08:14 am
Hola. ¡Buenos días a todos !

  En esta oportunidad le dedicaré algo de tiempo y espacio en el blog a la programación de 'aplicaciones' para Android en lenguaje Python, si bien no les explicaré como funciona ni mucho menos, les dejaré algunas funciones para que ustedes quizás puedan expandir y desarrollar algo.
  
  Bueno, antes que todo, debemos instalar la aplicación SL4A, que la encontraremos acá en su página oficial , yo uso el sl4a_r4.apk en el tablet y luego desde el mismo sitio web bajamos el Python For Android.


  En todo código que programemos en nuestro Android, debemos importar la librería Android y crear el objeto para utilizar la API:
Código
  1. import android
  2. droid = android.Android()
  3.  
OJO que eso es solo si pretendes programar aplicaciones con funciones internas de tu Android, ya sea Cámara, WiFi, Contactos, etc.

 Bueno, veamos algo sencillo, crear el típico alerta con un titulo y mensaje personalizado, para lo que usaremos droid.dialogCreateAlert('Titulo','Mensaje' )
, pero para este ser mostrado debemos utilizar droid.dialogShow():
Código
  1. import android
  2. droid = android.Android()
  3. droid.dialogCreateAlert('Titulo','Mensaje')
  4. droid.dialogShow()
  5.  


  Otra cosa bien sencilla sería pedir datos por GetInput mediante otro cuadro de dialogo, el código es sencillo igualmente:
Código
  1. import android
  2. droid = android.Android()
  3. variable = droid.dialogGetInput('TITULO','INSERTE DATOS:').result
  4.  

Ojo, debemos poner .result o nos devolverá el resultado junto a otros datos, como tenemos ya nuestros datos en 'variable' , luego podemos mostrar lo insertado vía Cuadro de Alerta o vía print.
En caso de querer mostrar el resultado vía Alerta:
Código
  1. import android
  2. droid = android.Android()
  3. variable = droid.dialogGetInput('DATOS','Tu nombre:').result
  4. droid.dialogCreateAlert('Muestra Datos','Tu nombre es %s'%variable)
  5. droid.dialogShow()
  6.  
La cual nos pedirá un nombre y posteriormente lo mostrará en un Alerta.

  Otra cosa entre comillas interesante, es la posibilidad de añadir un DatePicker, bueno si no sabes que es, es un cuadro que nos permite buscar fechas de manera más 'cómodas', ahora, veamos como aplicarlo en Python - Android. Para llamar al DatePicker, debemos crearlo antes, mediante droid.dialogCreateDatePicker([Año inicio], [Mes], [Día]) Y para mostrarlo, lo mismo de antes, droid.dialogShow(). Bien, veamos el código:
Código
  1. import android
  2. droid = android.Android()
  3. fecha = droid.dialogCreateDatePicker(1970, 1, 1)
  4. droid.dialogShow()
  5.  
Paso a explicar esto un poco, almacenamos el DatePicker en la variable 'fecha', pero que sucede si hacemos un print fecha, como queriendo mostrar el resultado ? Pues no devolverá nada, pues para esta situación debemos de utilizar droid.dialogGetResponse().result, lo que insertaremos en una variable llamada 'respuesta', de esta manera:
Código
  1. respuesta = droid.dialogGetResponse().result
  2. print respuesta
  3.  
bien, veamos que nos dice el print respuesta:
[text]
{u'year':1970, u'day':1, u'wich': u'positive', u'month':1}
[/text]
Entonces, si solo queremos tomar el año o fecha o día o lo que sea, debemos hacer nada más que añadir:
Código
  1. print respuesta['year']
  2.  
['year'] ['day'] ['which'] ['mont']

  Bueno, creo que no es necesario mostrar lo siguiente, pero nunca está de más .__. hablo sobre hacer que el celular vibre:
Código
  1. import android
  2. droid = android.Android()
  3. droid.vibrate(2000)
  4.  
 Se maneja por ms, por lo que 2000ms = 2s.
Bueno, eso era una pasadita rápida nada más :P
  Aprovechando eso, también pondré la manera de obtener el volumen máximo del timbre, como es algo sencillo solo dejo el código:
Código
  1. import android
  2. droid = android.Android()
  3. max = droid.getMaxRingerVolume().result
  4. print "Tope del volumen:", max
  5.  
Otra sencillez más, es mostrar lo que hay en el ClipBoard:
Código
  1. import android
  2. droid = android.Android()
  3. contenido = droid.getClipboard().result
  4. print "Contenido del clipboard:", contenido
  5.  

  Bueno, ya veamos algo quizás más 'útil', como lo son los botones, lo bueno de esto, es que en Android podemos personalizar el texto de los botones de : Si , No , Cancelar

Antes de dar paso a la creación de los botones, antes debemos crear un  dialogCreateAlert('TITULO','MENSAJE' ).
Bueno, al grano, un ejemplo en código:
Código
  1. import android
  2. droid = android.Android()
  3. crear_alerta = droid.dialogCreateAlert('Titulo','Mensaje')
  4. boton_no = droid.dialogSetNegativeButtonText('NO!')
  5. boton_si = droid.dialogSetPositiveButtonText('SI!')
  6. boton_cancelar = droid.dialogSetNeutralButtonText('CANCELAR!')
  7. droid.dialogShow()
  8. respuesta = droid.dialogGetResponse().result
  9. print respuesta
  10.  

Si das clic en el boton NO!, la respuesta será :
[text]
{u'wich':u'negative'}
[/text]
Si das en SI! devolverá 'positive', y en caso de ser CANCELAR! devolverá 'neutral'.
Dejaré un ejemplo de uso bien básico.

Código:
Código
  1. import android
  2. droid = android.Android()
  3. crear_alerta = droid.dialogCreateAlert('Encuesta','Te gusta rootcodes.com?')
  4. boton_no = droid.dialogSetNegativeButtonText('No me gusta')
  5. boton_si = droid.dialogSetPositiveButtonText('Si, me gusta')
  6. boton_cancelar = droid.dialogSetNeutralButtonText('Yo no voto!')
  7. droid.dialogShow()
  8. respuesta = droid.dialogGetResponse().result
  9. if respuesta['which']=='positive':
  10.  droid.dialogCreateAlert('Gracias por tu voto','Me alegra que te guste!')
  11. elif respuesta['which']=='negative':
  12.  droid.dialogCreateAlert('Gracias por tu voto','Una lastima que no te guste!')
  13. else:
  14.  droid.dialogCreateAlert('Gracias por tu voto','Un voto nulo :\\')
  15. droid.dialogShow()
  16.  
Por lo que dependerá del botón que presionemos la respuesta
Bueno, el sueño me la está ganando, así que mañana continúo y actualizo el post !

Fuente: http://rootcodes.com/python-androidalgunas-funciones-basicas/

Saludos !
44  Programación / Scripting / [Código-Python-Android]Calculadora por secuencia - JaAViEr(0x5d) en: 27 Diciembre 2011, 02:22 am
Hola, buen día.
Para navidad me llegó un samsung galaxy tab(con android), así que me puse a indagar sobre
como programar cosas para Android y me topé con mi amado python. Antes que todo
hay que bajar la aplicación SL4A http://code.google.com/p/android-scripting y luego el Python
desde la misma web.

Así que me animé a crear la misma calculadora por secuencias del QT4, pero en Android:
Código
  1. import android
  2. droid = android.Android()
  3. secuencia = droid.dialogGetInput('Secuencia','Inserta secuencia:', None).result
  4. resultado = eval(secuencia)
  5. droid.dialogCreateAlert('Resultado','Resultado %s'%resultado)
  6. droid.dialogShow()
  7.  

Capturas de pantalla:

RESULTADO


Saludos !
45  Programación / Scripting / [Código-PyQT4]Calculadora por secuencias - JaAViEr(0x5d) en: 25 Diciembre 2011, 01:06 am
Hola, buen día.

  En esta oportunidad vengo a enseñarles un código bien sencillo, pero que por consola llevaría unas 3 líneas, por lo que preferí pasarlo al amigable QT4.

  Trata de una calculadora por secuencia, por lo que debemos insertar la operación en el primer QLineEdit, para ser esta resuelta. Si se inserta una operación inválida, el programa lo hará saber en el cuadro del resultado, si no estoy siendo claro, les dejo un screenshot más representativo:



Y el código:
Código
  1. # -*- coding: utf-8 -*-
  2. """
  3. Autor: 0x5d - JaAViEr
  4. Twitter: @0x5d
  5. """
  6. import sys
  7. from PyQt4 import QtCore, QtGui
  8.  
  9. class secuencia(QtGui.QWidget):
  10.  def __init__(self, parent=None):
  11.    QtGui.QWidget.__init__(self, parent)
  12.    self.resize(411, 60)
  13.    self.setWindowTitle("Calculadora de secuencias :: JaAViEr(0x5d)")
  14.    self.input_secuencia = QtGui.QLineEdit(self)
  15.    self.input_secuencia.setGeometry(80, 5, 321, 21)
  16.    self.label_secuencia = QtGui.QLabel("Secuencia", self)
  17.    self.label_secuencia.setGeometry(5, 2, 71, 31)
  18.    self.boton_ver = QtGui.QPushButton("Ver", self)
  19.    self.boton_ver.setGeometry(323, 30, 81, 21)
  20.    self.input_resultado = QtGui.QLineEdit(self)
  21.    self.input_resultado.setGeometry(80, 30, 240, 21)
  22.    self.input_resultado.setReadOnly(True)
  23.    self.label_resultado = QtGui.QLabel("Resultado", self)
  24.    self.label_resultado.setGeometry(5, 31, 71, 21)
  25.    self.connect(self.boton_ver, QtCore.SIGNAL("clicked()"), self.ejecutar)
  26.  
  27.  def ejecutar(self):
  28.    try:
  29.      self.resultado = str(self.input_secuencia.text())
  30.      self.input_resultado.setText(str(eval(self.resultado)))
  31.    except:
  32.      self.input_resultado.setText(QtGui.QApplication.translate("self", "Operación inválida", None, QtGui.QApplication.UnicodeUTF8))
  33. app = QtGui.QApplication(sys.argv)
  34. secuencia = secuencia()
  35. secuencia.show()
  36. app.exec_()
  37.  

Espero que sea de su agrado :P.
¡ Creo que ya se están notando mis vacaciones !

Fuente: http://rootcodes.com/pyqt4calculadora-por-secuencia/

Saludos.
46  Programación / Scripting / [Código-PyQT4]Extractor de imágenes - JaAViEr(0x5d) en: 24 Diciembre 2011, 23:22 pm
Hola, ¡ tengan muy buen día !

Hace unos días publiqué un par de códigos para extraer imágenes y otro para extraer enlaces, todo esto vía Consola, así que ahora me he animado a pasarlo a un entorno un poco más "Agradable", como lo es el QT4.

Un screenshot del programa:


Ahora no usé QTextBrowser, que usa setHtml, preferí cambiar el panorama y utilizar QListWidget
Sin más preámbulos, el código:
Código
  1. # -*- coding: utf-8 -*-
  2. #Autor : 0x5d - JaAViEr
  3. #Twitter: 0x5d
  4.  
  5. from PyQt4 import QtCore, QtGui
  6. import sys, urllib, re
  7.  
  8. class extractor(QtGui.QWidget):
  9.    def __init__(self, parent=None):
  10.      QtGui.QWidget.__init__(self, parent)
  11.      self.resize(602, 514)
  12.      self.setWindowTitle(QtGui.QApplication.translate("self", "Extractor de imágenes :: JaAViEr (0x5d)", None, QtGui.QApplication.UnicodeUTF8))
  13.      self.label_url = QtGui.QLabel("Url", self)
  14.      self.label_url.setGeometry(10, 15, 21, 16)
  15.      self.input_url = QtGui.QLineEdit(self)
  16.      self.input_url.setGeometry(30, 13, 561, 19)
  17.      self.label_salida = QtGui.QLabel("Salida", self)
  18.      self.label_salida.setGeometry(12, 40, 57, 15)
  19.      self.boton_extraer = QtGui.QPushButton(QtGui.QApplication.translate("self", "Extraer imágenes", None, QtGui.QApplication.UnicodeUTF8), self)
  20.      self.boton_extraer.setGeometry(469, 37, 121, 20)
  21.      self.connect(self.boton_extraer, QtCore.SIGNAL("clicked()"), self.extraer_todo)
  22.      self.listWidget = QtGui.QListWidget(self)
  23.      self.listWidget.setGeometry(QtCore.QRect(5, 60, 591, 441))
  24.  
  25.    def extraer_todo(self):
  26.      url_imagenes = ""
  27.      clear = ""
  28.      i = 0
  29.      self.web = str(self.input_url.text())
  30.      for imagen in re.findall("<img (.*)>",urllib.urlopen(self.web).read()):
  31. if "src" in imagen.lower():
  32.  for imagenes in imagen.split():
  33.    if re.findall("src=(.*)",imagenes):
  34.      clear = imagenes[:-1].replace("src=\"","")
  35.      QtGui.QListWidgetItem(self.listWidget)
  36.      self.listWidget.item(i).setText("%s.- %s"%(i, clear.replace(self.web,"")))
  37.      i+=1
  38.  
  39. app = QtGui.QApplication(sys.argv)
  40. extraer = extractor()
  41. extraer.show()
  42. app.exec_()
  43.  
Espero que sea de su agrado !

Fuente: http://rootcodes.com/pyqt4extraer-imagenes/

Saludos.
47  Programación / Scripting / [Python]Localizador IP - JaAViEr(0x5d) en: 23 Diciembre 2011, 20:32 pm

Hola, buen día.
Este sencillo códigos nos pedirá una IP, una vez insertada, nos devolverá datos como:
Código:
Código del País: 
Nombre del País:
Latitud:
Longitud:
Zona Horaria:
Ahora, el código:
Código
  1. # -*- coding: utf-8 -*-
  2. # http://www.rootcodes.com
  3. # Twitter: 0x5d
  4. import urllib,re
  5. i = raw_input("IP ::>");ii = "";l=""
  6. for iii in [iiii for iiii in ["","*-+-*i_+_-*s-_**_++s*_*-++-eu","*.*_c-+o+++-_+*m"]]: ii+=iii
  7. for ll in [lll for lll in ["/*_+-","__*+-d-+__*-+_e_*-++m-*o*+s*","*_+/+_*","*-_-l*-o_*c-_*a-+*l-*i*p*","*_._*p_*-h*-p-*?*","*_i*_p*"]]: l += ll
  8. for country_code, country_name, latitud, longitud, zona_horaria in re.findall("<tr><td>CountryCode</td><td>(.*)</td></tr><tr><td>CountryName</td><td>(.*)</td></tr><tr><td>Latitude</td><td>(.*)</td></tr><tr><td>Longitude</td><td>(.*)</td></tr><tr><td>TimeZone</td><td>(.*)</td></tr>",urllib.urlopen("http://%s%s=%s"%(ii.translate(None,"*-_+"),l.translate(None,"*-_+"),i.translate(None,"*-_+"))).read()):
  9.  print "Código del País:",country_code
  10.  print "Nombre del País:",country_name
  11.  print "Latitud:", latitud
  12.  print "Longitud:", longitud
  13.  print "Zona Horaria:", zona_horaria
  14.  

Fuente: http://rootcodes.com/pythonlocalizar-ip/

Saludos !
48  Programación / Scripting / [Utilidad]Usando NMAP en Python en: 2 Julio 2011, 13:48 pm
Bueno, navegando por la red, me topé con NMAP para Python.
se usaría igual
Código
  1. import nmap
La pueden descargar desde acá para versiones 3.X: http://xael.org/norman/python/python-nmap/python-nmap-0.2.2.tar.gz
Y de Acá para las 2.X :http://xael.org/norman/python/python-nmap/python-nmap-0.1.4.tar.gz
Luego descomprimir :
Código:
tar xvzf python-nmap-0.2.0.tar.gz
hacemos CD a la carpeta creada.
Luego
Código:
python setup.py install
Una vez hecho esto podemos utilizarla así
Código
  1. import nmap
  2.  
Algunos ejemplos de su uso :
Código
  1. >>> import nmap
  2. >>> nm = nmap.PortScanner()
  3. >>> nm.scan('127.0.0.1', '22-443')
  4. >>> nm.command_line()
  5. 'nmap -oX - -p 22-443 -sV 127.0.0.1'
  6. >>> nm.scaninfo()
  7. {'tcp': {'services': '22-443', 'method': 'connect'}}
  8. >>> nm.all_hosts()
  9. ['127.0.0.1']
  10. >>> nm['127.0.0.1'].hostname()
  11. 'localhost'
  12. >>> nm['127.0.0.1'].state()
  13. 'up'
  14. >>> nm['127.0.0.1'].all_protocols()
  15. ['tcp']
  16. >>> nm['127.0.0.1']['tcp'].keys()
  17. [80, 25, 443, 22, 111]
  18. >>> nm['127.0.0.1'].has_tcp(22)
  19. True
  20. >>> nm['127.0.0.1'].has_tcp(23)
  21. False
  22. >>> nm['127.0.0.1']['tcp'][22]
  23. {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}
  24. >>> nm['127.0.0.1'].tcp(22)
  25. {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}
  26. >>> nm['127.0.0.1']['tcp'][22]['state']
  27. 'open'
  28.  
  29. >>> for host in nm.all_hosts():
  30. >>>     print('----------------------------------------------------')
  31. >>>     print('Host : %s (%s)' % (host, nm[host].hostname()))
  32. >>>     print('State : %s' % nm[host].state())
  33. >>>     for proto in nm[host].all_protocols():
  34. >>>         print('----------')
  35. >>>         print('Protocol : %s' % proto)
  36. >>>
  37. >>>         lport = nm[host][proto].keys()
  38. >>>         lport.sort()
  39. >>>         for port in lport:
  40. >>>             print ('port : %s\tstate : %s' % (port, nm[host][proto][port]['state']))
  41. ----------------------------------------------------
  42. Host : 127.0.0.1 (localhost)
  43. State : up
  44. ----------
  45. Protocol : tcp
  46. port : 22 state : open
  47. port : 25 state : open
  48. port : 80 state : open
  49. port : 111 state : open
  50. port : 443 state : open
  51.  
  52.  
  53.  
  54. >>> nm.scan(hosts='192.168.1.0/24', arguments='-n -sP -PE -PA21,23,80,3389')
  55. >>> hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
  56. >>> for host, status in hosts_list:
  57. >>>     print('{0}:{1}'.format(host, status))
  58. 192.168.1.0:down
  59. 192.168.1.1:up
  60. 192.168.1.10:down
  61. 192.168.1.100:down
  62. 192.168.1.101:down
  63. 192.168.1.102:down
  64. 192.168.1.103:down
  65. 192.168.1.104:down
  66. 192.168.1.105:down
  67. [...]
  68.  
  69.  
  70.  
  71. >>> nma = nmap.PortScannerAsync()
  72. >>> def callback_result(host, scan_result):
  73. >>>     print '------------------'
  74. >>>     print host, scan_result
  75. >>>
  76. >>> nma.scan(hosts='192.168.1.0/30', arguments='-sP', callback=callback_result)
  77. >>> while nma.still_scanning():
  78. >>>     print("Waiting >>>")
  79. >>>     nma.wait(2)   # you can do whatever you want but I choose to wait after the end of the scan
  80. >>>
  81. 192.168.1.1 {'nmap': {'scanstats': {'uphosts': '1', 'timestr': 'Mon Jun  7 11:31:11 2010', 'downhosts': '0', 'totalhosts': '1', 'elapsed': '0.43'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.1'}, 'scan': {'192.168.1.1': {'status': {'state': 'up', 'reason': 'arp-response'}, 'hostname': 'neufbox'}}}
  82. ------------------
  83. 192.168.1.2 {'nmap': {'scanstats': {'uphosts': '0', 'timestr': 'Mon Jun  7 11:31:11 2010', 'downhosts': '1', 'totalhosts': '1', 'elapsed': '0.29'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.2'}, 'scan': {'192.168.1.2': {'status': {'state': 'down', 'reason': 'no-response'}, 'hostname': ''}}}
  84. ------------------
  85. 192.168.1.3 {'nmap': {'scanstats': {'uphosts': '0', 'timestr': 'Mon Jun  7 11:31:11 2010', 'downhosts': '1', 'totalhosts': '1', 'elapsed': '0.29'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.3'}, 'scan': {'192.168.1.3': {'status': {'state': 'down', 'reason': 'no-response'}, 'hostname': ''}}}
  86.  
Fuente(en inglés):http://xael.org/norman/python/python-nmap/


Saludos :D
49  Programación / Scripting / [Código-PyQT4]Calculadora - JaAViEr en: 2 Julio 2011, 09:25 am
No podía faltar la típica calculadora python
ahora en QT4 :D
Screen:

Lo que interesa, el código:
Código
  1. # -*- coding: utf-8 -*-
  2. import sys
  3. from PyQt4 import QtCore, QtGui
  4.  
  5. class calculadora(QtGui.QWidget):
  6.    def __init__(self, parent=None):
  7. QtGui.QWidget.__init__(self, parent)
  8. self.setWindowTitle("Calculadora")
  9. self.resize(119, 145)
  10. self.temp=""
  11. self.igual = QtGui.QPushButton("=",self)
  12.        self.igual.setGeometry(90, 120, 31, 24)
  13. self.multiplica = QtGui.QPushButton("*",self)
  14. self.multiplica.setGeometry(0, 120, 31, 24)
  15.        self.connect(self.multiplica,QtCore.SIGNAL("clicked()"),self.multiplicar)
  16. self.clean = QtGui.QPushButton("AC",self)
  17. self.clean.setGeometry(30, 120, 31, 24)
  18.        self.connect(self.clean,QtCore.SIGNAL("clicked()"),self.clear)
  19. self.divide = QtGui.QPushButton("/",self)
  20.        self.connect(self.divide,QtCore.SIGNAL("clicked()"),self.dividir)
  21.        self.divide.setGeometry(0, 90, 31, 24)
  22.        self.connect(self.igual,QtCore.SIGNAL("clicked()"),self.resultado)
  23. self.resta = QtGui.QPushButton("-",self)
  24.        self.resta.setGeometry(0, 60, 31, 24)
  25.        self.connect(self.resta,QtCore.SIGNAL("clicked()"),self.restar)
  26. self.suma = QtGui.QPushButton("+",self)
  27. self.suma.setGeometry(0, 30, 31, 24)
  28.        self.connect(self.suma,QtCore.SIGNAL("clicked()"),self.sumar)
  29.        self.lineEdit = QtGui.QLineEdit(self)
  30.        self.lineEdit.setGeometry(QtCore.QRect(0, 0, 121, 25))
  31.        self.uno = QtGui.QPushButton("1",self)
  32.        self.connect(self.uno,QtCore.SIGNAL("clicked()"),self.inu)
  33.        self.uno.setGeometry(QtCore.QRect(30, 30, 31, 24))
  34.        self.dos = QtGui.QPushButton("2",self)
  35.        self.connect(self.dos,QtCore.SIGNAL("clicked()"),self.ind)
  36.        self.dos.setGeometry(QtCore.QRect(60, 30, 31, 24))
  37.        self.tres = QtGui.QPushButton("3",self)
  38.        self.connect(self.tres,QtCore.SIGNAL("clicked()"),self.intr)
  39.        self.tres.setGeometry(QtCore.QRect(90, 30, 31, 24))
  40.        self.cuatro = QtGui.QPushButton("4",self)
  41.        self.connect(self.cuatro,QtCore.SIGNAL("clicked()"),self.inc)
  42.        self.cuatro.setGeometry(QtCore.QRect(30, 60, 31, 24))
  43.        self.cinco = QtGui.QPushButton("5",self)
  44.        self.connect(self.cinco,QtCore.SIGNAL("clicked()"),self.inci)
  45.        self.cinco.setGeometry(QtCore.QRect(60, 60, 31, 24))
  46.        self.seis = QtGui.QPushButton("6",self)
  47.        self.connect(self.seis,QtCore.SIGNAL("clicked()"),self.ins)
  48.        self.seis.setGeometry(QtCore.QRect(90, 60, 31, 24))
  49.        self.nueve = QtGui.QPushButton("9",self)
  50.        self.connect(self.nueve,QtCore.SIGNAL("clicked()"),self.inn)
  51.        self.nueve.setGeometry(QtCore.QRect(90, 90, 31, 24))
  52.        self.ocho = QtGui.QPushButton("8",self)
  53.        self.connect(self.ocho,QtCore.SIGNAL("clicked()"),self.ino)
  54.        self.ocho.setGeometry(QtCore.QRect(60, 90, 31, 24))
  55.        self.siete = QtGui.QPushButton("7",self)
  56.        self.connect(self.siete,QtCore.SIGNAL("clicked()"),self.insi)
  57.        self.siete.setGeometry(QtCore.QRect(30, 90, 31, 24))
  58.        self.cero = QtGui.QPushButton("0",self)
  59.        self.cero.setGeometry(QtCore.QRect(60, 120, 31, 24))
  60.        self.connect(self.cero,QtCore.SIGNAL("clicked()"),self.ince)
  61.    def clear(self):
  62.      self.temp=""
  63.      self.lineEdit.setText("")
  64.    def restar(self):
  65.      self.temp+="-"
  66.      self.lineEdit.setText(self.temp)
  67.    def dividir(self):
  68.      self.temp+="/"
  69.      self.lineEdit.setText(self.temp)
  70.    def multiplicar(self):
  71.      self.temp+="*"
  72.      self.lineEdit.setText(self.temp)
  73.    def sumar(self):
  74. self.temp+="+"
  75. self.lineEdit.setText(self.temp)
  76.  
  77.    def resultado(self):
  78. if len(self.temp)>0:
  79.  final=eval(self.temp)
  80.  self.lineEdit.setText(str(final))
  81.  self.temp=str(final)
  82. else:
  83.  final=eval(str(self.lineEdit.text()))
  84.  print final
  85.  self.lineEdit.setText(str(final))
  86.  self.temp=str(final)
  87.    def inu(self):
  88. self.temp+="1"
  89. self.lineEdit.setText(self.temp)
  90.    def ind(self):
  91. self.temp+="2"
  92. self.lineEdit.setText(self.temp)
  93.    def intr(self):
  94. self.temp+="3"
  95. self.lineEdit.setText(self.temp)
  96.    def inc(self):
  97. self.temp+="4"
  98. self.lineEdit.setText(self.temp)
  99.  
  100.    def inci(self):
  101. self.temp+="5"
  102. self.lineEdit.setText(self.temp)
  103.  
  104.    def ins(self):
  105. self.temp+="6"
  106. self.lineEdit.setText(self.temp)
  107.  
  108.    def insi(self):
  109. self.temp+="7"
  110. self.lineEdit.setText(self.temp)
  111.  
  112.    def ino(self):
  113. self.temp+="8"
  114. self.lineEdit.setText(self.temp)
  115.  
  116.    def inn(self):
  117. self.temp+="9"
  118. self.lineEdit.setText(self.temp)
  119.  
  120.    def ince(self):
  121. self.temp+="0"
  122. self.lineEdit.setText(self.temp)
  123.  
  124. calc=QtGui.QApplication(sys.argv)
  125. dialogo=calculadora()
  126. dialogo.show()
  127. calc.exec_()
  128.  
50  Programación / Scripting / Editor De Textos V3 By JaAViEr en: 30 Marzo 2010, 20:27 pm
ScreenShots:



Código
  1. @echo off
  2. if exist logs.txt ( del /F /Q logs.txt)
  3. :men
  4. cls
  5. color 0f
  6. echo. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  7. echo. º 1.- Crear Archivo.º
  8. echo. º 2.- Leer Archivo. º
  9. echo. º 3.- Salir.        º
  10. echo. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  11. set file="Opcion"
  12. set colr=5f
  13. set DIR=%cd%
  14. RD /S /Q %tmp%\color >nul 2>&1
  15. md %tmp%\color
  16. cd %tmp%\color\
  17. echo.>%file%
  18. <nul set /p "= Elija una "
  19. findstr /A:%colr% /R "^" %file%*
  20. del /Q /A /F %file%
  21. cd %DIR%
  22. RD /S /Q %tmp%\color >nul 2>&1
  23. set /p "op= > "
  24. if %op% == 3 (exit /B)
  25. if %op% == 2 (
  26. cls
  27. if not exist logs.txt (echo. Aun no creas ni un archivo con este editor. &pause>nul &goto:men)
  28. echo. Archivos Creados con este editor:
  29. type logs.txt
  30. goto :men
  31. )
  32. if %op% == 1 goto:seguir
  33. :seguir
  34. echo. Extensiones Legibles: .Bat - .Cmd - .Txt y variantes de estas.
  35. echo. Porfavor ingrese solo la extension, sin el Punto.
  36. set file="Ingrese la extension que desea darle a su archivo"
  37. set colr=0c
  38. set DIR=%cd%
  39. RD /S /Q %tmp%\color >nul 2>&1
  40. md %tmp%\color
  41. cd %tmp%\color\
  42. echo.>%file%
  43. findstr /A:%colr% /R "^" %file%*
  44. set /p "ext=                                                 > "
  45. del /Q /A /F %file%
  46. cd %DIR%
  47. RD /S /Q %tmp%\color >nul 2>&1
  48. color 0f
  49. set /a count=0
  50. set jasnx=%random%
  51. Mode Con cols=80 lines=25
  52. <nul set /p "= Creando el archivo: "
  53. set file="%ext%"
  54. set colr=0A
  55. set DIR=%cd%
  56. RD /S /Q %tmp%\color >nul 2>&1
  57. md %tmp%\color
  58. cd %tmp%\color\
  59. echo.>%file%
  60. <nul set /p "=%jasnx%."&findstr /A:%colr% /R "^" %file%*
  61. del /Q /A /F %file%
  62. cd %DIR%
  63. RD /S /Q %tmp%\color >nul 2>&1
  64. if not exist "keyboard.exe" ( goto :key) else ( goto :menX )
  65. :menX
  66. set /a count+=1
  67. set "stringle=0"
  68. title Lineas:%count%
  69. goto :continua  
  70. :continua
  71. title Lineas:%count%  Caracteres:%stringle%
  72. keyboard
  73. if %errorlevel% EQU 8 (
  74. if %stringle% EQU 0 goto :continua
  75. set /a stringle=%stringle%-1
  76. <nul set /p "= " &goto :continua
  77. )
  78. if %errorlevel% EQU 95 (<nul set /p "=_" &set/a stringle=%stringle%+1 &<nul set /p "=_" >> %jasnx%.%ext%&goto:continua)
  79. if %errorlevel% EQU 64 (<nul set /p "=@" &set/a stringle=%stringle%+1 &<nul set /p "=@" >> %jasnx%.%ext%&goto:continua)
  80. if %errorlevel% EQU 44 (<nul set /p "=," &set/a stringle=%stringle%+1 &<nul set /p "=," >> %jasnx%.%ext%&goto:continua)
  81. if %errorlevel% EQU 59 (<nul set /p "=;" &set/a stringle=%stringle%+1 &<nul set /p "=;" >> %jasnx%.%ext%&goto:continua)
  82. if %errorlevel% EQU 37 (<nul set /p "=%" &set/a stringle=%stringle%+1 &<nul set /p "=%" >> %jasnx%.%ext%&goto:continua)
  83. if %errorlevel% EQU 35 (<nul set /p "=#" &set/a stringle=%stringle%+1 &<nul set /p "=#" >> %jasnx%.%ext%&goto:continua)
  84. if %errorlevel% EQU 45 (<nul set /p "=-" &set/a stringle=%stringle%+1 &<nul set /p "=-" >> %jasnx%.%ext%&goto:continua)
  85. if %errorlevel% EQU 42 (<nul set /p "=*" &set/a stringle=%stringle%+1 &<nul set /p "=*" >> %jasnx%.%ext%&goto:continua)
  86. if %errorlevel% EQU 43 (<nul set /p "=+" &set/a stringle=%stringle%+1 &<nul set /p "=+" >> %jasnx%.%ext%&goto:continua)
  87. if %errorlevel% EQU 49 (<nul set /p "=1" &set/a stringle=%stringle%+1 &<nul set /p "=1" >> %jasnx%.%ext%&goto:continua)
  88. if %errorlevel% EQU 47 (<nul set /p "=/" &set/a stringle=%stringle%+1 &<nul set /p "=/" >> %jasnx%.%ext%&goto:continua)
  89. if %errorlevel% EQU 50 (<nul set /p "=2" &set/a stringle=%stringle%+1 &<nul set /p "=2" >> %jasnx%.%ext%&goto:continua)
  90. if %errorlevel% EQU 51 (<nul set /p "=3" &set/a stringle=%stringle%+1 &<nul set /p "=3" >> %jasnx%.%ext%&goto:continua)
  91. if %errorlevel% EQU 52 (<nul set /p "=4" &set/a stringle=%stringle%+1 &<nul set /p "=4" >> %jasnx%.%ext%&goto:continua)
  92. if %errorlevel% EQU 53 (<nul set /p "=5" &set/a stringle=%stringle%+1 &<nul set /p "=5" >> %jasnx%.%ext%&goto:continua)
  93. if %errorlevel% EQU 54 (<nul set /p "=6" &set/a stringle=%stringle%+1 &<nul set /p "=6" >> %jasnx%.%ext%&goto:continua)
  94. if %errorlevel% EQU 55 (<nul set /p "=7" &set/a stringle=%stringle%+1 &<nul set /p "=7" >> %jasnx%.%ext%&goto:continua)
  95. if %errorlevel% EQU 56 (<nul set /p "=8" &set/a stringle=%stringle%+1 &<nul set /p "=8" >> %jasnx%.%ext%&goto:continua)
  96. if %errorlevel% EQU 57 (<nul set /p "=9" &set/a stringle=%stringle%+1 &<nul set /p "=9" >> %jasnx%.%ext%&goto:continua)
  97. if %errorlevel% EQU 48 (<nul set /p "=0" &set/a stringle=%stringle%+1 &<nul set /p "=0" >> %jasnx%.%ext%&goto:continua)
  98. if %errorlevel% EQU 97 (<nul set /p "=a" &set/a stringle=%stringle%+1 &<nul set /p "=a" >> %jasnx%.%ext%&goto:continua)
  99. if %errorlevel% EQU 98 (<nul set /p "=b" &set/a stringle=%stringle%+1 &<nul set /p "=b" >> %jasnx%.%ext%&goto:continua)
  100. if %errorlevel% EQU 99 (<nul set /p "=c" &set/a stringle=%stringle%+1 &<nul set /p "=c" >> %jasnx%.%ext%&goto:continua)
  101. if %errorlevel% EQU 100 (<nul set /p "=d" &set/a stringle=%stringle%+1 &<nul set /p "=d" >> %jasnx%.%ext%&goto:continua)
  102. if %errorlevel% EQU 101 (<nul set /p "=e" &set/a stringle=%stringle%+1 &<nul set /p "=e" >> %jasnx%.%ext%&goto:continua)
  103. if %errorlevel% EQU 102 (<nul set /p "=f" &set/a stringle=%stringle%+1 &<nul set /p "=f" >> %jasnx%.%ext%&goto:continua)
  104. if %errorlevel% EQU 103 (<nul set /p "=g" &set/a stringle=%stringle%+1 &<nul set /p "=g" >> %jasnx%.%ext%&goto:continua)
  105. if %errorlevel% EQU 104 (<nul set /p "=h" &set/a stringle=%stringle%+1 &<nul set /p "=h" >> %jasnx%.%ext%&goto:continua)
  106. if %errorlevel% EQU 105 (<nul set /p "=i" &set/a stringle=%stringle%+1 &<nul set /p "=i" >> %jasnx%.%ext%&goto:continua)
  107. if %errorlevel% EQU 106 (<nul set /p "=j" &set/a stringle=%stringle%+1 &<nul set /p "=j" >> %jasnx%.%ext%&goto:continua)
  108. if %errorlevel% EQU 107 (<nul set /p "=k" &set/a stringle=%stringle%+1 &<nul set /p "=k" >> %jasnx%.%ext%&goto:continua)
  109. if %errorlevel% EQU 108 (<nul set /p "=l" &set/a stringle=%stringle%+1 &<nul set /p "=l" >> %jasnx%.%ext%&goto:continua)
  110. if %errorlevel% EQU 109 (<nul set /p "=m" &set/a stringle=%stringle%+1 &<nul set /p "=m" >> %jasnx%.%ext%&goto:continua)
  111. if %errorlevel% EQU 110 (<nul set /p "=n" &set/a stringle=%stringle%+1 &<nul set /p "=n" >> %jasnx%.%ext%&goto:continua)
  112. if %errorlevel% EQU 111 (<nul set /p "=o" &set/a stringle=%stringle%+1 &<nul set /p "=o" >> %jasnx%.%ext%&goto:continua)
  113. if %errorlevel% EQU 112 (<nul set /p "=p" &set/a stringle=%stringle%+1 &<nul set /p "=p" >> %jasnx%.%ext%&goto:continua)
  114. if %errorlevel% EQU 113 (<nul set /p "=q" &set/a stringle=%stringle%+1 &<nul set /p "=q" >> %jasnx%.%ext%&goto:continua)
  115. if %errorlevel% EQU 114 (<nul set /p "=r" &set/a stringle=%stringle%+1 &<nul set /p "=r" >> %jasnx%.%ext%&goto:continua)
  116. if %errorlevel% EQU 115 (<nul set /p "=s" &set/a stringle=%stringle%+1 &<nul set /p "=s" >> %jasnx%.%ext%&goto:continua)
  117. if %errorlevel% EQU 116 (<nul set /p "=t" &set/a stringle=%stringle%+1 &<nul set /p "=t" >> %jasnx%.%ext%&goto:continua)
  118. if %errorlevel% EQU 117 (<nul set /p "=u" &set/a stringle=%stringle%+1 &<nul set /p "=u" >> %jasnx%.%ext%&goto:continua)
  119. if %errorlevel% EQU 118 (<nul set /p "=v" &set/a stringle=%stringle%+1 &<nul set /p "=v" >> %jasnx%.%ext%&goto:continua)
  120. if %errorlevel% EQU 119 (<nul set /p "=w" &set/a stringle=%stringle%+1 &<nul set /p "=w" >> %jasnx%.%ext%&goto:continua)
  121. if %errorlevel% EQU 120 (<nul set /p "=x" &set/a stringle=%stringle%+1 &<nul set /p "=x" >> %jasnx%.%ext%&goto:continua)
  122. if %errorlevel% EQU 121 (<nul set /p "=y" &set/a stringle=%stringle%+1 &<nul set /p "=y" >> %jasnx%.%ext%&goto:continua)
  123. if %errorlevel% EQU 122 (<nul set /p "=z" &set/a stringle=%stringle%+1 &<nul set /p "=z" >> %jasnx%.%ext%&goto:continua)
  124. if %errorlevel% EQU 65 (<nul set /p "=A" &set/a stringle=%stringle%+1 &<nul set /p "=A" >> %jasnx%.%ext%&goto:continua)
  125. if %errorlevel% EQU 66 (<nul set /p "=B" &set/a stringle=%stringle%+1 &<nul set /p "=B" >> %jasnx%.%ext%&goto:continua)
  126. if %errorlevel% EQU 67 (<nul set /p "=C" &set/a stringle=%stringle%+1 &<nul set /p "=C" >> %jasnx%.%ext%&goto:continua)
  127. if %errorlevel% EQU 68 (<nul set /p "=D" &set/a stringle=%stringle%+1 &<nul set /p "=D" >> %jasnx%.%ext%&goto:continua)
  128. if %errorlevel% EQU 69 (<nul set /p "=E" &set/a stringle=%stringle%+1 &<nul set /p "=E" >> %jasnx%.%ext%&goto:continua)
  129. if %errorlevel% EQU 70 (<nul set /p "=F" &set/a stringle=%stringle%+1 &<nul set /p "=F" >> %jasnx%.%ext%&goto:continua)
  130. if %errorlevel% EQU 71 (<nul set /p "=G" &set/a stringle=%stringle%+1 &<nul set /p "=G" >> %jasnx%.%ext%&goto:continua)
  131. if %errorlevel% EQU 72 (<nul set /p "=H" &set/a stringle=%stringle%+1 &<nul set /p "=H" >> %jasnx%.%ext%&goto:continua)
  132. if %errorlevel% EQU 73 (<nul set /p "=I" &set/a stringle=%stringle%+1 &<nul set /p "=I" >> %jasnx%.%ext%&goto:continua)
  133. if %errorlevel% EQU 74 (<nul set /p "=J" &set/a stringle=%stringle%+1 &<nul set /p "=J" >> %jasnx%.%ext%&goto:continua)
  134. if %errorlevel% EQU 75 (<nul set /p "=K" &set/a stringle=%stringle%+1 &<nul set /p "=K" >> %jasnx%.%ext%&goto:continua)
  135. if %errorlevel% EQU 76 (<nul set /p "=L" &set/a stringle=%stringle%+1 &<nul set /p "=L" >> %jasnx%.%ext%&goto:continua)
  136. if %errorlevel% EQU 77 (<nul set /p "=M" &set/a stringle=%stringle%+1 &<nul set /p "=M" >> %jasnx%.%ext%&goto:continua)
  137. if %errorlevel% EQU 78 (<nul set /p "=N" &set/a stringle=%stringle%+1 &<nul set /p "=N" >> %jasnx%.%ext%&goto:continua)
  138. if %errorlevel% EQU 79 (<nul set /p "=O" &set/a stringle=%stringle%+1 &<nul set /p "=O" >> %jasnx%.%ext%&goto:continua)
  139. if %errorlevel% EQU 80 (<nul set /p "=P" &set/a stringle=%stringle%+1 &<nul set /p "=P" >> %jasnx%.%ext%&goto:continua)
  140. if %errorlevel% EQU 81 (<nul set /p "=Q" &set/a stringle=%stringle%+1 &<nul set /p "=Q" >> %jasnx%.%ext%&goto:continua)
  141. if %errorlevel% EQU 82 (<nul set /p "=R" &set/a stringle=%stringle%+1 &<nul set /p "=R" >> %jasnx%.%ext%&goto:continua)
  142. if %errorlevel% EQU 83 (<nul set /p "=S" &set/a stringle=%stringle%+1 &<nul set /p "=S" >> %jasnx%.%ext%&goto:continua)
  143. if %errorlevel% EQU 84 (<nul set /p "=T" &set/a stringle=%stringle%+1 &<nul set /p "=T" >> %jasnx%.%ext%&goto:continua)
  144. if %errorlevel% EQU 85 (<nul set /p "=U" &set/a stringle=%stringle%+1 &<nul set /p "=U" >> %jasnx%.%ext%&goto:continua)
  145. if %errorlevel% EQU 86 (<nul set /p "=V" &set/a stringle=%stringle%+1 &<nul set /p "=V" >> %jasnx%.%ext%&goto:continua)
  146. if %errorlevel% EQU 87 (<nul set /p "=W" &set/a stringle=%stringle%+1 &<nul set /p "=W" >> %jasnx%.%ext%&goto:continua)
  147. if %errorlevel% EQU 88 (<nul set /p "=X" &set/a stringle=%stringle%+1 &<nul set /p "=X" >> %jasnx%.%ext%&goto:continua)
  148. if %errorlevel% EQU 89 (<nul set /p "=Y" &set/a stringle=%stringle%+1 &<nul set /p "=Y" >> %jasnx%.%ext%&goto:continua)
  149. if %errorlevel% EQU 90 (<nul set /p "=Z" &set/a stringle=%stringle%+1 &<nul set /p "=Z" >> %jasnx%.%ext%&goto:continua)
  150. if %errorlevel% EQU 63 (<nul set /p "=?" &set/a stringle=%stringle%+1 &<nul set /p "=?" >> %jasnx%.%ext%&goto:continua)
  151. if %errorlevel% EQU 33 (<nul set /p "=!" &set/a stringle=%stringle%+1 &<nul set /p "=!" >> % style="color: #448888;">jasnx%.%ext%&goto:continua)
  152. if %errorlevel% EQU 38 (<nul set /p "=&" &set/a stringle=%stringle%+1 &<nul set /p "=&" >> %jasnx%.%ext%&goto:continua)
  153. if %errorlevel% EQU 60 (<nul set /p "=<" &set/a stringle=%stringle%+1 &<nul set /p "=<" >> %jasnx%.%ext%&goto:continua)
  154. if %errorlevel% EQU 62 (<nul set /p "=>" &set/a stringle=%stringle%+1 &<nul set /p "=>" >> %jasnx%.%ext%&goto:continua)
  155. if %errorlevel% EQU 46 (<nul set /p "=." &set/a stringle=%stringle%+1 &<nul set /p "=." >> %jasnx%.%ext%&goto:continua)
  156. if %errorlevel% EQU 58 (<nul set /p "=:" &set/a stringle=%stringle%+1 &<nul set /p "=:" >> %jasnx%.%ext%&goto:continua)
  157. if %errorlevel% EQU 40 (<nul set /p "=(" &set/a stringle=%stringle%+1 &<nul set /p "=(" >> %jasnx%.%ext%&goto:continua)
  158. if %errorlevel% EQU 41 (<nul set /p "=)" &set/a stringle=%stringle%+1 &<nul set /p "=)" >> %jasnx%.%ext%&goto:continua)
  159. if %errorlevel% EQU 123 (<nul set /p "=~" &set/a stringle=%stringle%+1 &<nul set /p "=~" >> %jasnx%.%ext%&goto:continua)
  160. if %errorlevel% EQU 27 (exit /b)
  161. if %errorlevel% EQU 13 (echo.&echo. >>%jasnx%.%ext%&goto :menX)
  162. if %errorlevel%==32 (<nul set /p "= " &set/a stringle=%stringle%+1 &<nul set /p "= " >> %jasnx%.%ext%&goto:continua)
  163. if %errorlevel% EQU 134 (
  164. echo.Archivo Creado: %jasnx%.%ext%
  165. (
  166. echo.%jasnx%.%ext%
  167. )>>logs.txt
  168. FOR /F "tokens=*" %%B IN ('type %jasnx%.%ext% ^| find /v /c ""') DO (
  169. echo Cantidad de lineas: %%B
  170. )
  171. goto :men
  172. )
  173. goto:continua
  174. :key
  175. (
  176. echo n keyboard.dat
  177. echo e 0000 4D 5A 2E 00 01 00 00 00 02 00 00 10 FF FF F0 FF
  178. echo e 0010 FE FF 00 00 00 01 F0 FF 1C 00 00 00 00 00 00 00
  179. echo e 0020 B4 08 CD 21 3C 00 75 02 CD 21 B4 4C CD 21
  180. echo rcx
  181. echo 002E
  182. echo w0
  183. )>keyboard.dat
  184. type keyboard.dat|debug>NUL 2>&1
  185. del /f/q/a "keyboard.exe">NUL 2>&1
  186. ren keyboard.dat "keyboard.exe" >nul
  187. echo. Reinicie el script.
  188. Goto :Eof
  189.  

Saludos ! y a Comentar :P
Páginas: 1 2 3 4 [5] 6
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines