本文整理汇总了Python中easygui.enterbox方法的典型用法代码示例。如果您正苦于以下问题:Python easygui.enterbox方法的具体用法?Python easygui.enterbox怎么用?Python easygui.enterbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类easygui
的用法示例。
在下文中一共展示了easygui.enterbox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createProtocol
# 需要导入模块: import easygui [as 别名]
# 或者: from easygui import enterbox [as 别名]
def createProtocol(preselected_channels=False, preselected_powers=None):
electrodes=[]
powers=[]
outcomes=[]
anodeChoice=eg.multchoicebox(title="Select electrodes", msg="Select the locations that you want to recieve stimulation. You can set them as anodes or cathodes in the next step.", choices=['F4','C4','O2','C3','F3','O1'])
if anodeChoice:
for item in anodeChoice:
electrodes.append(stimModes[item])
choices=anodeChoice
choices.append("Ramp up/down duration (set to 0 for no ramping)")
choices.append("Stimulation duration (minutes)")
choices.append("Sham probability(set to 0 for no sham trials")
choices.append("Frequency (set to 0 for dc stimulation)")
powers=eg.multenterbox("Enter the power that should be used for each electrode. Positive values represent anodal stimulation, and negative values represent cathodal stimulation. You can also set the duration, ramping parameters, and sham probability of the protocol","Stimulation parameters",choices)
if powers:
exMode=eg.ynbox(title="Outcome measures",msg="Do you want to add outcome measures to this protocol?")
if exMode:
outcomes=[]
selected=""
keepPrompting=True
while keepPrompting:
keepPrompting=False
prompt=eg.buttonbox(title="Select outcome measures",msg="Current outcome measures:\n"+selected,choices=["Add","Done"])
if prompt:
keepPrompting=True
if "Add" in prompt:
name=eg.enterbox(title="Outcome measure name",msg="Enter the name for this outcome measure. Enter NPHYS to use automatically collected neurophsyiological measurements")
if name:
details=eg.buttonbox(title="Logging options",msg="How do you want to collect data on this measure?",choices=['Before stimulation only','After stimulation only','Both before and after stimulation'])
name=name.replace("/","")
selected=selected+name+ " "+details.lower()+"\n"
if 'Before stimulation only' in details:
name=name+"/1"
elif 'After stimulation only' in details:
name=name+"/2"
else:
name=name+"/3"
outcomes.append(name)
else:
keepPrompting=False
pwrite=eg.filesavebox(title="Where do you want to save this protocol?",msg="Where do you want to save this protocol?")
if pwrite:
outFile=open(pwrite,'w')
outstring=""
outstring=outstring+("phaselength:60\n")
outstring=outstring+("duration:"+powers[len(powers)-3]+"\n")
outstring=outstring+("rampdur:"+powers[len(powers)-4]+"\n")
outstring=outstring+("sham:"+powers[len(powers)-2]+"\n")
outstring=outstring+("frequency:"+powers[len(powers)-1]+"\n")
outstring=outstring+("****\n")
for item in outcomes:
outstring=outstring+(item+"\n")
outstring=outstring+("****\n")
for item in range(0,len(choices)):
outstring=outstring+(choices[item]+":"+powers[item]+"\n")
outFile.write(outstring)
outFile.flush()
outFile.close()