Foros del Web » Programando para Internet » Python »

error en Python usando qt

Estas en el tema de error en Python usando qt en el foro de Python en Foros del Web. buenas tardes amigo pues escribo en este foro por una duda que tengo estoy haciendo un tutorial para una app hecha en Qt 4 designer ...
  #1 (permalink)  
Antiguo 26/06/2014, 14:33
 
Fecha de Ingreso: junio-2014
Ubicación: Maracay
Mensajes: 7
Antigüedad: 9 años, 10 meses
Puntos: 0
error en Python usando qt

buenas tardes amigo pues escribo en este foro por una duda que tengo

estoy haciendo un tutorial para una app hecha en Qt 4 designer mi problema es que ya he hecho todos los pasos que me indican en el tutorial igual al ejecutar el codigo me da un error

aqui esta el codigo


Código:
__author__ = 'hito'
from PyQt4 import QtCore, QtGui
import sys

import show_name


class MainDialog(QDialog, show_name.ui_mainDialog):

    def __init__(self, parent=None):

        super(MainDialog,self).__init__(parent)
        self.setup(self)



app= QApplication(sys.argv)
form= MainDialog()
form.show()
app.exec_()

este es el error

Traceback (most recent call last):
File "/home/hito/develop/Qt/im_cod_qt.py", line 8, in <module>
class MainDialog(QDialog, show_name.ui_mainDialog):
NameError: name 'QDialog' is not defined

uso pyQt python 2.7
no se que hacer alguna ayuda please disculpen si hice mal el post soy nuevo en el foro
  #2 (permalink)  
Antiguo 26/06/2014, 14:54
 
Fecha de Ingreso: junio-2014
Ubicación: Maracay
Mensajes: 7
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: error en Python usando qt

se me olvidaba aqui esta el codigo .py del .ui
Código Python:
Ver original
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'show_name.ui'
  4. #
  5. # Created: Thu Jun 26 14:01:28 2014
  6. #      by: PyQt4 UI code generator 4.9.1
  7. #
  8. # WARNING! All changes made in this file will be lost!
  9.  
  10. from PyQt4 import QtCore, QtGui
  11.  
  12. try:
  13.     _fromUtf8 = QtCore.QString.fromUtf8
  14. except AttributeError:
  15.     _fromUtf8 = lambda s: s
  16.  
  17. class Ui_MainDialog(object):
  18.     def setupUi(self, MainDialog):
  19.         MainDialog.setObjectName(_fromUtf8("MainDialog"))
  20.         MainDialog.resize(415, 101)
  21.         self.NameEdit = QtGui.QLineEdit(MainDialog)
  22.         self.NameEdit.setGeometry(QtCore.QRect(20, 40, 271, 27))
  23.         self.NameEdit.setText(_fromUtf8(""))
  24.         self.NameEdit.setObjectName(_fromUtf8("NameEdit"))
  25.         self.show_button = QtGui.QPushButton(MainDialog)
  26.         self.show_button.setGeometry(QtCore.QRect(310, 40, 85, 27))
  27.         self.show_button.setObjectName(_fromUtf8("show_button"))
  28.  
  29.         self.retranslateUi(MainDialog)
  30.         QtCore.QMetaObject.connectSlotsByName(MainDialog)
  31.         MainDialog.setTabOrder(self.show_button, self.NameEdit)
  32.  
  33.     def retranslateUi(self, MainDialog):
  34.         MainDialog.setWindowTitle(QtGui.QApplication.translate("MainDialog", "Main Dialog", None, QtGui.QApplication.UnicodeUTF8))
  35.         self.NameEdit.setPlaceholderText(QtGui.QApplication.translate("MainDialog", "what is you name?", None, QtGui.QApplication.UnicodeUTF8))
  36.         self.show_button.setText(QtGui.QApplication.translate("MainDialog", "Show", None, QtGui.QApplication.UnicodeUTF8))


no si afecte en algo pero mi ide es pycham
  #3 (permalink)  
Antiguo 26/06/2014, 14:55
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: error en Python usando qt

Tal como sugiere el error:
Código Python:
Ver original
  1. NameError: name 'QDialog' is not defined

QDialog no esta definido, tienes que importarlo.
Código Python:
Ver original
  1. from PyQt4 import QtCore, QtGui
  2. from PyQt4.QtGui import QDialog
  #4 (permalink)  
Antiguo 27/06/2014, 08:38
 
Fecha de Ingreso: junio-2014
Ubicación: Maracay
Mensajes: 7
Antigüedad: 9 años, 10 meses
Puntos: 0
Respuesta: error en Python usando qt

hola como estas hice la modificacion que me sugeriste y me sale otro error ahora

AttributeError: 'module' object has no attribute 'ui_mainDialog'

pues no se porque los errores porque en el tutorial lo muestran sin errores y segun al importar QtGui ya deberia importar QDialog aqui esta el link del tutorial aunque alli usan pyside pero tengo entendido que colocando pyqt deberia dar lo mismo aqui esta el tutorial

[URL="http://www.youtube.com/results?search_query=qt+designer+tutorial+espa%C3% B1ol&page=2"]http://www.youtube.com/results?search_query=qt+designer+tutorial+espa%C3% B1ol&page=2[/URL]

estoy usando Qt 4 designer

si alguien conoce algun tutorial mas actual para probar
  #5 (permalink)  
Antiguo 27/06/2014, 09:01
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: error en Python usando qt

Igual tal como el error sugiere:

Cita:
AttributeError: 'module' object has no attribute 'ui_mainDialog'
No existe el atributo ui_mainDialog y es porque se llama Ui_MainDialog

Haz intentado leer el código o los errores?
  #6 (permalink)  
Antiguo 27/06/2014, 10:45
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: error en Python usando qt

Antes deberías leer algún libro de Python tus errores no tienen que ver con Qt.

Saludos
__________________
Grupo Telegram Docker en Español

Etiquetas: gui, usando
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:37.