def remove_item(self):
        self.action = "remove"

        selected_index = self.listWidgetAlyObj.currentRow()
        #selected_text = self.listWidgetAlyObj.currentItem().text()
        selected_item_data = self.listWidgetAlyObj.currentItem().data(
            Qt.UserRole).toString()
        self.xml_name = str(selected_item_data)
        #self.xml_name = selected_text + ".xml"
        if self.xml_name.endswith("_RectFinder.xml"):
            self.alyvix_finder_controller = AlyvixRectFinderView(self)
        elif self.xml_name.endswith("_ImageFinder.xml"):
            self.alyvix_finder_controller = AlyvixImageFinderView(self)
        elif self.xml_name.endswith("_TextFinder.xml"):
            self.alyvix_finder_controller = AlyvixTextFinderView(self)
        elif self.xml_name.endswith("_ObjectFinder.xml"):
            self.alyvix_finder_controller = AlyvixObjectFinderView(self)
        elif self.xml_name.endswith("_CustomCode.xml"):
            self.alyvix_finder_controller = AlyvixCustomCodeView(self)

        self.alyvix_finder_controller.remove_code_from_py_file()

        if self.xml_name.endswith("_ObjectFinder.xml"):
            self.alyvix_finder_controller.delete_lock_list()
            os.remove(self.path + os.sep + str(self.xml_name).replace(
                "_ObjectFinder.xml", "_old_code.txt"))
        elif self.xml_name.endswith("_CustomCode.xml"):
            os.remove(
                self.path + os.sep +
                str(self.xml_name).replace("_CustomCode.xml", "_old_code.txt"))
        else:
            os.remove(self.path + os.sep +
                      str(self.xml_name).replace("xml", "png"))
        """
        if not self.xml_name.endswith("_ObjectFinder.xml"):
            os.remove(self.path + os.sep + str(self.xml_name).replace("xml","png"))
        else:
            self.alyvix_finder_controller.delete_lock_list()
            os.remove(self.path + os.sep + str(self.xml_name).replace("_ObjectFinder.xml","_old_code.txt"))
        """

        os.remove(self.path + os.sep + str(self.xml_name))

        template_path = self.path + os.sep + str(self.xml_name).replace(
            "_ImageFinder.xml", "")

        if os.path.exists(template_path):
            shutil.rmtree(template_path)
        #self.update_list()

        item = self.listWidgetAlyObj.takeItem(selected_index)
        self.listWidgetAlyObj.removeItemWidget(item)

        self.update_list()
 def open_textfinder_view(self):
     self.xml_name = None
     self.restore_view()
     screen_manager = ScreenManager()
     self.hide()
     self.sleep_before_action()
     time.sleep(0.600)
     img_color = screen_manager.grab_desktop(screen_manager.get_color_mat)
     img_color = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB)
     image = QImage(img_color, img_color.shape[1], img_color.shape[0],
                    img_color.strides[0], QImage.Format_RGB888)
     self.alyvix_text_finder_controller = AlyvixTextFinderView(self)
     self.alyvix_text_finder_controller.set_bg_pixmap(image)
     self.alyvix_text_finder_controller.showFullScreen()
    def edit_item(self):
        self.action = "edit"

        if self.listWidgetAlyObj.currentRow() < 0:
            return

        #print self.listWidgetAlyObj.currentRow()

        selected_item_data = self.listWidgetAlyObj.currentItem().data(
            Qt.UserRole).toString()
        self.xml_name = str(selected_item_data)
        #print selected_item_data

        if self.xml_name.endswith("_ObjectFinder.xml"):
            self.hide()
            time.sleep(0.600)
            self.alyvix_finder_controller = AlyvixObjectFinderView(self)
            self.alyvix_finder_controller.show()
            return

        if self.xml_name.endswith("_CustomCode.xml"):
            self.hide()
            time.sleep(0.600)
            self.alyvix_finder_controller = AlyvixCustomCodeView(self)
            self.alyvix_finder_controller.show()
            return

        screen_manager = ScreenManager()
        self.hide()
        time.sleep(0.600)
        img_color = cv2.imread(str(self.xml_name).replace(
            "xml",
            "png"))  #screen_manager.grab_desktop(screen_manager.get_color_mat)
        #print "imgggg", self.path + os.sep + self.xml_name
        image = QImage(self.path + os.sep +
                       self.xml_name.replace("xml", "png"))
        #print self.path, self.robot_file_name, self.xml_name

        if self.xml_name.endswith("_RectFinder.xml"):
            self.alyvix_finder_controller = AlyvixRectFinderView(self)
        elif self.xml_name.endswith("_ImageFinder.xml"):
            self.alyvix_finder_controller = AlyvixImageFinderView(self)
        elif self.xml_name.endswith("_TextFinder.xml"):
            self.alyvix_finder_controller = AlyvixTextFinderView(self)

        #self.alyvix_rect_finder_controller.set_path(self.full_file_name)
        self.alyvix_finder_controller.set_bg_pixmap(image)
        self.alyvix_finder_controller.showFullScreen()