def title_hbox(self): """ Creates a Horizontal box layout containing the title lineedit and an edit button :return: QHBoxLayout """ # Create Edit/Label title = self.project_info['title'] title_edit = QLineEdit(title) grid_title(self.app, title_edit) title_edit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) title_edit.setEnabled(False) self.title_wid = title_edit # Create Edit Button edit_btn = QPushButton() edit_btn.setIcon( QIcon(os.path.abspath(__file__ + '/../..' + '/img/Pencil-52.png'))) edit_btn.setMaximumWidth(self.geometry().width() / 50) edit_btn.setMaximumHeight(self.geometry().width() / 50) checkable_button(self.app, edit_btn) # Add an action to the edit button edit_btn.clicked[bool].connect( lambda: self.on_edit_pressed(title_edit)) # Create Layout hbox = QHBoxLayout() hbox.addWidget(title_edit) hbox.addWidget(edit_btn) return hbox
def create_obj_thumb(self, title: str, published_date: str, object_id: int): """ Creates a large QPushButton with information on the objects title, and published date. Args: title: Name of the Figshare object. published_date: String representation of when/if the object was made public. object_id: Figshare object ID number Returns: btn (QPushButton): Button connected to open a subwindow with its specific ID number. """ # Get the scaling rations for the current display w_ratio, f_ratio = scaling_ratio(self.app) # Scale the font sizes title_fnt_size = 12 * f_ratio date_ftn_size = 8 * f_ratio # Create the Title Label # Create the title label title_lbl = QLabel() title_lbl.setText("{}".format(title)) title_lbl_fnt = QFont('SansSerif', title_fnt_size) title_lbl_fnt.setBold(True) title_lbl.setFont(title_lbl_fnt) title_lbl.setWordWrap(True) # Create the date label date_lbl = QLabel() if published_date is None: published_date = 'Private' date_lbl.setText("Published: {}".format(published_date)) date_lbl_fnt = QFont('SansSerif', date_ftn_size) date_lbl.setFont(date_lbl_fnt) date_lbl.setStyleSheet('color: gray') date_lbl.setWordWrap(True) # Create a layout to hold the labels lbl_box = QVBoxLayout() # Add labels to layout lbl_box.addWidget(title_lbl) lbl_box.addWidget(date_lbl) # Create a button for the project btn = QPushButton(self) checkable_button(self.app, btn) btn.setLayout(lbl_box) btn.clicked[bool].connect(lambda: self.on_object_pressed(object_id)) self.object_buttons_box.addWidget(btn)
def articles_button(self): """ Creates a click button to open and close the project articles window :return: QPushButton """ btn = QPushButton() btn.setIcon( QIcon(os.path.abspath(__file__ + '/../..' + '/img/Magazine-50.png'))) checkable_button(self.app, btn) btn.setMaximumWidth(self.geometry().width() / 20) btn.setMinimumWidth(self.geometry().width() / 20) btn.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) btn.setToolTip('Open Project Articles Window') btn.setToolTipDuration(1000) btn.clicked[bool].connect(self.on_articles_pressed) return btn
def description_vbox(self): """ Creates a Vertical box layout containing the description label and edit button and a textedit field :return: QVBoxLayout """ # Create the Description Label lbl = self.create_label('Description') lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) # Create Edit Button edit_btn = QPushButton() edit_btn.setIcon( QIcon(os.path.abspath(__file__ + '/../..' + '/img/Pencil-52.png'))) edit_btn.setMaximumWidth(self.geometry().width() / 50) edit_btn.setMaximumHeight(self.geometry().width() / 50) checkable_button(self.app, edit_btn) # Create TextEdit description = self.project_info['description'] text_edit = QTextEdit() if description is not None and description != '': text_edit.setText(description) grid_edit(self.app, text_edit) text_edit.setEnabled(False) self.desc_wid = text_edit # Add an action to the edit button edit_btn.clicked[bool].connect(lambda: self.on_edit_pressed(text_edit)) # Create a horizontal layout for the label and edit button hbox = QHBoxLayout() hbox.addWidget(lbl) hbox.addWidget(edit_btn) # Create a Vertical layout to hold the label layout and the edit field vbox = QVBoxLayout() vbox.addLayout(hbox) vbox.addWidget(text_edit) return vbox
def button_layout(self): """ Creates a QLayout object holding the section buttons :return: QLayout Object containing toggle buttons for different sections """ # QLayout to hold buttons button_box = QVBoxLayout() # Projects projects_btn = QPushButton('Projects', self) checkable_button(self.app, projects_btn) projects_btn.clicked[bool].connect(self.on_projects_btn_pressed) self.projects_btn = projects_btn # Collections collections_btn = QPushButton('Collections', self) checkable_button(self.app, collections_btn) collections_btn.clicked[bool].connect(self.on_collections_btn_pressed) self.collections_btn = collections_btn # Local Data localdata_btn = QPushButton('Local Data', self) checkable_button(self.app, localdata_btn) localdata_btn.clicked[bool].connect(self.on_local_data_btn_pressed) self.localdata_btn = localdata_btn # Selection #selection_btn = QPushButton('Selection', self) #checkable_button(self.app, selection_btn) #self.selection_btn = selection_btn # Add Buttons to Layout button_box.addWidget(projects_btn) button_box.addWidget(collections_btn) button_box.addWidget(localdata_btn) #button_box.addWidget(selection_btn) return button_box