Dlg =========================== .. code-block:: python class psychopy.gui.Dlg(title=u'PsychoPy Dialog', pos=None, size=None, style=None, labelButtonOK=u'OK', labelButtonCancel=u'Cancel', screen=-1) シンプルなダイアログボックスのクラスである。テキストや入力欄などを順番に追加して、入力された値を取得することが出来る。 DlgFromDictも参照のこと。以下に使用例を示す。 .. code-block:: python from psychopy import gui myDlg = gui.Dlg(title="JWP's experiment") myDlg.addText('Subject info') myDlg.addField('Name:') myDlg.addField('Age:', 21) myDlg.addText('Experiment Info') myDlg.addField('Grating Ori:',45) myDlg.addField('Group:', choices=["Test", "Control"]) ok_data = myDlg.show() # ダイアログを表示してOKかキャンセルを待つ if myDlg.OK: # OKだったか判定する。if ok_data is not None でもよい print(ok_data) else: print('user cancelled') .. A simple dialogue box. You can add text or input boxes (sequentially) and then retrieve the values. .. see also the function dlgFromDict for an even simpler version .. Example .. from psychopy import gui .. myDlg = gui.Dlg(title="JWP's experiment") .. myDlg.addText('Subject info') .. myDlg.addField('Name:') .. myDlg.addField('Age:', 21) .. myDlg.addText('Experiment Info') .. myDlg.addField('Grating Ori:',45) .. myDlg.addField('Group:', choices=["Test", "Control"]) .. ok_data = myDlg.show() # show dialog and wait for OK or Cancel .. if myDlg.OK: # or if ok_data is not None .. print(ok_data) .. else: .. print('user cancelled') addField(label='', initial='', color='', choices=None, tip='', enabled=True) --------------------------------------------------------------------------------- ダイアログに(ラベル付きの)入力欄を追加する。ラベルの文字色やツールチップを指定できる。 'initial'が真偽値であればチェックボックスが作成される。'choices'がリストまたはタプルである場合、ドロップダウンリストが作成される。それ以外の場合は、テキストを入力できるボックスが作成される。 戻り値は追加したフィールドのハンドラである。 .. Adds a (labelled) input field to the dialogue box, optional text color and tooltip. .. If 'initial' is a bool, a checkbox will be created. If 'choices' is a list or tuple, a dropdown selector is created. Otherwise, a text line entry box is created. .. Returns a handle to the field (but not to the label). addFixedField(label='', initial='', color='', choices=None, tip='') ------------------------------------------------------------------------ ダイアログに編集不可の要素を追加する。実験のバージョン名の表示などに用いると良い。 .. Adds a field to the dialog box (like addField) but the field cannot be edited. e.g. Display experiment version. show() ------------------- ダイアログを表示してOKが押されるかキャンセルされるまで待つ。 ユーザーがOKを押した場合はダイアログ上の各項目の値が順番に並べられたリストが返される。それ以外の場合はNoneが返される。 .. Presents the dialog and waits for the user to press OK or CANCEL. .. If user presses OK button, function returns a list containing the updated values coming from each of the input fields created. Otherwise, None is returned. .. Returns: self.data