Re: Eric - "No module named MainWindow"

Discussion in 'Python' started by Phil, Feb 17, 2013.

  1. Phil

    Phil Guest

    On 17/02/13 21:35, Vincent Vande Vyvre wrote:
    > Le 17/02/13 10:08, Phil a écrit :
    >> Thank you for reading this.
    >>
    >> I've been playing with Eric all day and I almost have a working GUI
    >> application, but not quite. I have followed the two tutorials on the
    >> Eric site and I'm sure that I haven't miss entered anything and so I

    <cut>


    > Are you sure you have a class MainWindow in your ui.MainWindow.py ?
    >
    > Can you show us the code of this MainWindow ?


    Thank you Vincent and Joel. I think I have already tried every
    conceivable combination but I still cannot get past the error message.
    At the risk of burdening the list with lots of code I have decided to
    show the code as it stands. It's substantially that from the mini
    browser example.

    This is the auto generated code for Ui_mainWindow.py:

    # -*- coding: utf-8 -*-

    # Form implementation generated from reading ui file
    '/home/phil/mainWindow.ui'
    #
    # Created: Sun Feb 17 15:54:33 2013
    # by: PyQt4 UI code generator 4.9.3
    #
    # 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_MainWindow(object):
    def setupUi(self, MainWindow):
    MainWindow.setObjectName(_fromUtf8("MainWindow"))
    MainWindow.resize(200, 200)
    self.centralWidget = QtGui.QWidget(MainWindow)
    self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
    self.pushButton = QtGui.QPushButton(self.centralWidget)
    self.pushButton.setGeometry(QtCore.QRect(40, 120, 91, 24))
    self.pushButton.setObjectName(_fromUtf8("pushButton"))
    MainWindow.setCentralWidget(self.centralWidget)

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

    def retranslateUi(self, MainWindow):

    MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow",
    "MainWindow", None, QtGui.QApplication.UnicodeUTF8))

    self.pushButton.setText(QtGui.QApplication.translate("MainWindow",
    "PushButton", None, QtGui.QApplication.UnicodeUTF8))


    if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

    This is the code for mainWindow.py"

    class MainWindow(QMainWindow, Ui_MainWindow):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):
    """
    Constructor
    """
    QMainWindow.__init__(self, parent)
    self.setupUi(self)

    And this is the main script that I had originally used and named new_gui.py:

    from PyQt4 import QtCore, QtGui
    from ui.MainWindow import MainWindow

    if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    ui = MainWindow()
    ui.show()
    sys.exit(app.exec_())

    Finally, for completeness, this is the error message when I attempt to
    execute new_gui.py:

    The debugged program raised the exception unhandled ImportError
    "No module named mainWindow"
    File: /home/phil/new_gui.py, Line: 2

    Could it simply be a case of conflict between my file names and the
    module name?

    --
    Regards,
    Phil
     
    Phil, Feb 17, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil
    Replies:
    0
    Views:
    88
  2. Vincent Vande Vyvre

    Re: Eric - "No module named MainWindow"

    Vincent Vande Vyvre, Feb 17, 2013, in forum: Python
    Replies:
    0
    Views:
    102
    Vincent Vande Vyvre
    Feb 17, 2013
  3. Joel Goldstick

    Re: Eric - "No module named MainWindow"

    Joel Goldstick, Feb 17, 2013, in forum: Python
    Replies:
    0
    Views:
    109
    Joel Goldstick
    Feb 17, 2013
  4. Vincent Vande Vyvre

    Re: Eric - "No module named MainWindow"

    Vincent Vande Vyvre, Feb 17, 2013, in forum: Python
    Replies:
    0
    Views:
    141
    Vincent Vande Vyvre
    Feb 17, 2013
  5. Phil
    Replies:
    0
    Views:
    128
Loading...

Share This Page