这是我做的一个选择题的粗略例子。它在终端上运行,我希望用Tkinter为它制作一个图形用户界面。
print "CATEGORY 1: ANXIOUS FEELINGS"
print
print "1. Anxiety, nervousness, worry or fear"
BAI_var1 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")
print
print "2. Feeling that things around you are strange, unreal, or foggy"
BAI_var2 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")
print
print "3. Feeling detached from all or part of your body"
BAI_var3 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")
print "Depression Test"
print
print
print "1. Sadness: Have been feeling sad or down in the dumps?"
BDC_var1 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")
print
print "2. Discouragement: Does the future look hopeless?"
BDC_var2 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")
print
print "3. Low self-esteem: Do you feel worthless or think of yourself as a failure?"
BDC_var3 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")
#Burns Anxiety Inventory
#CATEGORY 1: ANXIOUS FEELINGS
Cat1_var = BAI_var1 + BAI_var2 + BAI_var3
#Burns Anxiety Checklist
BAI_var = Cat1_var
#Burns Depression Checklist
BDC_var = BDC_var1 + BDC_var2 + BDC_var3
#Prints your BAI & your BDC
print "Your BAI =", BAI_var,"Your BDC =", BDC_var
name = raw_input ("Please type in your name:")
bai = str(input("Please enter your BAI:"))
bdc = str(input("Please enter your BDC:"))
year = str(input("please enter the year:"))
month = str(input("Please enter the month:"))
day = str(input("Please enter day:"))
time_hour = str(input("Please enter the current hour:"))
time_minute = str(input("Please enter the current minutes:"))
am_pm = raw_input ("Please enter pm or am:")
file = open('Burns inventory 1.3.txt', 'a')
file.write(name + '\n')
file.write(day)
file.write("/")
file.write(month)
file.write("/")
file.write(year)
file.write('\n')
file.write('\n')
file.write('Your BAI is:')
file.write(bai)
file.write('\n')
file.write('Your BDC is:')
file.write(bdc)
file.write('\n')
file.write(time_hour)
file.write(':')
file.write(time_minute)
file.write('\n')
file.write(' ')
file.write(am_pm)
file.write('\n')
file.close()
我已经工作了两天了,教自己如何使用Tkinter。我和我的朋友做了一个粗略的测试示例。
^{pr2}$使用这个Tkinter GUI,我可以想到几个目标:
我没有参加考试!!我只做了软件。这个测试是由davidburns设计的,可以在他的著作《感觉良好的书》中找到。在
用
self.v
更改v
的所有位置,使其成为对象的属性。然后您将看到它具有在单选按钮组中选择的任何值。在一旦您这样做了,在您的
button5
或button6
方法中,您可以执行print self.v.get()
来查看值。在如果您现在对学习tkinter不感兴趣,easygui将非常适合于快速获得此测试的GUI。它不在标准库中,因此您必须使用
pip install
安装它,或者下载它并将轻松.py与脚本位于同一文件夹中。Easygui允许您执行以下操作:相关问题 更多 >
编程相关推荐