PYQT4 Menu bar + toolbar + status bar + Center part to generate a text editing piece example

Source: Internet
Author: User

We will create a menu bar, a toolbar, a status bar, and a central part.

#!/usr/bin/python#-*-coding:utf-8-*-ImportSYS fromPyQt4ImportQtgui, QtcoreclassMainWindow (Qtgui.qmainwindow):def __init__(Self, parent =None): Qtgui.qmainwindow.__init__(self) self.resize (350, 250) Self.setwindowtitle ('main Window') TextEdit=Qtgui.qtextedit () self.setcentralwidget (textEdit) Exit= Qtgui.qaction (Qtgui.qicon ('Exit.png'),'Exit', self) exit.setshortcut ('Ctrl+q') Exit.setstatustip ('Exit Application') Self.connect (Exit, Qtcore.signal ('triggered ()'), Qtgui.qapp, Qtcore.slot ('quit ()') ) Self.statusbar () MenuBar=self.menubar () file= Menubar.addmenu ('&file') file.addaction (exit) Self.toolbar= Self.addtoolbar ('Exit') self.toolbar.addAction (exit) app=qtgui.qapplication (SYS.ARGV) main=MainWindow () main.show () Sys.exit (App.exec_ ())

Effect:

In this example, we created a text-editing part and set it as the central part of the Qmainwindow. The center part will occupy all the remaining space in the window.

PYQT4 Menu bar + toolbar + status bar + Center part to generate a text editing piece example

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.