def _resize(self, dialog_w, dialog_h, repaint=1):
        """Attempt to resize the controls on the dialog, spreading
        then horizontally to cover the full extent of the dialog
        box, with left-aligned labels and right-aligned buttons.
        """
        def coords(hwnd, id):
            ctrl = wrapped(win32gui.GetDlgItem, hwnd, id)
            l, t, r, b = wrapped(win32gui.GetWindowRect, ctrl)
            l, t = wrapped(win32gui.ScreenToClient, hwnd, (l, t))
            r, b = wrapped(win32gui.ScreenToClient, hwnd, (r, b))
            return ctrl, l, t, r, b

        hDC = wrapped(win32gui.GetDC, self.hwnd)
        try:
            label_w, label_h = max(wrapped(win32gui.GetTextExtentPoint32, hDC, label or "") for label, _, _ in self.fields)
        finally:
            wrapped(win32gui.ReleaseDC, self.hwnd, hDC)

        for i, (field, default, callback) in enumerate(self.fields):
            if field is not None:
                label, l, t, r, b = coords(self.hwnd, self.IDC_LABEL_BASE + i)
                wrapped(win32gui.MoveWindow, label, self.GUTTER_W, t, label_w, b - t, repaint)
                label_r = self.GUTTER_W + label_w

                if callback:
                    callback_button, l, t, r, b = coords(self.hwnd, self.IDC_CALLBACK_BASE + i)
                    callback_w = l - r
                    callback_l = dialog_w - self.GUTTER_W - callback_w
                    MoveWindow(callback_button, callback_l, t, r - l, b - t, repaint)
                else:
                    callback_w = 0
            else:
                label_r = callback_w = 0

            field, l, t, r, b = coords(self.hwnd, self.IDC_FIELD_BASE + i)
            field_l = label_r + self.GUTTER_W
            field_w = dialog_w - self.GUTTER_W - field_l - (callback_w + self.GUTTER_W if callback_w else 0)
            MoveWindow(field, field_l, t, field_w, b - t, repaint)

        if self._progress_id:
            field, l, t, r, b = coords(self.hwnd, self._progress_id)
            field_w = dialog_w - 2 * self.GUTTER_W
            MoveWindow(field, l, t, field_w, b - t, repaint)

        for i, (caption, id) in enumerate(reversed(self.BUTTONS)):
            button, l, t, r, b = coords(self.hwnd, id)
            MoveWindow(button, dialog_w - ((i + 1) * (self.GUTTER_W + (r - l))), t, r - l, b - t, repaint)
dataset/ETHPy150Open tjguk/winsys/winsys/dialogs.py/Dialog._resize/swapped operands of `-`