def __init__(self, table): QWidget.__init__(self) layout = QVBoxLayout() hlayout = QHBoxLayout() l = QLabel(table.name()) font = l.font() font.setBold(True) l.setFont(font) hlayout.addWidget(l) open_table_btn = QToolButton() icon = QIcon(os.path.dirname(__file__) + "/mActionOpenTableGML.svg") open_table_btn.setIcon(icon) open_table_btn.resize(32, 32) open_table_btn.clicked.connect( lambda checked: self.linkActivated.emit(table.name()) ) hlayout.addWidget(open_table_btn) f = QFrame() f.setFrameStyle(QFrame.Panel | QFrame.Plain) f.setLineWidth(2.0) f.setLayout(hlayout) layout.addWidget(f) self.attribute_label = QLabel() names = [f.name() for f in table.columns()] names += [l.name() + "_id" for l in table.links() if l.max_occurs() == 1] names += [l.ref_table().name() + "_id" for l in table.back_links()] self.attribute_label.setText("\n".join(names)) v2 = QVBoxLayout() v2.addWidget(self.attribute_label) self.attribute_frame = QFrame() self.attribute_frame.setFrameStyle(QFrame.Panel | QFrame.Plain) self.attribute_frame.setLineWidth(2.0) self.attribute_frame.setLayout(v2) layout.addWidget(self.attribute_frame) self.setLayout(layout) fm = QFontMetricsF(self.attribute_label.font()) self.__font_height = fm.height() margins = layout.contentsMargins() self.attribute_x_offset = margins.left() self.attribute_x2_offset = margins.right()
def _create_bar(self): for i in range(len(self.steps)): self.widgets[i] = [] if i != 0: line = QFrame() line.setFrameShape(QFrame.HLine) line.setLineWidth(3) line.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) line.setFixedHeight(self.bar_height) self.layout_bar.addWidget(line) self.widgets[i].append(line) dot = QLabel("•") dot.font_size = self.bar_height * 2.6 dot.setFixedWidth(self.dot_width) dot.setFixedHeight(self.bar_height) dot.setAlignment(Qt.AlignCenter) self.layout_bar.addWidget(dot) self.widgets[i].append(dot)
class TableWidget(QWidget): linkActivated = pyqtSignal(str) def __init__(self, table): QWidget.__init__(self) layout = QVBoxLayout() hlayout = QHBoxLayout() l = QLabel(table.name()) font = l.font() font.setBold(True) l.setFont(font) hlayout.addWidget(l) open_table_btn = QToolButton() icon = QIcon(os.path.dirname(__file__) + "/mActionOpenTableGML.svg") open_table_btn.setIcon(icon) open_table_btn.resize(32, 32) open_table_btn.clicked.connect( lambda checked: self.linkActivated.emit(table.name()) ) hlayout.addWidget(open_table_btn) f = QFrame() f.setFrameStyle(QFrame.Panel | QFrame.Plain) f.setLineWidth(2.0) f.setLayout(hlayout) layout.addWidget(f) self.attribute_label = QLabel() names = [f.name() for f in table.columns()] names += [l.name() + "_id" for l in table.links() if l.max_occurs() == 1] names += [l.ref_table().name() + "_id" for l in table.back_links()] self.attribute_label.setText("\n".join(names)) v2 = QVBoxLayout() v2.addWidget(self.attribute_label) self.attribute_frame = QFrame() self.attribute_frame.setFrameStyle(QFrame.Panel | QFrame.Plain) self.attribute_frame.setLineWidth(2.0) self.attribute_frame.setLayout(v2) layout.addWidget(self.attribute_frame) self.setLayout(layout) fm = QFontMetricsF(self.attribute_label.font()) self.__font_height = fm.height() margins = layout.contentsMargins() self.attribute_x_offset = margins.left() self.attribute_x2_offset = margins.right() def attributeCoords(self, idx): # returns the box coordinates of the idx-th attribute offset_y = self.attribute_label.y() + self.attribute_frame.y() offset_x = self.attribute_x_offset x = self.x() + offset_x w = self.width() - offset_x - self.attribute_x2_offset y = self.y() + offset_y + self.__font_height * idx h = self.__font_height return (x, y, w, h)