Home arrow Python arrow Page 4 - PyQT: Input Widgets

The Connections - Python

You may have experienced some headaches in the past when creating GUIs to gather user input. Python makes this process easy with input widgets. Keep reading to learn more.

TABLE OF CONTENTS:
  1. PyQT: Input Widgets
  2. QCheckBox
  3. PyQT in the Real World
  4. The Connections
  5. The Main Part
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 4
November 20, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Next comes the connections. The enterPressed signal of the lineEdit1 is connected with the selectAll slot of lineEdit2. Similarly, the clicked signal of pushbutton2(having reset its value) is connected to the clear slot of both the textboxes.

class Form1(QDialog):

    def __init__(self,parent = None,name = None,modal = 0,fl =
0):

        QDialog.__init__(self,parent,name,modal,fl)

        if not name:

            self.setName("Form1")

        self.textLabel1 = QLabel(self,"textLabel1")

        self.textLabel1.setGeometry(QRect(30,71,111,30))

        self.textLabel1_2 = QLabel(self,"textLabel1_2")

        self.textLabel1_2.setGeometry(QRect(30,140,111,30))

        self.lineEdit1 = QLineEdit(self,"lineEdit1")

        self.lineEdit1.setGeometry(QRect(160,70,181,31))

        self.lineEdit2 = QLineEdit(self,"lineEdit2")

        self.lineEdit2.setGeometry(QRect(161,140,180,31))

       self.checkBox1 = QCheckBox(self,"checkBox1")

        self.checkBox1.setGeometry(QRect(30,190,91,21))

        self.pushButton1 = QPushButton(self,"pushButton1")

        self.pushButton1.setEnabled(1)

        self.pushButton1.setGeometry(QRect(30,230,141,21))

        self.pushButton1_2 = QPushButton(self,"pushButton1_2")

        self.pushButton1_2.setEnabled(1)

        self.pushButton1_2.setGeometry(QRect(210,230,141,21))

        self.languageChange()

        self.resize(QSize(600,480).expandedTo
(self.minimumSizeHint()))

        self.clearWState(Qt.WState_Polished)

         self.connect(self.lineEdit1,SIGNAL
("returnPressed()"),

                      self.lineEdit2.selectAll)

         self.connect(self.pushButton1_2,SIGNAL
("clicked()"),

                                      self.lineEdit1.clear)

         self.connect(self.pushButton1_2,SIGNAL
("clicked()"),

                                    self.lineEdit2.clear)

    def languageChange(self):

        self.setCaption(self.__tr("Form1"))

        self.textLabel1.setText(self.__tr("Host"))

        self.textLabel1_2.setText(self.__tr("Port"))

        self.pushButton1.setText(self.__tr("Submit"))

        self.pushButton1_2.setText(self.__tr("Reset"))

        self.checkBox1.setText(self.__tr("Secured"))

        self.lineEdit1.setText(self.__tr("192.168.1.1"))

        self.lineEdit2.setText(self.__tr("3306"))

    def __tr(self,s,c = None):

        return qApp.translate("Form1",s,c)



 
 
>>> More Python Articles          >>> More By A.P.Rajshekhar
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: