def run(self): # 2. Implement run() """ start QtApplication """ startup_window = StartupWidget() startup_window.setWindowTitle(AppInfo().app_name() + ' Version ' + AppInfo().version()) if len(sys.argv) > 1 and type(sys.argv[1]) is str: project_file_path = sys.argv[1] _, ext = os.path.splitext(project_file_path) if ext == '.sdt': startup_window.move_to_main_window(project_file_path) else: startup_window.show() # スタイルをwindows共用に(for develop) # self.app.setStyle(QStyleFactory.create('Fusion')) # Enable High DPI display with PyQt5 os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" self.app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) # Disable [?] button on dialogs self.app.setAttribute(QtCore.Qt.AA_DisableWindowContextHelpButton, True) return self.app.exec_()
def on_triggered_action_open(self): save_location_path = QFileDialog.getOpenFileName(self, 'プロジェクトを開く', os.path.expanduser('~'), AppInfo().app_name() + ' プロジェクト(*.sdt);;すべて(*.*)')[0] if not save_location_path: return Project.load_settings_file(save_location_path) project_name = os.path.basename(os.path.splitext(save_location_path)[0]) window_title = project_name + ' - ' + AppInfo().app_name() + ' Version ' + AppInfo().version() self.setWindowTitle(window_title) self.show() self.setup_tool_bar()
def move_to_main_window(self, project_file_path): Project.load_settings_file(project_file_path) project_name = os.path.basename(os.path.splitext(project_file_path)[0]) 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() self.main_window.back_to_new_project.connect( self.new_project_window.open_new_project_widget) self.main_window.back_to_startup.connect(self.open_start_up_widget)
def on_clicked_open_project_button(self): project_file_path = QFileDialog.getOpenFileName( self, 'プロジェクトを開く', os.path.expanduser('~'), AppInfo().app_name() + ' プロジェクト(*.sdt);;すべてのファイル(*.*)')[0] if not project_file_path: return self.move_to_main_window(project_file_path)
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)
def _on_sentry_init(self): scope = self.sentry_exception_handler.scope from fbs_runtime import platform scope.set_extra('os', platform.name()) scope.set_extra('build', AppInfo().version())
def open_start_up_widget(self): self.setWindowTitle(AppInfo().app_name() + ' Version ' + AppInfo().version()) if self.main_window: self.main_window = MainWindow() self.show()
def on_triggered_action_version(self): self.msgBox = QMessageBox() self.msgBox.setText(AppInfo().app_name() + '\nVersion ' + AppInfo().version() + '\n(c) ' + AppInfo().author()) self.msgBox.setWindowTitle(AppInfo().app_name() + ' Version ' + AppInfo().version()) self.msgBox.exec()