def _get_dialog_template(self):
        """Put together a sensible default layout for this dialog, taking
        into account the default structure and the (variable) number of fields.

        NB Although sensible default positions are chosen here, the horizontal
        layout will be overridden by the :meth:`_resize` functionality below.
        """
        dlg_class_name = _register_wndclass()
        style = reduce(operator.or_, (
            win32con.WS_THICKFRAME,
            win32con.WS_POPUP,
            win32con.WS_VISIBLE,
            win32con.WS_CAPTION,
            win32con.WS_SYSMENU,
            win32con.DS_SETFONT,
            win32con.WS_MINIMIZEBOX
        ))
        cs = win32con.WS_CHILD | win32con.WS_VISIBLE

        n_fields = len(self.fields) + (1 if self.progress_callback else 0)
        dlg = []

        control_t = self.GUTTER_H
        for i, (field, default_value, callback) in enumerate(self.fields):
            label_l = self.GUTTER_W
            label_t = control_t
            field_l = label_l + self.LABEL_W + self.GUTTER_W
            field_t = label_t
            display_h = field_h = self.CONTROL_H

            if field is None:
                field_type, sub_type = "EDIT", "READONLY"
            elif isinstance(default_value, bool):
                field_type, sub_type = "BUTTON", "CHECKBOX"
            elif isinstance(default_value, tuple):
                field_type, sub_type = "BUTTON", "RADIOBUTTON"
            elif isinstance(default_value, list):
                field_type, sub_type = "COMBOBOX", None
            elif field.upper() == "PASSWORD":
                field_type, sub_type = "EDIT", "PASSWORD"
            else:
                field_type, sub_type = "EDIT", None

            dlg.append(["STATIC", field, self.IDC_LABEL_BASE + i, (label_l, label_t, self.LABEL_W, self.CONTROL_H), cs | win32con.SS_LEFT])
            if field_type != "STATIC":
                field_styles = win32con.WS_TABSTOP
            else:
                field_styles = 0
            if (field_type, sub_type) == ("BUTTON", "CHECKBOX"):
                field_styles |= win32con.BS_AUTOCHECKBOX
                field_w = self.CONTROL_H
            elif (field_type, sub_type) == ("BUTTON", "RADIOBUTTON"):
                field_styles |= win32con.BS_AUTORADIOBUTTON
                field_w = self.CONTROL_H
            elif field_type == "COMBOBOX":
                if callback is not None:
                    raise x_dialogs("Cannot combine a list with a callback")
                field_styles |= win32con.CBS_DROPDOWNLIST | win32con.WS_VSCROLL
                field_w = self.FIELD_W
                field_h = 8 * self.CONTROL_H
                display_h = self.CONTROL_H
            elif field_type == "EDIT":
                field_styles |= win32con.WS_BORDER | win32con.ES_AUTOHSCROLL | win32con.ES_AUTOVSCROLL
                field_w = self.FIELD_W - ((self.CALLBACK_W) if callback else 0)
                if "\r\n" in unicode(default_value):
                    field_styles |= win32con.ES_MULTILINE
                    display_h = field_h = self.CONTROL_H * min(default_value.count("\r\n"), 10)
                if sub_type == "READONLY":
                    field_styles |= win32con.ES_READONLY
                if sub_type == "PASSWORD":
                    field_styles |= win32con.ES_PASSWORD
            else:
                raise x_dialogs("Problemo", "_get_dialog_template", 0)

            dlg.append([field_type, None, self.IDC_FIELD_BASE + i, (field_l, field_t, field_w, field_h), cs | field_styles])
            if callback:
                dlg.append(["BUTTON", "...", self.IDC_CALLBACK_BASE + i, (field_l + field_w + self.GUTTER_W, field_t, self.CALLBACK_W, self.CONTROL_H), cs | win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON])

            control_t += display_h + self.GUTTER_H

        i += 1
        if self.progress_callback:
            self._progress_id = self.IDC_FIELD_BASE + i
            field_t = control_t
            field_w = (2 * self.GUTTER_W) - self.W
            field_l = self.GUTTER_W
            field_h = self.CONTROL_H
            field_styles = win32con.SS_LEFT
            dlg.append(["STATIC", None, self.IDC_FIELD_BASE + i, (field_l, field_t, field_w, field_h), cs | field_styles])
            control_t += field_h + self.GUTTER_H

        cs = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON
        button_t = control_t
        for i, (caption, id) in enumerate(reversed(self.BUTTONS)):
            field_h = self.CONTROL_H
            dlg.append (["BUTTON", caption, id, (self.W - ((i + 1) * (self.GUTTER_W + self.BUTTON_W)), button_t, self.BUTTON_W, field_h), cs])
        control_t += field_h + self.GUTTER_H

        dlg.insert(0, [self.title, (0, 0, self.W, control_t), style, None, (9, "Lucida Sans Unicode"), None, dlg_class_name])
        return dlg
dataset/ETHPy150Open tjguk/winsys/winsys/dialogs.py/BaseDialog._get_dialog_template/swapped operands of `-`