def __init__(self): super(ComicExplorer, self).__init__() self.defaultColour = QApplication.style().standardPalette() self.layout = FlowLayout(self) self.display_comics()
def setupUi(self, MainWindow): super().setupUi(MainWindow) self.attachment_grid = FlowLayout() self.attachment_grid.setObjectName(u"attachment_grid") self.verticalLayout_6.addLayout(self.attachment_grid)
class ComicExplorer(DefaultWidget): def __init__(self): super(ComicExplorer, self).__init__() self.defaultColour = QApplication.style().standardPalette() self.layout = FlowLayout(self) self.display_comics() def display_comics(self): def rename(directory): print(f"Searching {directory}") for file in os.listdir(directory): file_type = gui_functions.suffix(file) comic_path = os.path.join(directory, file) # If file is folder then search folder if file_type == "": rename(comic_path) continue # If file is a supported file type and contains an image then create Comic object. if file_type in ZIP_TYPES: image = gui_functions.image_from_path_to_zip(comic_path) if image: self.layout.addWidget(Comic(comic_path, image, self)) for x in DIRECTORIES: rename(x)
def __init__(self): super().__init__() self.setupUi(self) layout = FlowLayout(parent=self.frameValveControl) for i in range(1, 30): checkBox = QtWidgets.QCheckBox(f'{i}') layout.addWidget(checkBox) self.__dict__[f'checkBoxValve{i}'] = checkBox self.checkBoxValve1.setEnabled(False) with open(os.path.join(_path, 'style_sheet.txt'), 'r') as f: styleSheet = f.read() self.setStyleSheet(styleSheet) # while layout.count(): # child = layout.takeAt(0) # if child.widget(): # child.widget().deleteLater() # for i in range(1, 9): # checkBox = QtWidgets.QCheckBox(f'Valve {i}') # layout.addWidget(checkBox) # self.__dict__[f'checkBoxValve{i}'] = checkBox self.actionSR1.triggered.connect(self.test) self.pushButtonStart.clicked.connect(self.test2)
def on_new_data(self, data: Dict): """ Replace existing data views with updated ones drawn from provided dictionary. """ self.clear() show = self.get_keys() for ii, (_, keys) in enumerate(show.items()): current_widget = QWidget() current_layout = FlowLayout() for key in keys: current_layout.addWidget( CellFeatureView(key, get_feature(data, *["cell_record", key]))) current_widget.setLayout(current_layout) self.central_layout.addWidget(current_widget) if ii < len(show) - 1: divider = QFrame() divider.setFrameStyle(QFrame.HLine) divider.setLineWidth(3) self.central_layout.addWidget(divider)
def __init__(self): QWidget.__init__(self) flow_layout = FlowLayout() labels = [ "Short", "Longer", "Different text", "More text", "Even longer button text" ] for lbl in labels: wdgt = QLabel(lbl) wdgt.setStyleSheet("border: 1px solid black;") flow_layout.addWidget(wdgt) self.setLayout(flow_layout) self.setWindowTitle("Flow Layout")
def __init__(self): super().__init__() vl = QtWidgets.QVBoxLayout(self) vl.setSpacing(0) vl.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(True) self.q = QtWidgets.QWidget() self.fl = FlowLayout(self.q) # scroll.setLayout(self.fl) scroll.setWidget(self.q) vl.addWidget(scroll) bottom_label = QtWidgets.QLabel( 'Use mouse movement together with left click, ctrl/cmd and shift to define the pose.' ) bottom_label.setAlignment(Qt.AlignBottom) bottom_label.setContentsMargins(5, 5, 5, 5) vl.addWidget(bottom_label) self.scene: Scene = None self.obj: Object = None self.overlays = []
def layout(): return FlowLayout(margin=12, horizontal_spacing=24, vertical_spacing=36)
class Ui_MainWindow_Extend(Ui_MainWindow): def setupUi(self, MainWindow): super().setupUi(MainWindow) self.attachment_grid = FlowLayout() self.attachment_grid.setObjectName(u"attachment_grid") self.verticalLayout_6.addLayout(self.attachment_grid) def show_no_subject_pop_up(self): msg = QMessageBox() msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msg.setDefaultButton(QMessageBox.No) msg.setStyleSheet(u"QPushButton{\n" " background-color: rgb(85, 170, 255);\n" " color: rgb(255, 255, 255);\n" " border: 2px solid;\n" " border-color: none;\n" " border-radius: 10px;\n" " width: 50px;\n" " height: 20px;\n" " padding: 10px;\n" "}\n" "\n" "QPushButton:hover{\n" " border: 2px solid;\n" " border-color: rgb(85, 85, 255);\n" "}\n" "QMessageBox{\n" " background-color: rgb(255, 255, 255);\n" "}") msg.setIconPixmap(QPixmap(":/icons/images/help-circle.svg")) msg.setText('Are you sure you want to send without a subject?') msg.setWindowTitle('Empty subject') return msg.exec_() def show_exit_confirmation(self): msg = QMessageBox() msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msg.setDefaultButton(QMessageBox.No) msg.setStyleSheet(u"QPushButton{\n" " background-color: rgb(85, 170, 255);\n" " color: rgb(255, 255, 255);\n" " border: 2px solid;\n" " border-color: none;\n" " border-radius: 10px;\n" " width: 50px;\n" " height: 20px;\n" " padding: 10px;\n" "}\n" "\n" "QPushButton:hover{\n" " border: 2px solid;\n" " border-color: rgb(85, 85, 255);\n" "}\n" "QMessageBox{\n" " background-color: rgb(255, 255, 255);\n" "}") msg.setIconPixmap(QPixmap(":/icons/images/help-circle.svg")) msg.setText('Emails are being sent. Are you sure you want to quit?') msg.setWindowTitle('Close program') return msg.exec_() def show_cleaning_up_message(self): msg = QMessageBox() msg.setStandardButtons(0) msg.setStyleSheet(u"QPushButton{\n" " background-color: rgb(85, 170, 255);\n" " color: rgb(255, 255, 255);\n" " border: 2px solid;\n" " border-color: none;\n" " border-radius: 10px;\n" " width: 50px;\n" " height: 20px;\n" " padding: 10px;\n" "}\n" "\n" "QPushButton:hover{\n" " border: 2px solid;\n" " border-color: rgb(85, 85, 255);\n" "}\n" "QMessageBox{\n" " background-color: rgb(255, 255, 255);\n" "}") msg.setText('Please wait for the program to clean up and terminate') msg.setWindowTitle('Closing program') return msg.exec_()
class Editor(QtWidgets.QWidget): def __init__(self): super().__init__() vl = QtWidgets.QVBoxLayout(self) vl.setSpacing(0) vl.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setWidgetResizable(True) self.q = QtWidgets.QWidget() self.fl = FlowLayout(self.q) # scroll.setLayout(self.fl) scroll.setWidget(self.q) vl.addWidget(scroll) bottom_label = QtWidgets.QLabel( 'Use mouse movement together with left click, ctrl/cmd and shift to define the pose.' ) bottom_label.setAlignment(Qt.AlignBottom) bottom_label.setContentsMargins(5, 5, 5, 5) vl.addWidget(bottom_label) self.scene: Scene = None self.obj: Object = None self.overlays = [] def open_image(self, image: Image): overlay = RenderOverlayWidget(image, self.crop_near) overlay.render_overlay.set_obj(self.obj) self.overlays.append(overlay) self.fl.addWidget(overlay) def crop_near(self): for overlay in self.overlays: overlay.render_overlay.crop_near_() def close_image(self, image: Image): for overlay in list(self.overlays): if overlay.image is image: overlay.remove() self.overlays.remove(overlay) def on_new_scene(self, scene: Scene): self.scene = scene for image in self.scene.images: image.open_listeners.add(partial(self.open_image, image)) image.close_listeners.add(partial(self.close_image, image)) def select_object(self, obj: Object): self.obj = obj for c in self.fl.children(): c.remove() if obj.pose is None: open_images = [img for img in self.scene.images if img.is_open] if open_images: image = open_images[0] else: image = self.scene.images[0] obj.pose = image.camera_pose @ Transform( p=(0, 0, obj.diameter * 3), rpy=(np.pi / 2, 0, 0)) obj.pose = obj.pose @ Transform(p=-obj.center) for overlay in self.overlays: overlay.render_overlay.set_obj(obj)