def __init__(self, lis, form, title="", parent=None): self.title = title self.lis = lis self.form = form self.widget = QtWidgets.QWidget(parent) # create a new widget self.lay = QtWidgets.QVBoxLayout( self.widget) # attach layout to that widget self.label = QtWidgets.QLabel(self.title, self.widget) self.subwidget = QtWidgets.QWidget(self.widget) self.sublay = QtWidgets.QHBoxLayout(self.subwidget) self.lay.addWidget(self.label) self.lay.addWidget(self.subwidget) self.lis.widget.setParent( self.subwidget ) # get widget from List and set its parent to widget self.form.widget.setParent(self.subwidget) self.sublay.addWidget( self.lis.widget) # add List's internal widget to widget's layout self.sublay.addWidget(self.form.widget) self.lis.widget.currentItemChanged.connect( self.form.chooseForm_slot) # connections between list and the form self.form.signals.new_record.connect(self.lis.update_slot) self.form.signals.save_record.connect(self.lis.update_slot) self.form.signals.delete_record.connect(self.lis.update_slot) self.delete = self.form.signals.delete_record # shorthand self.modified = self.form.signals.modified
def placeWidget(self, i, key_name): """Place column widget to line i """ column = self[key_name] labelname = column.label_name label = QtWidgets.QLabel(labelname, self.widget) column.widget.setParent(self.widget) self.qlabel_by_name[column.key_name] = label # add to the layout self.lay.addWidget(label, i, 0) self.lay.addWidget(column.widget, i, 1)
def __init__(self, maintitle, lis1, lis2, form, titles=["", "", ""], parent=None): self.maintitle = maintitle self.lis1 = lis1 self.lis2 = lis2 self.form = form self.titles = titles self.parent = parent self.widget = QtWidgets.QWidget(parent) # create a new widget self.lay = QtWidgets.QHBoxLayout( self.widget) # attach layout to that widget # create three subwidgets self.sections = [] self.layouts = [] self.labels = [] for i in range(0, 3): self.sections.append(QtWidgets.QWidget( self.widget)) # create a widget self.layouts.append(QtWidgets.QVBoxLayout( self.sections[-1])) # .. create a layout to that widget self.labels.append(QtWidgets.QLabel( titles[i], self.sections[-1])) # add a QLabel to the widget self.layouts[-1].addWidget( self.labels[-1]) # add the QLabel to widget's layout self.lay.addWidget( self.sections[-1]) # add the widget to main layout self.lis1.widget.setParent(self.sections[0]) self.layouts[0].addWidget(self.lis1.widget) self.lis2.widget.setParent(self.sections[1]) self.layouts[1].addWidget(self.lis2.widget) self.form.widget.setParent(self.sections[2]) self.layouts[2].addWidget(self.form.widget) # Connect the user/car pair to the permission form self.lis1.widget.currentItemChanged.connect( self.form.chooseRecord1_slot ) # inform form about the item in question self.lis2.widget.currentItemChanged.connect( self.form.chooseRecord2_slot ) # inform form about the item in question
def makeWidget(self): """Creates a Qt form, using the column structure """ self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QGridLayout(self.widget) """ for key in self.column_by_name: print(self.pre,"makeWidget: >>",key) """ """ policy = QtWidgets.QSizePolicy() policy.setVerticalPolicy(QtWidgets.QSizePolicy.Minimum) """ for i, column in enumerate(self.columns_): if (column.widget is not None): #""" labelname = column.label_name label = QtWidgets.QLabel(labelname, self.widget) self.qlabel_by_name[column.key_name] = label if column.label_alignment is not None: label.setAlignment(column.label_alignment) if column.label_size_policy is not None: label.setSizePolicy(column.label_size_policy) # label.setAlignment(QtCore.Qt.AlignTop) # label.setSizePolicy(policy) column.widget.setParent(self.widget) # add to the layout self.lay.addWidget(label, i, 0) self.lay.addWidget(column.widget, i, 1) #""" # self.placeWidget(i, column.key_name) # print(self.pre,"makeWidget :",labelname,label,column.widget) # print("column visible", column.visible, column.label_name) if column.visible == False: qlabel.setVisible(False) column.widget.setVisible(False) self.connectNotifications()
def makeWidget(self): self.widget = QtWidgets.QLabel(self.label_name)