QT - IMPOSIBLE ABRIR UNA NUEVA VENTANA

 
Vista:
sin imagen de perfil

IMPOSIBLE ABRIR UNA NUEVA VENTANA

Publicado por Juan C (1 intervención) el 22/03/2016 22:00:35
Hola compañeros, tengo un problema, resulta que estoy intentando hacer una aplicacion para la facultad en donde me quede trabado al intentar abrir una nueva ventana desde de la ventana principal al hacer click en un boton de la aplicacion.

Sin mas estos son los modulos.


ESTE ES EL MODULO DE LA VENTANA QUE QUIERO ABRIR. Hecho en QtDesinger y transformado con cmd.
from PyQt4 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_NuevoContacto(object):
def setupUi(self, NuevoContacto):
NuevoContacto.setObjectName(_fromUtf8("NuevoContacto"))
NuevoContacto.resize(303, 241)
self.lineNombre = QtGui.QLineEdit(NuevoContacto)
self.lineNombre.setGeometry(QtCore.QRect(102, 20, 191, 20))
self.lineNombre.setObjectName(_fromUtf8("lineNombre"))
self.lineApellido = QtGui.QLineEdit(NuevoContacto)
self.lineApellido.setGeometry(QtCore.QRect(102, 60, 191, 20))
self.lineApellido.setObjectName(_fromUtf8("lineApellido"))
self.lineNumero = QtGui.QLineEdit(NuevoContacto)
self.lineNumero.setGeometry(QtCore.QRect(102, 100, 191, 20))
self.lineNumero.setObjectName(_fromUtf8("lineNumero"))
self.lineDireccion = QtGui.QLineEdit(NuevoContacto)
self.lineDireccion.setGeometry(QtCore.QRect(102, 140, 191, 20))
self.lineDireccion.setObjectName(_fromUtf8("lineDireccion"))
self.label = QtGui.QLabel(NuevoContacto)
self.label.setGeometry(QtCore.QRect(20, 20, 46, 13))
self.label.setObjectName(_fromUtf8("label"))
self.label_2 = QtGui.QLabel(NuevoContacto)
self.label_2.setGeometry(QtCore.QRect(20, 100, 46, 13))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.label_3 = QtGui.QLabel(NuevoContacto)
self.label_3.setGeometry(QtCore.QRect(20, 60, 46, 13))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QtGui.QLabel(NuevoContacto)
self.label_4.setGeometry(QtCore.QRect(20, 140, 46, 13))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.pushCargar = QtGui.QPushButton(NuevoContacto)
self.pushCargar.setGeometry(QtCore.QRect(100, 210, 101, 23))
self.pushCargar.setObjectName(_fromUtf8("pushCargar"))
self.pushVolver = QtGui.QPushButton(NuevoContacto)
self.pushVolver.setGeometry(QtCore.QRect(220, 210, 75, 23))
self.pushVolver.setObjectName(_fromUtf8("pushVolver"))
self.pushLimpiar = QtGui.QPushButton(NuevoContacto)
self.pushLimpiar.setGeometry(QtCore.QRect(10, 210, 75, 23))
self.pushLimpiar.setObjectName(_fromUtf8("pushLimpiar"))
self.pushMostrar = QtGui.QPushButton(NuevoContacto)
self.pushMostrar.setGeometry(QtCore.QRect(10, 180, 281, 23))
self.pushMostrar.setObjectName(_fromUtf8("pushMostrar"))


self.retranslateUi(NuevoContacto)
QtCore.QObject.connect(self.pushLimpiar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineDireccion.clear)
QtCore.QObject.connect(self.pushLimpiar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineNumero.clear)
QtCore.QObject.connect(self.pushLimpiar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineApellido.clear)
QtCore.QObject.connect(self.pushLimpiar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineNombre.clear)
QtCore.QObject.connect(self.pushVolver, QtCore.SIGNAL(_fromUtf8("clicked()")), NuevoContacto.close)
# QtCore.QObject.connect(self.pushCargar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Carga)
QtCore.QObject.connect(self.pushCargar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineDireccion.clear)
QtCore.QObject.connect(self.pushCargar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineNumero.clear)
QtCore.QObject.connect(self.pushCargar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineApellido.clear)
QtCore.QObject.connect(self.pushCargar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineNombre.clear)
# QtCore.QObject.connect(self.pushMostrar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Muestra)
QtCore.QMetaObject.connectSlotsByName(NuevoContacto)



# def Carga(self):
#Funcion correcta

# def Muestra(self):
#Funcion correcta

def retranslateUi(self, NuevoContacto):
NuevoContacto.setWindowTitle(_translate("NuevoContacto", "Agenda", None))
self.label.setText(_translate("NuevoContacto", "Nombre", None))
self.label_2.setText(_translate("NuevoContacto", "Numero", None))
self.label_3.setText(_translate("NuevoContacto", "Apellido", None))
self.label_4.setText(_translate("NuevoContacto", "Direccion", None))
self.pushCargar.setText(_translate("NuevoContacto", "Cargar", None))
self.pushVolver.setText(_translate("NuevoContacto", "Volver", None))
self.pushLimpiar.setText(_translate("NuevoContacto", "Limpiar", None))
self.pushMostrar.setText(_translate("NuevoContacto", "Mostrar", None))


