我尝试使用qmlgui和Python制作一个简单的计算器。当我给出一些值,如(a=4,b=6,c=a+b)并单击按钮,它可以给出一个结果。但是我不能用python管理文本输入框。当我给输入框赋值时,如何在Python中使用文本输入框? 谢谢
QML图形用户界面:
http://postimg.org/image/o9wt326g5/
QML代码:
import QtQuick 1.1
Rectangle {
id:r
anchors.centerIn: parent
width: 200
height: 200
signal messageRequired;
function updateMessage(text) {
messageText.text = text
}
Column{
width: r.width*0.8
height: r.height*0.8
spacing: 10
anchors.centerIn: parent
Row{
id:ro
spacing:10
Text {
anchors.centerIn: ro.parent
font.bold: true
text: "a"
}
TextInput {
id: a
width: r.width*3/4
height: 20
selectionColor: "#2f8bc5"
fillColor: "lightgray"
font.bold: true
}
}
Row{
spacing:10
Text {
text: "b"
font.bold: true
}
TextInput {
id: b
width: r.width*3/4
height: 20
fillColor: "lightgray"
font.bold: true
}
}
Rectangle {
id: calculate
width: r.width
height: 30
color: "#8a0800"
Text{
anchors.centerIn: calculate
font.bold: true
text:"calculate";color:"white"
}
MouseArea {
anchors.fill: parent
onClicked:messageRequired()
}
gradient: Gradient {
GradientStop {position: 0; color: "#8a0800"}
GradientStop {position: 1; color: "#330009"}
}
}
Row{
spacing:10
Text {
text: "c"
font.bold: true
}
TextInput {
id: messageText
font.bold: true
width: r.width*3/4
height: 20
fillColor: "lightgray"
selectionColor: "#2f8bc5"
font.pixelSize: 12
}}}}
和Python代码:
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