PYQT4 implementation drop-down menu to choose from and print out

Source: Internet
Author: User
This article mainly for you to introduce the PYQT4 implementation of the drop-down menu to choose and print out, with a certain reference value, interested in small partners can refer to

This article for you to share the PYQT4 implementation of the drop-down menu to choose and print out the specific code for your reference, the specific content is as follows

#-*-coding:cp936-*-#QComboBox window component allows the user to select #这个例子中显示一个 qcombobox and a qlabel from the list of lists. The combo box has a list of 5 options, #他们是Linux发行版的名称. The label displays the content selected from the combo box. From PYQT4 import Qtgui, Qtcore class Example (qtgui.qwidget): def __init__ (self): Super (Example, self). __init__ () se  Lf.initui () def initui (self): #self. Label = Qtgui.qlabel ("Ubuntu", self) #创建一个 the Qcombobox window component and adds 5 options.  Combo = Qtgui.qcombobox (self) combo.additem ("Ubuntu") Combo.additem ("Mandriva") Combo.additem ("Fedora") Combo.additem ("Red Hat") Combo.additem ("Gentoo") Combo.move #self. Label.move (.) #当一个选项被选择, we call Onacti  Vated () method.  Self.connect (Combo, qtcore.signal (' Activated (QString) '), self.onactivated) Self.setgeometry (250, 200, 350, 250)  Self.setwindowtitle (' Qcombobox ') #在该方法中, we set the selection to the label and adjust the size of the label. def onActivated (self, text): Print text #self. Label.settext (text) #self. Label.adjustsize () def main (): app = Qtgui.qa Pplication ([]) ex = Example () ex.show () app.exec_ () if __name__ = = ' __main__ ': Main ()

Related Article

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.