Python
  Home arrow Python arrow Page 2 - PyQT: Handling Windows and Buttons
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

PyQT: Handling Windows and Buttons
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2006-04-05

    Table of Contents:
  • PyQT: Handling Windows and Buttons
  • Slots
  • QPushButton
  • PyQT in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PyQT: Handling Windows and Buttons - Slots


    (Page 2 of 4 )

     

    The show() and exec_loop() methods determine whether the dialogs are modal  or modeless. However the main purpose of dialogs is to provide information feedback to the user, as well as to gather information from the user using buttons such as OK and Cancel. For these purposes, the accept() and reject() slots have been provided by the QDialog class. 

    Both of these are protected Slots. They are available only to the classes inherited from QDialog.

    The accept() slot closes the dialog and sets the return value to ACCEPTED. This value is equivalent to the Boolean value of 1. The best scenario to visualize the usage of accept() is a button representing OK. If the clicked signal of this button is connected with the accept() slot, then upon the button being clicked, the dialog box would be closed and the return value would become ACCEPTED. In code this would be:

           self.OK = QPushButton(self,"OK")
       self.connect(self.OK,SIGNAL("clicked()"),self.accept)

    The above code is a snippet from an about dialog. When the OK button is clicked, the signal connects to the accept() dialog.

    The reject() slot provides functionalities that are the opposite of accept(). It comes into picture when the dialog is canceled. The return code is set to Rejected. This slot can be connected to the signal corresponding to the dialog box or any button's clicked() signal. If the button's clicked() signal is connected, then the code would be:       

    self.Cancel = QPushButton(self,"Cancel")
    self.connect(self.Cancel,SIGNAL("clicked()"),self.reject)

    QDialog (as of version 3.x) doesn't emit any signal of its own.  That's about it for QDialog and its main slots and methods. Next is the most common widget of all: the command button, or in the terminology of PyQT, QPushButton. 

    More Python Articles
    More By A.P.Rajshekhar


       · In the second part of the PyQT series I have discussed the two of the most common...
     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway