Exemplo n.º 1
0
    def _select_region_with_gui(self, request: NormcapData) -> NormcapData:
        """Show window(s) with screenshots and select region.

        Arguments:
            request {NormcapData} -- NormCap's session data

        Returns:
            dict -- Selected region {"bottom": <int>,
                                     "top": <int>,
                                     "left": <int>,
                                     "right": <int>,
                                     "monitor": <int>,
                                     "mode": <int>}
        """
        # Create dummy window plus one for every monitor
        root = _RootWindow(request.cli_args, request.platform)
        for shot in request.shots:
            _CropWindow(root, shot)
        root.mainloop()

        # Store result in request class
        result = root.props.crop_result
        if result:
            request.bottom = result["lower"]
            request.top = result["upper"]
            request.left = result["left"]
            request.right = result["right"]
            request.monitor = result["monitor"]
            request.mode = result["mode"]
        else:
            self._logger.info("Exiting. No selection done.")
            sys.exit(0)

        return request
Exemplo n.º 2
0
    def _select_region(self, request: NormcapData) -> NormcapData:
        """Show window(s) with screenshots and select region.

        Arguments:
            request {NormcapData} -- NormCap's session data

        Returns:
            dict -- Selected region {"bottom": <int>,
                                     "top": <int>,
                                     "left": <int>,
                                     "right": <int>,
                                     "monitor": <int>,
                                     "mode": <int>}
        """
        # Create dummy window plus one for every monitor
        # root = _RootWindow(request.cli_args, request.platform)
        # for shot in request.shots:
        # _CropWindow(root, shot)
        # root.mainloop()

        # Store result in request class
        # result = root.props.crop_result

        request.bottom = self.lower
        request.top = self.upper
        request.left = self.left
        request.right = self.right
        request.monitor = 0
        request.mode = 'parse'

        return request
Exemplo n.º 3
0
def data_test_image(test_params):
    """Create NormcapData instance for testing."""
    data = NormcapData()
    data.test_mode = True
    data.cli_args = test_params["cli_args"]
    data.top = test_params["position"]["top"]
    data.bottom = test_params["position"]["bottom"]
    data.left = test_params["position"]["left"]
    data.right = test_params["position"]["right"]
    data.mode = test_params["cli_args"]["mode"]

    # Prep images
    test_img_folder = os.path.dirname(os.path.abspath(__file__)) + "/images/"
    img = Image.open(test_img_folder + test_params["filename"])
    data.shots = [{"monitor": 0, "image": img}]

    # Set tempfolder for storing
    data.cli_args["path"] = tempfile.gettempdir()

    return data
Exemplo n.º 4
0
    def _select_region_with_gui(self, request: NormcapData) -> NormcapData:
        """Show window(s) with screenshots and select region.

        Arguments:
            request {NormcapData} -- NormCap's session data

        Returns:
            dict -- Selected region {"bottom": <int>,
                                     "top": <int>,
                                     "left": <int>,
                                     "right": <int>,
                                     "monitor": <int>,
                                     "mode": <int>}
        """
        # Create window for every monitor
        root = tkinter.Tk()
        for idx, shot in enumerate(request.shots):
            if idx == 0:
                _CropWindow(root, root, shot, request.cli_args)
            else:
                top = tkinter.Toplevel()
                _CropWindow(root, top, shot, request.cli_args)
        root.mainloop()

        # Store result in request class
        result = root.result
        if result:
            request.bottom = result["lower"]
            request.top = result["upper"]
            request.left = result["left"]
            request.right = result["right"]
            request.monitor = result["monitor"]
            request.mode = result["mode"]
        else:
            self._logger.info("Exiting. No selection done.")
            sys.exit(0)

        return request