def screenshot(self, *args):
from mss import mss<EOL>if not os.path.exists("<STR_LIT>"):<EOL><INDENT>os.makedirs("<STR_LIT>")<EOL><DEDENT>box = {<EOL>"<STR_LIT>": self.winfo_y(),<EOL>"<STR_LIT:left>": self.winfo_x(),<EOL>"<STR_LIT:width>": self.winfo_width(),<EOL>"<STR_LIT>": self.winfo_height()<EOL>}<EOL>screenshot = mss().grab(box)<EOL>screenshot = Image.frombytes("<STR_LIT>", screenshot.size, screenshot.rgb)<EOL>screenshot.save("<STR_LIT>".format(ttk.Style(self).theme_use()))<EOL>
Take a screenshot, crop and save