Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 511297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:12:07+00:00 2026-05-13T07:12:07+00:00

I’m new to PyQt though I know python a bit.. I wanted to Qt

  • 0

I’m new to PyQt though I know python a bit.. I wanted to Qt designer for GUI programming since it’ll make my job easier. I’ve taken a simple dialog in Qt designer and converted using pyuic4.

from PyQt4 import QtCore, QtGui

class Ui_Form1(object):
    def setupUi(self, Form1):
        Form1.setObjectName("Form1")
        Form1.resize(495, 364)
        self.listWidget = QtGui.QListWidget(Form1)
        self.listWidget.setGeometry(QtCore.QRect(60, 100, 221, 111))
        self.listWidget.setObjectName("listWidget")
        self.lineEdit = QtGui.QLineEdit(Form1)
        self.lineEdit.setGeometry(QtCore.QRect(60, 250, 221, 26))
        self.lineEdit.setObjectName("lineEdit")
        self.pushButton = QtGui.QPushButton(Form1)
        self.pushButton.setGeometry(QtCore.QRect(350, 170, 92, 28))
        self.pushButton.setAutoDefault(False)
        self.pushButton.setObjectName("pushButton")

        self.retranslateUi(Form1)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.listWidget.clear)
        QtCore.QMetaObject.connectSlotsByName(Form1)

    def retranslateUi(self, Form1):
        Form1.setWindowTitle(QtGui.QApplication.translate("Form1", "Form1", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton.setText(QtGui.QApplication.translate("Form1", "X", None, QtGui.QApplication.UnicodeUTF8))

I want to run this program. How to run this program from this file by importing this? I know it’s a very basic question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:12:08+00:00Added an answer on May 13, 2026 at 7:12 am

    You may pass -x parameter to pyuic. It will generate addtional code to make the script executable.


    In real application you should better write a subclass of QMainWindow which could look like this:

    # Store this code in the file MyMainWindow.py
    from PyQt4.QtGui import *
    
    class MyMainWindow(QMainWindow):
        def __init__(self, ui_layout):
            QMainWindow.__init__(self)
    
            self.ui = ui_layout
            ui_layout.setupUi(self)
    

    And also create a main executable script in the same directory as MyMainWindow.py:

    from PyQt4.QtGui import *
    from MyMainWindow import *
    from Form1 import *             # replace Form1 the name of your generated file
    import sys
    
    app = QApplication(sys.argv)
    
    window = MyMainWindow(Ui_Form1())
    window.show()
    
    sys.exit(app.exec_())
    

    Then run this last script to launch the program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 307k
  • Answers 307k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer self points to the class in which it is written.… May 13, 2026 at 9:34 pm
  • Editorial Team
    Editorial Team added an answer iconv -f utf-8 -t latin1 < in.sql | iconv -f… May 13, 2026 at 9:34 pm
  • Editorial Team
    Editorial Team added an answer I don't believe restarting apache every 5 minutes is the… May 13, 2026 at 9:34 pm

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.