#-*-Coding: UTF-8 -*-
# Python: 2.x
_ Author _ = 'admin'
From pyqt4.qtgui import *
From pyqt4.qt import *
From pyqt4.qtcore import *
Import sys
Qtextcodec. setcodecfortr (qtextcodec. codecforname ("utf8 "))
Class Example (qdialog ):
Def _ init _ (self, parent = none ):
Super (example, self). _ init _ (parent)
Label2 = qlabel (self. tr ("gender "))
Label3 = qlabel (self. tr ("Age "))
Label4 = qlabel (self. tr ("height "))
Self. sexlabel = qlabel (self. tr ("male "))
Sexbutton = qpushbutton ("...")
Agebutton = qpushbutton ("...")
Staturebutton = qpushbutton ("...")
Self. sexlabel = qlabel (self. tr ("male "))
Self. sexlabel. setframestyle (qframe. Panel | qframe. Sunken)
# Qframe. panelqframe indicates that the content of a panel is concave or concave.
# Qframe. Sunken frame and content appear sunk; draw a 3 D concave line using the light of the current color and the dark color group
Self. agelabel = qlabel ("25 ")
Self. agelabel. setframestyle (qframe. Panel | qframe. Sunken)
Self. staturelabel = qlabel ("168 ")
Self. staturelabel. setframestyle (qframe. Panel | qframe. Sunken)
Layout = qgridlayout ()
Layout. addwidget (label2, 1, 0)
Layout. addwidget (self. sexlabel, 1, 1)
Layout. addwidget (sexbutton, 1, 2)
Layout. addwidget (label3, 2, 0)
Layout. addwidget (self. agelabel, 2, 1)
Layout. addwidget (agebutton, 2, 2)
Layout. addwidget (label4, 3, 0)
Layout. addwidget (self. staturelabel, 3, 1)
Layout. addwidget (staturebutton, 3, 2)
Self. setlayout (layout)
Self. Connect (sexbutton, signal ("clicked ()"), self. slotsex)
Self. Connect (agebutton, signal ("clicked ()"), self. slotage)
Self. Connect (staturebutton, signal ("clicked ()"), self. slotstature)
Def slotsex (Self ):
Listsex = qstringlist ()
Listsex. append (u'male ')
Listsex. append (u'female ')
Sex, OK = qinputdialog. getitem (self, self. tr ('gender'), self. tr ('select gender '),
Listsex)
If OK:
Self. sexlabel. settext (sex)
Def slotage (Self ):
Age, OK = qinputdialog. getinteger (self, self. tr ("Age "),
Self. tr ("Enter age :"),
INT (self. agelabel. Text (), 0,150)
If OK:
Self. agelabel. settext (STR (AGE ))
Def slotstature (Self ):
Stature, OK = qinputdialog. getdouble (self, self. tr ("height "),
Self. tr ("Enter Height :"),
Float (self. staturelabel. Text (), 0, 2300.00)
If OK:
Self. staturelabel. settext (STR (stature ))
APP = qapplication (SYS. argv)
X = example ()
X. Show ()
Sys.exit(app.exe C _())
: