當前位置: 首頁>>代碼示例>>Python>>正文


Python easygui.enterbox方法代碼示例

本文整理匯總了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() 
開發者ID:ohsnapitsnathan,項目名稱:brainkit,代碼行數:63,代碼來源:brainkit.py


注:本文中的easygui.enterbox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。