def scale_context_and_center(self, cr):
bot_width, bot_height = self.bot_size<EOL>if self.width != bot_width or self.height != bot_height:<EOL><INDENT>if self.width < self.height:<EOL><INDENT>scale_x = float(self.width) / float(bot_width)<EOL>scale_y = scale_x<EOL>cr.translate(<NUM_LIT:0>, (self.height - (bot_height * scale_y)) / <NUM_LIT>)<EOL><DEDENT>elif self.width > self.height:<EOL><INDENT>scale_y = float(self.height) / float(bot_height)<EOL>scale_x = scale_y<EOL>cr.translate((self.width - (bot_width * scale_x)) / <NUM_LIT>, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>scale_x = <NUM_LIT:1.0><EOL>scale_y = <NUM_LIT:1.0><EOL><DEDENT>cr.scale(scale_x, scale_y)<EOL>self.input_device.scale_x = scale_y<EOL>self.input_device.scale_y = scale_y<EOL><DEDENT>
Scale context based on difference between bot size and widget