def __init__(self, parent=None): super(TopBar, self).__init__(parent) self.setLayout(QHBoxLayout()) self.layout().setAlignment(QtCore.Qt.AlignRight) self.layout().setContentsMargins(0, 0, 0, 0) self.setFrameStyle(QFrame.Box) self.setObjectName("top_bar") self.setFixedHeight(40) # self.setCursor(QtCore.Qt.SizeAllCursor) preferred_size = QSize(30, 30) self.btn_minimize = QPushButton(icon=GUIUtilities.get_icon("minimize.png")) self.btn_maximize = QPushButton(icon=GUIUtilities.get_icon("maximize.png")) self.btn_close = QPushButton(icon=GUIUtilities.get_icon("close.png")) self.btn_minimize.clicked.connect(lambda evt: self.window().showMinimized()) self.btn_maximize.clicked.connect(self.btn_maximize_click) self.btn_close.clicked.connect(lambda evt: self.window().close()) self.layout().addWidget(self.btn_minimize) self.layout().addWidget(self.btn_maximize) self.layout().addWidget(self.btn_close) self.dragPos = None for i in reversed(range(self.layout().count())): widget = self.layout().itemAt(i).widget() if isinstance(widget, QPushButton): widget.setFixedSize(preferred_size) widget.setCursor(QtCore.Qt.PointingHandCursor)
def contextMenuEvent(self, evt: QContextMenuEvent) -> None: index: QModelIndex = self.indexAt(evt.pos()) actions = [] if index.isValid(): node: CustomNode = index.internalPointer() index: QModelIndex = self.indexAt(evt.pos()) menu = QMenu() menu.triggered.connect(self.context_menu_actions_handler) if node.level == 1: actions = [ QAction(gui.get_icon('new_folder.png'), self.CTX_MENU_ADD_REPOSITORY_ACTION) ] elif node.level == 2: actions = [ QAction(gui.get_icon('delete.png'), self.CTX_MENU_DELETE_REPO_ACTION), QAction(gui.get_icon('refresh.png'), self.CTX_MENU_UPDATE_REPO_ACTION) ] elif node.level == 3: actions = [ QAction(gui.get_icon('robotic-hand.png'), self.CTX_MENU_AUTO_LABEL_ACTION) ] if actions: for act in actions: act.setData(index) menu.addAction(act) menu.exec_(self.mapToGlobal(evt.pos()))
def setup_toolbar(self): uncheck_all_icon = GUIUtilities.get_icon("uncheck_all.png") self.btn_uncheck_all = ImageButton(icon=uncheck_all_icon, size=QSize(20, 20)) check_all_icon = GUIUtilities.get_icon("check_all.png") self.btn_check_all = ImageButton(icon=check_all_icon, size=QSize(20, 20)) self.btn_check_all.setFixedWidth(40) self.btn_uncheck_all.setFixedWidth(40) self.btn_check_all.clicked.connect(self.btn_check_all_on_click_slot) self.btn_uncheck_all.clicked.connect( self.btn_uncheck_all_on_click_slot)
def contextMenuEvent(self, evt: QContextMenuEvent) -> None: menu = QMenu() menu.triggered.connect(self.context_menu_actions_handler) index: QModelIndex = self.indexAt(evt.pos()) if index.isValid(): icon: QIcon = GUIUtilities.get_icon('delete_label.png') action = menu.addAction(icon, self.CTX_MENU_DELETE_LABEL) action.setData(index) else: icon: QIcon = GUIUtilities.get_icon('new_label.png') menu.addAction(icon, self.CTX_MENU_ADD_LABEL) menu.exec_(self.mapToGlobal(evt.pos()))
def __init__(self, vo: DatasetVO = None, parent=None): super(DatasetForm, self).__init__(parent) self.setupUi(self) self.setWindowTitle("Create new dataset".title()) self.setWindowIcon(GUIUtilities.get_icon("polygon.png")) self._value = vo self.initialize_form()
def setup_paginator(self): self.grid_actions_layout.addWidget(self.btn_check_all) self.grid_actions_layout.addWidget(self.btn_uncheck_all) self.btn_next_page.clicked.connect(self.btn_next_page_on_click) self.btn_prev_page.clicked.connect(self.btn_prev_page_on_click) self.btn_last_page.clicked.connect(self.btn_last_page_on_click) self.btn_first_page.clicked.connect(self.btn_first_page_on_click) self.btn_first_page.setIcon(GUIUtilities.get_icon("first.png")) self.btn_prev_page.setIcon(GUIUtilities.get_icon("left.png")) self.btn_next_page.setIcon(GUIUtilities.get_icon("right.png")) self.btn_last_page.setIcon(GUIUtilities.get_icon("last.png")) self.btn_first_page.setStyleSheet('QPushButton{border: 0px solid;}') self.btn_prev_page.setStyleSheet('QPushButton{border: 0px solid;}') self.btn_last_page.setStyleSheet('QPushButton{border: 0px solid;}') self.btn_next_page.setStyleSheet('QPushButton{border: 0px solid;}') self.grid_actions_layout.setAlignment(QtCore.Qt.AlignCenter)
def build_new_button(self): new_item_widget: GridCard = GridCard(with_actions=False, with_title=False) btn_new_item = ImageButton(GUIUtilities.get_icon("new_folder.png")) btn_new_item.clicked.connect(lambda: self.new_item_action.emit()) new_item_widget.body = btn_new_item return new_item_widget
def __init__(self, parent=None): super(NewLabelForm, self).__init__(parent) self.setupUi(self) self.setWindowTitle("Create New Label".title()) self.setWindowIcon(GUIUtilities.get_icon("polygon.png")) self.btn_pick_color.clicked.connect(self.btn_pick_color_click_slot) self._result = None
def __init__(self, ds, parent=None): super(MediaTabWidget, self).__init__(parent) self.media_grid = Gallery() self.media_grid.filesDropped.connect(self.gallery_files_dropped_slot) self.media_grid.doubleClicked.connect(self.gallery_card_double_click_slot) delete_action = GalleryAction(gui.get_icon("delete.png"), name="delete", tooltip="delete image") edit_action = GalleryAction(gui.get_icon("annotations.png"), name="edit", tooltip="edit annotations") # view_action=GalleryAction(gui.get_icon("search.png"),name="view") self.media_grid.actions = [delete_action, edit_action] self.media_grid.cardActionClicked.connect(self.card_action_clicked_slot) self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self.media_grid) self._thread_pool = QThreadPool() self._loading_dialog = QLoadingDialog() self._ds_dao = DatasetDao() self._ds: DatasetVO = ds self.load()
def __init__(self, parent=None): super(ModelWizard, self).__init__(parent) self.setWindowIcon(GUIUtilities.get_icon("pytorch.png")) self.setWindowTitle("New Model") self.resize(800, 600) self.setWizardStyle(QWizard.ClassicStyle) self._model_params_page = BaseModelSelectionPage() self.addPage(self._model_params_page) self.button(QWizard.FinishButton).clicked.connect( self.finish_button_click)
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.tab_widget_manager.tabCloseRequested.connect( lambda index: self.tab_widget_manager.removeTab(index)) self.lateral_menu = LateralMenu() self.setWindowTitle("CV-Studio") self.resize(1600, 900) self.lateral_menu.add_item(GUIUtilities.get_icon("data.png"), "Datasets", name="datasets") self.lateral_menu.add_item(GUIUtilities.get_icon("logout.png"), "Exit", loc=LateralMenuItemLoc.BOTTOM, name="exit") self.lateral_menu.item_click_signal.connect( self.item_click_signal_slot) self.tab_widget_manager.clear() self.loading_dialog = QLoadingDialog() self.frame_lateral_bar.setLayout(QVBoxLayout()) self.frame_lateral_bar.layout().addWidget(self.lateral_menu)
def add_node(self, vo: HubVO): parent_node = CustomNode( [vo.path, ""], level=2, tag=vo, status=1, success_icon=gui.get_icon("github.png") ) self._root_node.addChild(parent_node) for m in vo.models: child_node = CustomNode( [m.name, ""], level=3, tooltip=m.description, tag=m, status=1, success_icon=gui.get_icon("cube.png") ) parent_node.addChild(child_node) self._update_model()
def __init__(self, parent=None): super(ModelsTreeview, self).__init__(parent) self.setIconSize(QSize(18, 18)) self.setDragDropMode(QAbstractItemView.InternalMove) self.setDragEnabled(True) self.setAcceptDrops(True) self.setCursor(QtCore.Qt.PointingHandCursor) self.setDropIndicatorShown(True) self._thread_pool = QThreadPool() self._loading_dialog = QLoadingDialog() model: CustomModel = CustomModel(["Name", "Uri"]) self._root_node = CustomNode(["Models", ""], level=1, status=1, success_icon=gui.get_icon("database.png")) model.addChild(self._root_node) self.setModel(model)
def __init__(self, parent=None): super(ImageViewerToolBox, self).__init__(parent) self._icon_size = QSize(28, 28) self._toolbox = [ SwitchButton(icon=GUIUtilities.get_icon("polygon.png"), tag="polygon", tooltip="polygon tool"), SwitchButton(icon=GUIUtilities.get_icon("square.png"), tag="box", tooltip="box tool"), SwitchButton(icon=GUIUtilities.get_icon("circle.png"), tag="ellipse", tooltip="ellipse tool"), SwitchButton(icon=GUIUtilities.get_icon("highlighter.png"), tag="free", tooltip="free draw tool"), SwitchButton(icon=GUIUtilities.get_icon("robotic-hand.png"), tag="points", tooltip="extreme points tool"), SwitchButton(icon=GUIUtilities.get_icon("cursor.png"), tag="pointer", tooltip="pointer tool"), ImageButton(icon=GUIUtilities.get_icon("save-icon.png"), size=self._icon_size, tag="save", tooltip="save annotations"), ImageButton(icon=GUIUtilities.get_icon("clean.png"), size=self._icon_size, tag="clean", tooltip="clean annotations")] self._layout = QVBoxLayout(self) for button in self._toolbox: self._layout.addWidget(button) self._layout.addWidget(SeparatorWidget()) button.clicked.connect(self._action_toolbox_clicked_slot)
def main(): try: create_tables() app = QApplication(sys.argv) app_theme = "cvstudio" app.setProperty("theme", app_theme) if app_theme == "light": light_theme(app) elif app_theme == "dark": dark_theme(app) elif app_theme == "gray": gray_theme(app) elif app_theme == "cvstudio": cvstudio_theme(app) mainWindow = MainWindow() mainWindow.setWindowIcon(GUIUtilities.get_icon("polygon.png")) mainWindow.show() sys.exit(app.exec_()) except Exception as ex: print(ex)
def done_work(args): result, error = args if result: images, models, labels = result if models: for model in models: self.treeview_models.add_node(model) if labels: for entry in labels: self.treeview_labels.add_row(entry) selected_image = None icon = GUIUtilities.get_icon("image.png") for img in images: if os.path.isfile(img.file_path): item = CustomListWidgetItem(img.file_path, tag=img) item.setIcon(icon) self.images_list_widget.addItem(item) if img.file_path == self.tag.file_path: selected_image = item self.images_list_widget.setCurrentItem(selected_image) self._loading_dialog.hide()
def build_ds_card(self, ds: DatasetVO): card_widget: GridCard = GridCard(debug=False) card_widget.label = "{}".format(ds.name) card_widget.label2 = "{} files \n {} ".format( ds.count, size(ds.size, system=alternative) if ds.size else "0 MB") btn_delete = ImageButton(GUIUtilities.get_icon("delete.png"), size=QSize(15, 15)) btn_delete.setToolTip("Delete dataset") btn_edit = ImageButton(GUIUtilities.get_icon("edit.png"), size=QSize(15, 15)) btn_edit.setToolTip("Edit dataset") btn_refresh = ImageButton(GUIUtilities.get_icon("refresh.png"), size=QSize(15, 15)) btn_refresh.setToolTip("Refresh dataset") btn_export_annotations = ImageButton( GUIUtilities.get_icon("download.png"), size=QSize(15, 15)) btn_export_annotations.setToolTip("Export annotations") btn_import_annotations = ImageButton( GUIUtilities.get_icon("upload.png"), size=QSize(15, 15)) btn_import_annotations.setToolTip("Import annotations") card_widget.add_buttons([ btn_delete, btn_edit, btn_refresh, btn_export_annotations, btn_import_annotations ]) icon_file = "folder_empty.png" icon = GUIUtilities.get_icon(icon_file) # events btn_delete.clicked.connect( lambda: self.delete_dataset_action_signal.emit(ds)) btn_edit.clicked.connect( lambda: self.edit_dataset_action_signal.emit(ds)) btn_export_annotations.clicked.connect( lambda: self.download_anno_action_signal.emit(ds)) btn_import_annotations.clicked.connect( lambda: self.import_anno_action_signal.emit(ds)) card_widget.body = ImageButton(icon) btn_refresh.clicked.connect( lambda: self.refresh_dataset_action_signal.emit(ds)) card_widget.body.doubleClicked.connect( lambda evt: self.open_dataset_action_signal.emit(ds)) return card_widget
def __init__(self, parent=None): super(NewRepoForm, self).__init__(parent) self.setupUi(self) self.setWindowTitle("New Repository".title()) self.setWindowIcon(GUIUtilities.get_icon("polygon.png")) self._result = None