if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
NuevoContacto = QtGui.QDialog()
ui = Ui_NuevoContacto()
ui.setupUi(NuevoContacto)
NuevoContacto.show()
sys.exit(app.exec_())


Y ESTE ES EL DE LA PRINCIPAL. El que se ejecuta. Hecha tambien en QtDesinger.
from PyQt4 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)


class Ui_Principal(object):
def setupUi(self, Principal):
Principal.setObjectName(_fromUtf8("Principal"))
Principal.resize(393, 542)
self.lineEdit = QtGui.QLineEdit(Principal)
self.lineEdit.setGeometry(QtCore.QRect(10, 10, 151, 20))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.radioNombre = QtGui.QRadioButton(Principal)
self.radioNombre.setGeometry(QtCore.QRect(170, 10, 82, 17))
self.radioNombre.setObjectName(_fromUtf8("radioNombre"))
self.radioTelefono = QtGui.QRadioButton(Principal)
self.radioTelefono.setGeometry(QtCore.QRect(240, 10, 82, 17))
self.radioTelefono.setObjectName(_fromUtf8("radioTelefono"))
self.pushBuscar = QtGui.QPushButton(Principal)
self.pushBuscar.setGeometry(QtCore.QRect(310, 10, 71, 21))
self.pushBuscar.setObjectName(_fromUtf8("pushBuscar"))
self.pushSalir = QtGui.QPushButton(Principal)
self.pushSalir.setGeometry(QtCore.QRect(310, 510, 75, 23))
self.pushSalir.setObjectName(_fromUtf8("pushSalir"))
self.pushLimpiar = QtGui.QPushButton(Principal)
self.pushLimpiar.setGeometry(QtCore.QRect(10, 510, 75, 23))
self.pushLimpiar.setObjectName(_fromUtf8("pushLimpiar"))
self.pushNuevo = QtGui.QPushButton(Principal)
self.pushNuevo.setGeometry(QtCore.QRect(110, 510, 171, 23))
self.pushNuevo.setObjectName(_fromUtf8("pushNuevo"))
self.Tabla = QtGui.QTableWidget(Principal)
self.Tabla.setGeometry(QtCore.QRect(10, 40, 371, 461))
self.Tabla.setObjectName(_fromUtf8("Tabla"))
self.Tabla.setColumnCount(3)
self.Tabla.setRowCount(1000)
item = QtGui.QTableWidgetItem()
self.Tabla.setHorizontalHeaderItem(0, item)
item = QtGui.QTableWidgetItem()
self.Tabla.setHorizontalHeaderItem(1, item)
item = QtGui.QTableWidgetItem()
self.Tabla.setHorizontalHeaderItem(2, item)

self.retranslateUi(Principal)
QtCore.QObject.connect(self.pushSalir, QtCore.SIGNAL(_fromUtf8("clicked()")), Principal.close)
# QtCore.QObject.connect(self.pushBuscar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Busqueda)
# QtCore.QObject.connect(self.pushLimpiar, QtCore.SIGNAL(_fromUtf8("clicked()")), self.lineEdit.clear)
# QtCore.QObject.connect(self.pushNuevo, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Abrir)
QtCore.QMetaObject.connectSlotsByName(Principal)


# def Busqueda(self):
#Funcion correcta

# def Abrir(self):
#AQUI TENDRIA QUE IR LA FUNCION QUE ABRA LA VENTANA AL PRESIONAR EL BOTON "NUEVO"
#AQUI TENDRIA QUE IR LA FUNCION QUE ABRA LA VENTANA AL PRESIONAR EL BOTON "NUEVO"
#AQUI TENDRIA QUE IR LA FUNCION QUE ABRA LA VENTANA AL PRESIONAR EL BOTON "NUEVO"




def retranslateUi(self, Principal):
Principal.setWindowTitle(_translate("Principal", "Agenda", None))
self.radioNombre.setText(_translate("Principal", "Nombre", None))
self.radioTelefono.setText(_translate("Principal", "Telefono", None))
self.pushBuscar.setText(_translate("Principal", "Buscar", None))
self.pushSalir.setText(_translate("Principal", "Salir", None))
self.pushLimpiar.setText(_translate("Principal", "Limpiar", None))
self.pushNuevo.setText(_translate("Principal", "Nuevo", None))
item = self.Tabla.horizontalHeaderItem(0)
item.setText(_translate("Principal", "Nombre", None))
item = self.Tabla.horizontalHeaderItem(1)
item.setText(_translate("Principal", "Numero", None))
item = self.Tabla.horizontalHeaderItem(2)
item.setText(_translate("Principal", "Direccion", None))


if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Principal = QtGui.QDialog()
ui = Ui_Principal()
ui.setupUi(Principal)
Principal.show()
sys.exit(app.exec_())


NECESITARIA QUE ALGUIEN ME AYUDE A PODER ABRIR ESA VENTANA O COMO ES LA MALDITA FUNCION.

Estoy trabajando con Python2.7 y Qt4 si prueban el código asi en python como esta sale andando.

Desde ya gracias al que me pueda ayudar, estoy trabadisimo y no puedo continuar por que la carga de datos la quiero realizar desde la nueva ventana.

GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder