Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/03/2012, 21:02
Onsterion
 
Fecha de Ingreso: octubre-2010
Mensajes: 73
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Unas preguntas sobre PyQt4

Tenes razón ahi te paso todo el código



El Principal:

Código:
import sys
import socket
from PyQt4 import QtCore,  QtGui
from red_test_vista import Ui_test_ip_app

class Iniciar_control_red (QtGui.QWidget):
    def __init__(self):
        QtGui.QWidget.__init__(self)
        
        self.test_ping = Ui_test_ip_app()
        self.test_ping.setupUi(self)

        self.connect(self.test_ping.pushButton_ver_ip_btn,  QtCore.SIGNAL('clicked()'),  self.realizar_ping)

    def realizar_ping(self):
            if self.test_ping.lineEdit_ingresar_ip.text() == '':
                self.test_ping.lineEdit_resultado_del_ip.setText('IP o Dominio inválido')
            else : 
                self.test_ping.lineEdit_resultado_del_ip.setText('IP o Dominio inválido')
                self.test_ping.texto_del_campo = self.test_ping.lineEdit_ingresar_ip.text()
                try:
                    self.test_ping.pc1_dominio = socket.gethostbyaddr(self.test_ping.texto_del_campo)
                    self.test_ping.lineEdit_resultado_del_ip.setText('Nombre de la PC: ' + self.test_ping.pc1_dominio[0])
                except socket.gaierror:
                    raise self.test_ping.lineEdit_resultado_del_ip.setText('IP o Dominio inválido')
    
def main ():
    app = QtGui.QApplication(sys.argv)
    test_ping = Iniciar_control_red()
    test_ping.show()
    sys.exit(app.exec_())
    
if __name__ == "__main__":
    main()

La vista:

Código:
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'red_test_vista.ui'
#
# Created: Tue Mar 13 14:35:42 2012
#      by: PyQt4 UI code generator 4.9.1
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Ui_test_ip_app(object):
    def setupUi(self, test_ip_app):
        test_ip_app.setObjectName(_fromUtf8("test_ip_app"))
        test_ip_app.resize(758, 357)
        test_ip_app.setWindowOpacity(2.0)
        test_ip_app.setStyleSheet(_fromUtf8("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(7, 7, 7, 187), stop:1 rgba(7, 7, 7, 185));"))
        self.centralwidget = QtGui.QWidget(test_ip_app)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.label_sub_titulo = QtGui.QLabel(self.centralwidget)
        self.label_sub_titulo.setGeometry(QtCore.QRect(70, 110, 111, 21))
        self.label_sub_titulo.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.label_sub_titulo.setStyleSheet(_fromUtf8("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 198), stop:1 rgba(0, 0, 0, 165));\n"
"background-image: url();\n"
"text-decoration: underline;\n"
"font: 87 9pt \"Arial Black\";\n"
"color: rgb(255, 255, 255);"))
        self.label_sub_titulo.setAlignment(QtCore.Qt.AlignCenter)
        self.label_sub_titulo.setObjectName(_fromUtf8("label_sub_titulo"))
        self.lineEdit_resultado_del_ip = QtGui.QLineEdit(self.centralwidget)
        self.lineEdit_resultado_del_ip.setGeometry(QtCore.QRect(340, 80, 341, 211))
        self.lineEdit_resultado_del_ip.setStyleSheet(_fromUtf8("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 198), stop:1 rgba(0, 0, 0, 165));\n"
"background-image: url();\n"
"font: 87 9pt \"Arial Black\";\n"
"color: rgb(255, 255, 255);"))
        self.lineEdit_resultado_del_ip.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.lineEdit_resultado_del_ip.setReadOnly(True)
        self.lineEdit_resultado_del_ip.setObjectName(_fromUtf8("lineEdit_resultado_del_ip"))
        self.label_titulo = QtGui.QLabel(self.centralwidget)
        self.label_titulo.setGeometry(QtCore.QRect(30, 40, 191, 31))
        self.label_titulo.setStyleSheet(_fromUtf8("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 198), stop:1 rgba(0, 0, 0, 165));\n"
"background-image: url();\n"
"text-decoration: underline;\n"
"font-size: 15px;\n"
"font: 87 9pt \"Arial Black\";\n"
"color: rgb(255, 255, 255);"))
        self.label_titulo.setAlignment(QtCore.Qt.AlignCenter)
        self.label_titulo.setObjectName(_fromUtf8("label_titulo"))
        self.pushButton_ver_ip_btn = QtGui.QPushButton(self.centralwidget)
        self.pushButton_ver_ip_btn.setGeometry(QtCore.QRect(60, 190, 131, 41))
        self.pushButton_ver_ip_btn.setStyleSheet(_fromUtf8("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(12, 12, 12, 255), stop:1 rgba(46, 45, 45, 255));\n"
"border-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(221, 221, 221, 255), stop:1 rgba(216, 216, 216, 255));\n"
"background-image: url();\n"
"font: 87 9pt \"Arial Black\";\n"
"color: rgb(255, 255, 255);"))
        self.pushButton_ver_ip_btn.setObjectName(_fromUtf8("pushButton_ver_ip_btn"))
        self.lineEdit_ingresar_ip = QtGui.QLineEdit(self.centralwidget)
        self.lineEdit_ingresar_ip.setGeometry(QtCore.QRect(70, 150, 113, 20))
        self.lineEdit_ingresar_ip.setStyleSheet(_fromUtf8("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 198), stop:1 rgba(0, 0, 0, 165));\n"
"background-image: url();\n"
"font: 87 9pt \"Arial Black\";\n"
"color: rgb(255, 255, 255);"))
        self.lineEdit_ingresar_ip.setObjectName(_fromUtf8("lineEdit_ingresar_ip"))
        test_ip_app.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(test_ip_app)#        self.menubar.setGeometry(QtCore.QRect(0, 0, 758, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.statusbar = QtGui.QStatusBar(test_ip_app)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))

        self.retranslateUi(test_ip_app)
        QtCore.QMetaObject.connectSlotsByName(test_ip_app)

    def retranslateUi(self, test_ip_app):
        test_ip_app.setWindowTitle(QtGui.QApplication.translate("test_ip_app", "Test IP - Dominio", None, QtGui.QApplication.UnicodeUTF8))
        self.label_sub_titulo.setText(QtGui.QApplication.translate("test_ip_app", "Realizar Testeo", None, QtGui.QApplication.UnicodeUTF8))
        self.label_titulo.setText(QtGui.QApplication.translate("test_ip_app", "Testeo de IP - Dominio", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_ver_ip_btn.setText(QtGui.QApplication.translate("test_ip_app", "Ejecutar Consulta", None, QtGui.QApplication.UnicodeUTF8))


Ahora si :P?
__________________
Página Principal: http://www.almightysystem.com.ar/