Pyside: Build a "Search" dialog box

Source: Internet
Author: User

Let's take a look at the final:

Full code:

#! /Usr/bin/ENV pythonimport sysfrom pyside. qtcore import * From pyside. qtgui import * class finddialog (qdialog): def _ init _ (self, parent = none): qdialog. _ init _ (self, parent) # create a label & edit label = qlabel ('Find & what: ') lineedit = qlineedit () label. setbuddy (lineedit) # When Alt + W is pressed, the focus is on edit. # Create checkbox casecheckbox = qcheckbox ('match & case') backwardcheckbox = qcheckbox ('search & backward ') # create find button findbutton = qpushbutton (' & find ') findbutton. setdefault (true) # set as the default button findbutton. setenabled (false) # Set the button to disable closebutton = qpushbutton ('close') # topleftlayout = qhboxlayout () topleftlayout in the layout dialog box. addwidget (Label) topleftlayout. addwidget (lineedit) leftlayout = qvboxlayout () leftlayout. addlayout (topleftlayout) leftlayout. addwidget (casecheckbox) leftlayout. addwidget (backwardcheckbox) rightlayout = qvboxlayout () rightlayout. addwidget (findbutton) rightlayout. addwidget (closebutton) rightlayout. addstretch () mainlayout = qhboxlayout () mainlayout. addlayout (leftlayout) mainlayout. addlayout (rightlayout) self. setlayout (mainlayout) # Set the dialog box title self. setwindowtitle ('Find ') def main (): APP = qapplication (sys. argv) d = finddialog () d. show () sys.exit(app.exe C _ () If _ name _ = '_ main _': Main ()

There is no actual function code in this section. It mainly demonstrates how to build a "Search" dialog box user interface through qhboxlayout and qvboxlayout.

The following dialog box shows the layout and parent-child relationship diagram:

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.