Python - error pyside

 
Vista:
sin imagen de perfil

error pyside

Publicado por pyside (6 intervenciones) el 25/03/2015 17:15:30
Error en la fila 17. He probado con la tabulación pero persiste el error. ¿Algún consejo?
Gracias.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# coding=utf-8
import sys
from PySide import QtGui, QtCore
 
def botoClic():
        mp =float('Inf')
        mg =float('-Inf')
text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
n = float(text)
while n != 0: 
        if n > mg:
            mg = n
        if n < mp:
            mp = n
text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
n = float(text)     
    wid.resultado.setText(str(mp)+" "+str(mg))
    
app = QtGui.QApplication(sys.argv)
wid = QtGui.QWidget()

text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
n = float(text)
wid.resultado = QtGui.QLabel()
formulario = QtGui.QGridLayout()

formulario.addWidget(wid.boto, 1, 1)
formulario.addWidget(wid.resultado, 3, 1)
wid.resize(250, 150)
wid.move(300, 200)
wid.setWindowTitle("serie")
wid.setLayout(formulario)
wid.caja1.setFocus()
QtCore.QObject.connect(wid.boto, QtCore.SIGNAL('clicked()'), botoClic)

wid.show()
sys.exit(app.exec_())
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

error pyside

Publicado por anonymous (84 intervenciones) el 26/03/2015 22:21:39
No entiendo mucho el orden del codigo, pero se supone que esta parte debe ir asi, no?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def botoClic():
    mp =float('Inf')
    mg =float('-Inf')
    text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
    n = float(text) 
    while n != 0: 
        if n > mg: 
            mg = n 
        if n < mp: 
            mp = n 
    text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
    n = float(text) 
    wid.resultado.setText(str(mp)+" "+str(mg))

Por cierto, que mensaje de error te muestra?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

error pyside

Publicado por solucionado (6 intervenciones) el 26/03/2015 22:44:50
Ya lo tengo resuelto. pero gracias.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# coding=utf-8
import sys
from PySide import QtGui, QtCore
 
def botoClic():
    mp =float('Inf')
    mg =float('-Inf')
    text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
    n = float(text)
    while n != 0: 
        if n > mg:
            mg = n
        if n < mp:
            mp = n
        text, ok = QtGui.QInputDialog.getText(wid, 'n?', "Dona'm un número:")
        n = float(text)     
    wid.resultado.setText(str(mp)+" "+str(mg))
    
app = QtGui.QApplication(sys.argv)
wid = QtGui.QWidget()
wid.boto = QtGui.QPushButton('maxmin')
wid.resultado = QtGui.QLabel()
formulario = QtGui.QGridLayout()

formulario.addWidget(wid.boto, 1, 1)
formulario.addWidget(wid.resultado, 3, 1)
wid.resize(250, 150)
wid.move(300, 200)
wid.setWindowTitle("serie")
wid.setLayout(formulario)

QtCore.QObject.connect(wid.boto, QtCore.SIGNAL('clicked()'), botoClic)

wid.show()
sys.exit(app.exec_())
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

error pyside

Publicado por anonymous (84 intervenciones) el 27/03/2015 02:01:57
Gracias por compartirlo...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar