def __init__(self, parent, view, data): QTreeView.__init__(self, parent) FilterTarget.__init__(self) self.data = data self.parent = parent self.view = view # Allow view-specific shortcuts when imports are focused self.actionHandler = UIActionHandler() self.actionHandler.setupActionHandler(self) self.actionHandler.setActionContext(lambda: self.view.actionContext()) self.model = GenericImportsModel(self.data) self.setModel(self.model) self.setRootIsDecorated(False) self.setUniformRowHeights(True) self.setSortingEnabled(True) self.sortByColumn(0, Qt.AscendingOrder) if self.model.ordinal_col is not None: self.setColumnWidth(self.model.ordinal_col, 55) self.setFont(binaryninjaui.getMonospaceFont(self)) self.selectionModel().currentChanged.connect(self.importSelected) self.doubleClicked.connect(self.importDoubleClicked)
def __init__(self, parent=None): QTreeView.__init__(self, parent=parent) self.setStyleSheet(''' QTreeView { font-size: 14pt; background-color: #2e2e2e; color: #cccccc; min-width: 125px; max-width: 250px } QTreeView::item { padding: 5px; } ''') self.header().hide() self.clicked.connect(self.sendListId) self.setDragDropMode(QAbstractItemView.DragDrop) self.setWordWrap(True) self.inputDialog = RenameDeleteDialog() self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.setupContextMenus() return
def __init__(self): QTreeView.__init__(self) # model = QFileSystemModel() # model.setRootPath('C:\\') model = QtGui.QStandardItemModel() model.setHorizontalHeaderLabels(['col1', 'col2', 'col3']) self.setModel(model) self.doubleClicked.connect(self.double_click) # populate data for i in range(3): parent1 = QtGui.QStandardItem( 'Family {}. Some long status text for sp'.format(i)) for j in range(3): child1 = QtGui.QStandardItem('Child {}'.format(i * 3 + j)) child2 = QtGui.QStandardItem('row: {}, col: {}'.format( i, j + 1)) child3 = QtGui.QStandardItem('row: {}, col: {}'.format( i, j + 2)) parent1.appendRow([child1, child2, child3]) model.appendRow(parent1) # span container columns self.setFirstColumnSpanned(i, self.rootIndex(), True)
def init_ui(self): '''Initializes the UI''' self.setWindowTitle(self.title) self.model = QFileSystemModel() self.model.setRootPath(ROOT_PATH) self.tree = QTreeView() self.tree.setModel(self.model) self.tree.setRootIndex(self.model.index(self.root_path)) self.start_box = QLineEdit() self.stop_box = QLineEdit() self.start_box.setValidator(QIntValidator()) self.stop_box.setValidator(QIntValidator()) self.make_btn = QPushButton("Create Project Folders") self.make_btn.clicked.connect(self.on_btn) layout = QVBoxLayout() layout.addWidget(self.tree) subgrid = QGridLayout() subgrid.addWidget(self.start_box, 0, 1) subgrid.addWidget(self.stop_box, 1, 1) subgrid.addWidget(QLabel('From (inc.): '), 0, 0) subgrid.addWidget(QLabel('To (not inc.): '), 1, 0) layout.addLayout(subgrid) layout.addWidget(self.make_btn) self.setLayout(layout) self.show()
def __init__(self, vfs_view, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) self.vnode_2click_selected = None # Getting the Model self.source_model = VfsDirModel() # Creating a QTableView self.view = QTreeView() self.view.doubleClicked.connect(self.double_clicked) self.view.clicked.connect(self.clicked) self.view.setSelectionBehavior(QAbstractItemView.SelectRows) self.view.setSelectionMode(QAbstractItemView.ExtendedSelection) font = self.view.font() font.setPointSize(8) self.view.setFont(font) self.view.setModel(self.source_model) # # QTableView Headers self.header = self.view.header() self.header.setSectionResizeMode(QHeaderView.ResizeToContents) self.header.setStretchLastSection(True) size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) size.setHorizontalStretch(1) self.view.setSizePolicy(size) self.main_layout = QHBoxLayout() self.main_layout.addWidget(self.view) self.setLayout(self.main_layout) self.source_model.vfs_view_set(vfs_view)
class RightPanel(FuturaFrame): side = "right" def __init__(self, *args): super(RightPanel, self).__init__(*args) self.connect_signals() self.label.setText('Recipe') self.tree_view = QTreeView() self.model = RecipeModel() self.tree_view.setModel(self.model) self.tree_view.setWordWrap(True) self.tree_view.setColumnWidth(0, 50) self.widget_layout.addWidget(self.tree_view) signals.update_recipe.emit() def connect_signals(self): signals.update_recipe.connect(self.update_recipe) def update_recipe(self): self.model.parse_recipe(findMainWindow().loader.recipe) if self.model.rowCount() == 0: self.tree_view.header().hide() else: self.tree_view.header().show()
def __init__(self, *args): super().__init__() self.setFixedSize(930, 631) self.setLocale(QLocale(QLocale.English, QLocale.UnitedStates)) self.setWindowTitle( QCoreApplication.translate("MainWindow", "PyInspect")) self.central_widget = QWidget(self) self.comboBox = QComboBox(self.central_widget) self.comboBox.setGeometry(QRect(10, 10, 451, 22)) self.comboBox.setMouseTracking(False) self.comboBox.setMaxVisibleItems(5) self.comboBox.setObjectName("comboBox") for _backend in backend.registry.backends.keys(): self.comboBox.addItem(_backend) self.tree_view = QTreeView(self.central_widget) self.tree_view.setGeometry(QRect(10, 40, 451, 581)) self.tree_view.setColumnWidth(0, 150) self.comboBox.setCurrentText('uia') self.__show_tree() self.table_view = QTableView(self.central_widget) self.table_view.setGeometry(QRect(470, 40, 451, 581)) self.comboBox.activated[str].connect(self.__show_tree) self.tree_view.clicked.connect(self.__show_property)
def __init__(self, parent=None): super().__init__(parent) self.model = ExportChangesModel() self.error_dialog = None self.setWindowIcon(QIcon("paragon.ico")) self.setWindowTitle("Export") main_layout = QVBoxLayout(self) self.export_button = QPushButton() self.export_button.setText("Export") self.main_view = QTreeView() self.main_view.setModel(self.model) self.main_view.setHeaderHidden(True) self.main_view.setEditTriggers( QtWidgets.QAbstractItemView.NoEditTriggers) self.remember_selections_checkbox = QCheckBox() self.remember_selections_checkbox.setText("Remember selections.") main_layout.addWidget(self.export_button) main_layout.addWidget(self.main_view) main_layout.addWidget(self.remember_selections_checkbox) self.setLayout(main_layout) self.main_view.expanded.connect(self._on_item_expanded) self.export_button.clicked.connect(self._on_export_triggered) self.remember_selections_checkbox.stateChanged.connect( self._on_remember_selections_state_changed) self._set_remember_checkbox_state_from_settings()
def _layout(self): layout = QHBoxLayout(self) self.setLayout(layout) self.tree = QTreeView(self) self.tree.setModel(self.model) self.tree.setUniformRowHeights(True) self.tree.setColumnWidth(0, 200) self.tree.setDragEnabled(True) self.tree.setDragDropMode(QAbstractItemView.InternalMove) self.tree.viewport().setAcceptDrops(True) layout.addWidget(self.tree, 1) buttons = QVBoxLayout() buttons.setAlignment(Qt.AlignTop) add_button = QPushButton(QIcon.fromTheme("list-add"), "", self) add_button.setToolTip("Add application") add_button.clicked.connect(self.on_add) buttons.addWidget(add_button) mkdir_button = QPushButton(QIcon.fromTheme("folder-new"), "", self) mkdir_button.setToolTip("Make directory") mkdir_button.clicked.connect(self.on_mkdir) buttons.addWidget(mkdir_button) delete_button = QPushButton(QIcon.fromTheme("list-remove"), "", self) delete_button.setToolTip("Remove selected item") delete_button.clicked.connect(self.on_delete) buttons.addWidget(delete_button) layout.addLayout(buttons)
def __init__(self, parent=None): super().__init__(parent) self._recursiveActivated = False self._model = FolderListModel(self) self._completer = QCompleter(self._model, self) self._completer.setCompletionColumn(3) self._lineedit = TabCompletionLineEdit(self._completer, self) self._view = QTreeView(self) self._view.setModel(self._model) self._model.folderChanged.connect(self._lineedit.setText) self._model.setFolder(".") self._view.header().setSectionResizeMode(0, QHeaderView.Interactive) self._view.header().setSectionResizeMode(1, QHeaderView.ResizeToContents) self._view.header().setSectionResizeMode(2, QHeaderView.ResizeToContents) self._view.header().resizeSection(0, 500) self._view.header().setSectionHidden(3, True) layout = QVBoxLayout(self) layout.addWidget(self._lineedit) layout.addWidget(self._view) self.setLayout(layout) self._view.activated.connect(self._activated) self.activated.connect(self._lineedit.setText) self._lineedit.returnPressed.connect(self._leActivated, Qt.QueuedConnection) self._lineedit.textEdited.connect(self._leTextEdited)
def __init__(self): super().__init__() self.chapter_data = None self.dispos_model = None self.dispos = None self.terrain = None self.tiles_model = None self.terrain_mode = False self.initialized_selection_signal = False self.selected_faction = None left_panel_container = QWidget() left_panel_layout = QVBoxLayout() self.toggle_editor_type_checkbox = QCheckBox() self.toggle_editor_type_checkbox.setText("Spawns/Terrain") self.toggle_editor_type_checkbox.setChecked(True) self.toggle_editor_type_checkbox.stateChanged.connect( self._on_mode_change_requested) self.toggle_coordinate_type_checkbox = QCheckBox() self.toggle_coordinate_type_checkbox.setText( "Coordinate (1)/Coordinate (2)") self.toggle_coordinate_type_checkbox.setChecked(True) self.toggle_coordinate_type_checkbox.stateChanged.connect( self._on_coordinate_change_requested) self.tree_view = QTreeView() left_panel_layout.addWidget(self.toggle_editor_type_checkbox) left_panel_layout.addWidget(self.toggle_coordinate_type_checkbox) left_panel_layout.addWidget(self.tree_view) left_panel_container.setLayout(left_panel_layout) self.grid = FE14MapGrid() self.dispos_scroll, self.dispos_form = PropertyForm.create_with_scroll( dispo.SPAWN_TEMPLATE) self.terrain_form, self.terrain_persistent_editors, self.tile_form = _create_terrain_form( ) self.organizer = QSplitter() self.organizer.addWidget(left_panel_container) self.organizer.addWidget(self.grid) self.organizer.addWidget(self.dispos_scroll) main_layout = QVBoxLayout(self) main_layout.addWidget(self.organizer) self.setLayout(main_layout) self.add_faction_shortcut = QShortcut(QKeySequence("Ctrl+F"), self) self.add_item_shortcut = QShortcut(QKeySequence("Ctrl+N"), self) self.grid.focused_spawn_changed.connect(self._on_focused_spawn_changed) self.add_faction_shortcut.activated.connect( self._on_add_faction_requested) self.add_item_shortcut.activated.connect(self._on_add_item_requested) self.dispos_form.editors["PID"].editingFinished.connect( self._on_pid_field_changed) self.dispos_form.editors["Team"].currentIndexChanged.connect( self._on_team_field_changed) self.dispos_form.editors["Coordinate (1)"].textChanged.connect( self._on_coordinate_1_field_changed) self.dispos_form.editors["Coordinate (2)"].textChanged.connect( self._on_coordinate_2_field_changed)
class Torrents2Tab(QWidget): newtorrents = Signal(int) def __init__(self): QWidget.__init__(self) layout = QVBoxLayout(self) self.splitter = QSplitter(self) self.list = QTreeView(self) self.list.setSortingEnabled(True) self.model = NewTorrentModel() proxy = QSortFilterProxyModel() proxy.setSourceModel(self.model) self.list.setModel(proxy) self.splitter.addWidget(self.list) self.t = QTableWidget(0, 4, self) self.splitter.addWidget(self.t) layout.addWidget(self.splitter) self.setLayout(layout) self.ds = DataSource() self.worker = UpdateTorrentWorker() self.worker_thread = QThread() self.worker_thread.started.connect(self.worker.run) self.worker.finished.connect(self.worker_thread.quit) self.worker.moveToThread(self.worker_thread) self.worker_thread.start() self.worker.processed.connect(self.processed) def finish(self): self.worker.finish() self.worker_thread.quit() self.worker_thread.wait() def processed(self, topic): self.model.add_topic(topic['published'])
def __init__(self): if not path.exists(algorithm_directory): os.makedirs(algorithm_directory, exist_ok=True) self.fmodel = QFileSystemModel() self.fmodel.setRootPath(algorithm_directory) self.module_list = QTreeView() self.module_list.setModel(self.fmodel) self.module_list.setRootIndex(self.fmodel.index(algorithm_directory)) self.module_button = QPushButton("Change Directory") self.module_button.clicked.connect(self.change_dir) self.start_date = ToggleButton('Start Date') self.end_date = ToggleButton('End Date', 'Default (Present)') self.test_types = ['Profit', 'Accuracy'] self.test_type = QComboBox() self.test_type.addItems(self.test_types) self.test_output = QTextEdit() self.test_output.setDisabled(True) self.run_btn = QPushButton('Run Test') self.profit = QLCDNumber() self.accuracy = QLCDNumber() super().__init__('Jencks Stock Algorithm Tester')
def __init__(self, parent: QtWidgets.QWidget): """ Args: parent (QtWidgets.QWidget): The widget """ QTreeView.__init__(self, parent) QTimer.singleShot(200, self.style_me) self.expanded.connect(self.resize_on_expand)
def __init__(self, parent: QWidget): """ Inits TreeViewQLibrary Args: parent (QtWidgets.QWidget): parent widget """ QTreeView.__init__(self, parent) self.is_dev_mode = False # Whether MetalGUI is in developer mode
def __init__(self, parent: QWidget): """ Inits TreeViewQLibrary Args: parent (QtWidgets.QWidget): parent widget """ QTreeView.__init__(self, parent) self.tool_tip_str = "Library of QComponents"
def read(self, index): putanja = self.dock.model.filePath(index) if os.path.isdir(putanja): return ista_putanja = False for i in range(len(self.lista_putanja)): if putanja == self.lista_putanja[i]: ista_putanja = True return if not ista_putanja: self.lista_putanja.append(putanja) if putanja.find(".sql") != -1: self.connection = mysql.connector.connect(user="******", password="******", host="127.0.0.1", database="projekat") self.csor = self.connection.cursor() putanja = "podaci\metaPodaci\projekat_meta_podaci.csv" meta_podaci = citanje_meta_podataka(putanja, True) self.imena_tabela = meta_podaci[4].split(",") self.treeView = QTreeView() self.treeView.setContextMenuPolicy(Qt.CustomContextMenu) self.treeView.customContextMenuRequested.connect(self.dugme_baza) model = QStandardItemModel(parent=self.dock.tree.sub_layout) item = QStandardItem("zatvori") item.setEditable(False) model.appendRow(item) for text in self.imena_tabela: item = QStandardItem(text) item.setEditable(False) model.appendRow(item) self.treeView.setModel(model) self.treeView.clicked.connect(self.dugme_baza) self.treeView.PositionAtBottom si = self.dock.tree.sub_layout.sizeHint() si.setWidth(self.dock.width()) si.setHeight(200) self.treeView.setFixedSize(si.width(), si.height()) self.treeView.setHeaderHidden(True) self.dock.tree.sub_layout.addWidget(self.treeView) self.dock.tree.sub_layout.setAlignment(self.treeView, QtCore.Qt.AlignBottom) return tab = Tab(putanja, parent=self.central_widget) tab.pocetna_strana = self if putanja != "": tab.read() else: tab.read(putanja) tab.btn_down.clicked.connect(self.otvori_tabelu_dete) tab.btn_up.clicked.connect(self.otvori_tabelu_roditelj) tab.naziv = tab.meta_podaci[0] self.central_widget.addTab(tab, tab.naziv) self.central_widget.setCurrentIndex(self.central_widget.currentIndex()+1)
def __init__(self, parent: QtWidgets.QWidget): """ Args: parent (QtWidgets.QWidget): the widget """ QTreeView.__init__(self, parent) # not sure whu the ui isn't updating these here. self.expanded.connect(self.resize_on_expand)
def __init__(self, index_filename): QWidget.__init__(self) self.data_index = pd.DataFrame() self.data_info = aecg.tools.indexer.StudyInfo() self.data_index_stats = aecg.tools.indexer.StudyStats( self.data_info, self.data_index) # Getting the Models self.project_loaded = '' self.projectmodel = ProjectTreeModel() # Creating a QTreeView for displaying the selected project index self.project_treeview = QTreeView() self.project_treeview.setModel(self.projectmodel) self.phorizontal_header = self.project_treeview.header() self.phorizontal_header.setSectionResizeMode( QHeaderView.ResizeToContents) self.phorizontal_header.setStretchLastSection(True) self.sp_right = QSplitter(Qt.Orientation.Horizontal) self.sp_left = QSplitter(Qt.Orientation.Vertical, self.sp_right) # NavigationWidget Layout self.main_layout = QVBoxLayout() size = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) # Left side # Left side - Top layout # Left side - Bottom Layout size.setVerticalStretch(4) self.project_treeview.setSizePolicy(size) self.sp_left.addWidget(self.project_treeview) # Right side size = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) size.setHorizontalStretch(2) size.setHeightForWidth(False) self.tabdisplays = TabDisplays(self) self.sp_right.addWidget(self.tabdisplays) self.tabdisplays.validator_data_ready.connect( self.load_projectindex_after_validation) self.sp_right.setSizePolicy(size) # Set the layout to the QWidget self.main_layout.addWidget(self.sp_right) self.setLayout(self.main_layout) self.tabdisplays.setCurrentWidget(self.tabdisplays.validator) # Load study index if index_filename and (index_filename != ""): if os.path.exists(index_filename): self.load_projectindex(os.path.normpath(index_filename)) else: QMessageBox.warning(self, f"Study index file not found", f"{index_filename} not found")
def __init__(self, parent=None): QWidget.__init__(self, parent) self.treeView = QTreeView(self) layout = QVBoxLayout() layout.addWidget(self.treeView) self.setLayout(layout) self.treeView.setModel(QStandardItemModel()) self.treeView.model().setHorizontalHeaderLabels(('3', '1', '5'))
def __init__(self): super(MainWindow, self).__init__() self.model = Project() self.view = QTreeView(self) self.view.setModel(self.model) self.view.setDragEnabled(True) self.view.setDragDropMode(QAbstractItemView.InternalMove) self.setCentralWidget(self.view)
def __init__(self, parent: QWidget): """ Inits TreeViewQLibrary Args: parent (QtWidgets.QWidget): parent widget """ QTreeView.__init__(self, parent) self.tool_tip_str = "Library of QComponents.\nClick one to create it." self.expanded.connect(self.onExpanded)
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout(self) self.splitter = QSplitter(self) self.tree = QTreeView(self) self.tree.setSortingEnabled(True) self.tree.setModel(ForumModel()) self.splitter.addWidget(self.tree) layout.addWidget(self.splitter) self.setLayout(layout)
def __init__(self): QDockWidget.__init__(self, "File Menager") self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) model = QFileSystemModel() model.setRootPath(QDir.currentPath()) tree = QTreeView() tree.setModel(model) self.setWidget(tree)
def __init__(self, parent: QtWidgets.QWidget): """ Args: parent (QtWidgets.QWidget): The parent widget """ QTreeView.__init__(self, parent) QWidget_PlaceholderText.__init__(self, "Select a QComponent to edit"\ "\n\nfrom the QComponents window") # not sure whu the ui isn't updating these here. QTimer.singleShot(200, self.style_me) self.expanded.connect(self.resize_on_expand)
def fileList(self): #树状文件列表 self.model = QDirModel() self.view = QTreeView(self) self.view.setModel(self.model) self.view.setColumnHidden(1, True) self.view.setColumnHidden(2, True) self.view.setColumnHidden(3, True) self.view.setHeaderHidden(True) #self.view.setRootIndex(self.model.index("c:/")) self.layout.addWidget(self.view, 0, 0, 2, 1)
def add_transformation_at_index( component_model: ComponentTreeModel, component_tree_view: QTreeView, component_index: QModelIndex, ): """ Adds a transformation to the component model at a given index. :param component_model: The component model. :param component_tree_view: The component tree view. :param component_index: The QModelIndex that is selected when the transformation is added. """ component_tree_view.setCurrentIndex(component_index) component_model.add_transformation(component_index, TransformationType.TRANSLATION)
def currentChanged(self, current, previous): QTreeView.currentChanged(self, current, previous) device_path = self.model().itemFromIndex(current).data() logging.debug('device selected: ' + device_path) device_props_tree_widget.clear() device_props_tree_widget.addTopLevelItems([ item for item in iter_device_props_tree_items( device_path, devices_dict[device_path]) ]) device_props_tree_widget.expandAll() if self.history_push_flag: self.history_push(device_path) self.history_push_flag = True
def add_link_at_index( component_model: ComponentTreeModel, component_tree_view: QTreeView, component_index: QModelIndex, ): """ Adds a link to the component model at a given index. :param component_model: The component model. :param component_tree_view: The component tree view. :param component_index: The QModelIndex that is selected when the link is added. """ component_tree_view.setCurrentIndex(component_index) component_model.add_link(component_index)
class App(QWidget): '''The FolderMaker base class''' def __init__(self, root_path, conf): super().__init__() self.title = 'FolderMaker' self.root_path = root_path self.conf = conf self.init_ui() def on_btn(self): '''Creates buttons on click''' basedir = ROOT_PATH try: create_dirs( self.conf, basedir, range(int(self.start_box.text()), int(self.stop_box.text()))) except ValueError: msg = QMessageBox() msg.setText('Error! Invalid numbers in text boxes!') msg.exec() except FileExistsError as file_ex: msg = QMessageBox() msg.setText( f'Error! Directory already exists! Exception: {str(file_ex)}') msg.exec() def init_ui(self): '''Initializes the UI''' self.setWindowTitle(self.title) self.model = QFileSystemModel() self.model.setRootPath(ROOT_PATH) self.tree = QTreeView() self.tree.setModel(self.model) self.tree.setRootIndex(self.model.index(self.root_path)) self.start_box = QLineEdit() self.stop_box = QLineEdit() self.start_box.setValidator(QIntValidator()) self.stop_box.setValidator(QIntValidator()) self.make_btn = QPushButton("Create Project Folders") self.make_btn.clicked.connect(self.on_btn) layout = QVBoxLayout() layout.addWidget(self.tree) subgrid = QGridLayout() subgrid.addWidget(self.start_box, 0, 1) subgrid.addWidget(self.stop_box, 1, 1) subgrid.addWidget(QLabel('From (inc.): '), 0, 0) subgrid.addWidget(QLabel('To (not inc.): '), 1, 0) layout.addLayout(subgrid) layout.addWidget(self.make_btn) self.setLayout(layout) self.show()
class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.model = Project() self.view = QTreeView(self) self.view.setModel(self.model) self.view.setDragEnabled(True) self.view.setDragDropMode(QAbstractItemView.InternalMove) self.setCentralWidget(self.view) def mousePressEvent(self, e): print(e.x(), e.y()) return QMainWindow.mousePressEvent(self, e)