(self, slack_ratio)
return mult[0]*logical[0], mult[1]*logical[1]
Determine the optimal size for a natively scaled window.
Determine the optimal size for a natively scaled window.
Determine the optimal size for a natively scaled window .
def _find_native_window_size(self, slack_ratio):
        """Determine the optimal size for a natively scaled window."""
        # logical-pixel window size
        logical = self.window_size_logical
        # shrink the window in the most constraining dimension
        mcd = _most_constraining(self._screen_size, self._aspect)
        lcd = 1 - mcd
        # find the integer multiplier for the most constraining dimension by rounding down
        mult = [1, 1]
        mult[mcd] = max(1, int(slack_ratio * self._screen_size[mcd] / float(logical[mcd])))
        # find the integer multiplier for the other dimension
        # such that we get closest to the target aspect ratio
        target_aspect_ratio = self._aspect[lcd] / float(self._aspect[mcd])
        target_lcd = mult[mcd] * logical[mcd] * target_aspect_ratio / logical[lcd]
        mult[lcd] = max(1, int(target_lcd))
        if mult[lcd] + 1 - target_lcd < target_lcd - mult[lcd]:
            mult[lcd] += 1
        # physical-pixel window size
        return mult[0]*logical[0], mult[1]*logical[1]
def _find_native_window_size ( self , slack_ratio ) : # logical-pixel window size logical = self . window_size_logical # shrink the window in the most constraining dimension mcd = _most_constraining ( self . _screen_size , self . _aspect ) lcd = 1 - mcd # find the integer multiplier for the most constraining dimension by rounding down mult = [ 1 , 1 ] mult [ mcd ] = max ( 1 , int ( slack_ratio * self . _screen_size [ mcd ] / float ( logical [ mcd ] ) ) ) # find the integer multiplier for the other dimension # such that we get closest to the target aspect ratio target_aspect_ratio = self . _aspect [ lcd ] / float ( self . _aspect [ mcd ] ) target_lcd = mult [ mcd ] * logical [ mcd ] * target_aspect_ratio / logical [ lcd ] mult [ lcd ] = max ( 1 , int ( target_lcd ) ) if mult [ lcd ] + 1 - target_lcd < target_lcd - mult [ lcd ] : mult [ lcd ] += 1 # physical-pixel window size return mult [ 0 ] * logical [ 0 ] , mult [ 1 ] * logical [ 1 ]