我是使用python开发GUI的新手。在我正在使用的最新代码中,我需要从我制作的python GUI传递一个输入变量,并且需要将该值发送到通过参数单独运行的另一个python代码。我有一个make.sh文件,其内容如下:
#!/bin/bash
echo "Enter participants Name:"
read name
echo "Please enter participant's Age: "
read age
echo "Please enter participant's Gender:(M/F) "
read sex
python -W ignore test.py $name
clear
read -n 1 -s -p "Press any key to continue"
python -W ignore test2.py $name $age $sex
clear
如何使用python GUI实现此功能。
from Tkinter import *
import os
import subprocess
top = Tk()
L2 = Label(top, text="Enter Participate name")
L2.config(font=("Times", 11))
L2.grid(row = 5, column = 4)
userName = StringVar()
U1 = Entry(top, width=30, textvariable=userName)
U1.grid(row = 5, column = 10)
L3 = Label(top, text="Enter Age")
L3.config(font=("Times", 11))
L3.grid(row = 7, column = 4)
userName2 = IntVar()
U2 = Entry(top, width=30, textvariable=userName2)
U2.grid(row = 7, column = 10)
L4 = Label(top, text="Enter Gender:(M/F)")
L4.config(font=("Times", 11))
L4.grid(row = 9, column = 4)
userName3 = StringVar()
U3 = Entry(top, width=30, textvariable=userName3)
U3.grid(row = 9, column = 10)
def source():
subprocess.call("python test.py userName.get()", shell=True)
subprocess.call("python test2.py userName.get()", shell=True)
B1 = Button(top, text="Submit", fg="blue", command=source)
B1.grid(row = 20, column=5)
top.mainloop()
这是我编写的代码。运行此代码时也出现错误。
/bin/sh: 1: Syntax error: "(" unexpected
/bin/sh: 1: Syntax error: "(" unexpected
感谢您提供有关此问题的任何帮助。