Qtdesigner PyQt4 Python

Source: Internet
Author: User

This article describes creating a GUI with Qtdesigner and converting it to an executable python file via PyQt4

1. Qtdesigner A. ui file (Eg:TestUI.ui) is generated when a GUI is created

2. Generate the Py file (testui.py) We need by command Python Pyuic.py-o testui.py testui.ui

3. Create a test.py file and edit the following code:

1 ImportSYS2  fromPyqt4.qtguiImport*3  fromPyqt4.qtcoreImport*4 ImportTestui5       6 classUITest (Qmainwindow,testui.ui_mainwindow):7     def __init__(Self, parent=None):8Super (UITest, self).__init__(parent)9 self.setupui (self)Ten        OneApp =qapplication (SYS.ARGV) AW =uitest () - w.show () -APP.EXEC_ ()

4. Python test.py to get the GUI you designed in step 1

NOTE: Pyuic parameter description:

  • NAME

  • Pyuic4-compile QT4 user interfaces to Python code

  • Synopsis

  • PYUIC4 [OPTION] ... FILE

  • DESCRIPTION

  • Pyuic4 takes a QT4 user interface description file and compiles it to

  • Python code. It can also show a preview of the user interface.

  • OPTIONS

  • -H,--help

  • Show a summary of the options.

  • --version

  • Display The version number of PYUIC4 of the version of Qt which

  • PYQT4 is generated for.

  • -P,--preview

  • Show a preview of the UI instead of generating Python code.

  • -O,--output=file

  • Write the generated Python code to FILE instead of stdout.

  • -D,--debug

  • Show detailed debugging information about the UI generation

  • Process.

  • -X,--execute

  • Generate extra code to test and display the class when executed

  • As a script.

  • -I.,--indent=num

  • Set the indentation width to NUM spaces. A TAB character'll be

  • Used if NUM is 0 (default:4).


Qtdesigner PyQt4 Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.