Esempio n. 1
0
    def on_clicked_create_button(self):
        save_location_path = self.ui.save_location_line.text()
        project_name = os.path.basename(self.ui.project_name_line.text())

        if not self.is_valid_character(project_name, save_location_path):
            self.msgBox = QMessageBox()
            self.msgBox.setText(
                'プロジェクト名またはディレクトリ名に、使用できない文字が含まれています。\n'
                '全角文字や特殊記号が使われている場合は、名前を変えるか別のディレクトリに変更してください。')
            self.msgBox.exec()
            return

        dir_paths = [
            os.path.join(save_location_path, 'dataset/test/OK'),
            os.path.join(save_location_path, 'dataset/test/NG'),
            os.path.join(save_location_path, 'dataset/train/OK'),
            os.path.join(save_location_path, 'dataset/truncated'),
            os.path.join(save_location_path, 'inspection_results'),
            os.path.join(save_location_path, 'inspection_results/images'),
            os.path.join(save_location_path, 'tmp'),
            os.path.join(save_location_path, 'models')
        ]
        for dir_path in dir_paths:
            os.makedirs(dir_path, exist_ok=True)

        # プロジェクトファイル作成部分
        project_path = save_location_path
        Project.generate_project_file(project_path, project_name)
        window_title = project_name + ' - ' + AppInfo().app_name(
        ) + ' Version ' + AppInfo().version()
        self.main_window = MainWindow()
        self.main_window.setWindowTitle(window_title)
        self.main_window.show()
        self.close_old_project.emit()
        self.close()
        self.main_window.back_to_new_project.connect(
            self.open_new_project_widget)
        self.main_window.back_to_startup.connect(
            self.on_back_to_startup_signal)