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 makeWidget(self): self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QVBoxLayout(self.widget) self.makeForm() # from mother class self.lay.insertWidget(0, self.form) self.row_dialog = RowDialog(self.row_instance_by_name.keys()) self.makeButtons() self.lay.insertWidget(1, self.buttons)
def makeForm(self): self.makeRows() self.form = QtWidgets.QWidget(self.widget) self.form.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.form_lay = QtWidgets.QVBoxLayout(self.form) for key, row in self.row_instance_by_name.items(): if (row.widget): row.widget.setParent(self.form) self.form_lay.addWidget(row.widget)
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): self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QVBoxLayout(self.widget) self.makeForm() # from mother class self.dropdown_widget = QtWidgets.QComboBox(self.widget) self.row_instance_by_index = [] for i, key in enumerate(self.row_instance_by_name.keys()): row_instance = self.row_instance_by_name[key] self.row_instance_by_index.append(row_instance) classname = key display_name = row_instance.getName() self.dropdown_widget.insertItem(i, display_name) self.dropdown_widget.currentIndexChanged.connect( self.dropdown_changed_slot) self.lay.insertWidget(0, self.dropdown_widget) self.lay.insertWidget(1, self.form) self.makeButtons() self.lay.insertWidget(2, self.buttons)
def makeWidget(self): self.widget = QtWidgets.QWidget() # self.widget.setAlignment(QtCore.Qt.AlignTop) # nopes self.sublay = QtWidgets.QVBoxLayout(self.widget) self.sublay.setAlignment(QtCore.Qt.AlignTop) lis = self.getList() self.radio_buttons_by_value = {} # policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) policy = QtWidgets.QSizePolicy() policy.setVerticalPolicy(QtWidgets.QSizePolicy.Minimum) # policy.setVerticalPolicy(QtWidgets.QSizePolicy.ShrinkFlag) self.widget.setSizePolicy(policy) # self.widget.setMaximumHeight(40) for i, (label, value) in enumerate(lis): # print("ConstantRadioButtonColumn: makeWidget: label, value>", label, value) rb = QtWidgets.QRadioButton(label, self.widget) # rb = QtWidgets.QLabel("test") rb.setSizePolicy(policy) self.radio_buttons_by_value[value] = rb self.sublay.addWidget(rb) self.updateWidget()
def __init__(self, typenames, title="", parent=None): super().__init__(parent) self.setWindowTitle(title) self.layout = QtWidgets.QVBoxLayout(self) self.qlis = QtWidgets.QListWidget(self) self.create = QtWidgets.QPushButton("Create", self) self.cancel = QtWidgets.QPushButton("Cancel", self) self.layout.addWidget(self.qlis) self.layout.addWidget(self.create) self.layout.addWidget(self.cancel) for typename in typenames: item = QtWidgets.QListWidgetItem() item.setText(typename) item.typename = typename self.qlis.addItem(item) self.create.clicked.connect(lambda: self.done(1)) self.cancel.clicked.connect(lambda: self.reject()) self.clear()
def makeWidget(self): self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QVBoxLayout(self.widget) self.makeForm() self.lay.addWidget(self.form)
def makeWidget(self): self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QVBoxLayout(self.widget) self.row_instance.widget.setParent(self.widget) self.lay.addWidget(self.row_instance.widget)