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 __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 setupUi(self): self.setGeometry(QtCore.QRect(100, 100, 800, 800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QHBoxLayout(self.w) # Create a list self.lis = self.data_model.PersonList( collection=self.data_model.collection) # Get lists's widget self.lis.widget.setParent(self.w) # Add to main layout self.lay.addWidget(self.lis.widget) # Create a group of forms self.formset = EditFormSet(collection=self.data_model.collection) # Get form's widget and set it's parent to the current main widget self.formset.widget.setParent(self.w) # Add formset to layout self.lay.addWidget(self.formset.widget) # Inform formset about the item in question. "self.lis.widget" is a QListWidget instance. self.lis.widget.currentItemChanged.connect( self.formset.chooseForm_slot) # inform list when a new record has been added or when a record has been saved self.formset.signals.new_record.connect(self.lis.update_slot) self.formset.signals.save_record.connect(self.lis.update_slot)
def setupUi(self): # self.setGeometry(QtCore.QRect(100,100,800,800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QHBoxLayout(self.w) self.person_view = ListAndForm( self.data_model.PersonList(collection=self.data_model.collection), EditFormSet(collection=self.data_model.collection), "Persons", self.w) self.food_view = ListAndForm( self.data_model.FoodList( collection=self.data_model.food_collection), EditFormSet(collection=self.data_model.food_collection), "Foods", self.w) self.food_view.modified.connect(self.person_view.update) # instantiate PersonFormSet => instantiate rows => row instantiates widgets based on the columns => .. # updating: call row's updateWidget method => re-creates column widgets self.lay.addWidget(self.person_view.widget) self.lay.addWidget(self.food_view.widget) # self.data_model.dump() self.data_model.purge()
def makeButtons(self): self.buttons = QtWidgets.QWidget(self.widget) self.buttons_lay = QtWidgets.QHBoxLayout(self.buttons) self.new_button = QtWidgets.QPushButton("NEW", self.buttons) self.copy_button = QtWidgets.QPushButton("COPY", self.buttons) self.save_button = QtWidgets.QPushButton("SAVE", self.buttons) self.clear_button = QtWidgets.QPushButton("CLEAR", self.buttons) self.delete_button = QtWidgets.QPushButton("DELETE", self.buttons) self.new_button.clicked.connect(self.new_slot) self.copy_button.clicked.connect(self.copy_slot) self.save_button.clicked.connect(self.save_slot) self.clear_button.clicked.connect(self.clear_slot) self.delete_button.clicked.connect(self.delete_slot) self.buttons_lay.addWidget(self.new_button) self.buttons_lay.addWidget(self.copy_button) self.buttons_lay.addWidget(self.save_button) self.buttons_lay.addWidget(self.clear_button) self.buttons_lay.addWidget(self.delete_button) self.signals.new_record.connect(self.signals.modified.emit) self.signals.save_record.connect(self.signals.modified.emit) self.signals.delete_record.connect(self.signals.modified.emit)
def setupUi(self): self.setGeometry(QtCore.QRect(100, 100, 800, 800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QHBoxLayout(self.w) # Create a list self.lis = PersonList(collection=collection) # Get lists's widget self.lis.widget.setParent(self.w) # Add to main layout self.lay.addWidget(self.lis.widget) # Create a group of forms self.formset = FormSet(collection=collection) # Get form's widget. It encapsulates the form widgets of each row type self.formset.widget.setParent(self.w) # Add formset to layout self.lay.addWidget(self.formset.widget) # Inform formset about the item in question self.lis.widget.currentItemChanged.connect( self.formset.chooseForm_slot)
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 makeWidget(self): self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QHBoxLayout(self.widget) self.line = QtWidgets.QLineEdit(self.widget) self.line.setReadOnly(True) self.button = QtWidgets.QPushButton("Choose", self.widget) self.lay.addWidget(self.line) self.lay.addWidget(self.button) self.button.clicked.connect(self.open_dialog_slot)
def setupUi(self): self.setGeometry(QtCore.QRect(100, 100, 800, 800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QHBoxLayout(self.w) # Create a list view of a collection. We need to provide a collection, of course self.lis = PersonList(collection=collection) # Get lists's widget, set its parent to the current main widget self.lis.widget.setParent(self.w) # Add to main layout self.lay.addWidget(self.lis.widget)
def setupUi(self): # self.setGeometry(QtCore.QRect(100,100,800,800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay = QtWidgets.QHBoxLayout(self.w) # List view of person_collection self.person_lis = PersonList(collection=person_collection) self.person_lis.widget.setParent(self.w) self.lay.addWidget(self.person_lis.widget) # Form views of individual records in the person_collection self.person_form = FormSet(collection=person_collection) self.person_form.widget.setParent(self.w) self.lay.addWidget(self.person_form.widget) # List view of car_collection self.car_lis = CarList(collection=car_collection) self.car_lis.widget.setParent(self.w) self.lay.addWidget(self.car_lis.widget) # Form view of records in car_collection self.car_form = FormSet(collection=car_collection) self.car_form.widget.setParent(self.w) self.lay.addWidget(self.car_form.widget) # Form view of the Link table self.permission_form = PermissionFormSet(collection=link_collection, key1_name="user_key", key2_name="car_key") self.permission_form.widget.setParent(self.w) self.lay.addWidget(self.permission_form.widget) # Create connections between list views, forms, etc. self.person_lis.widget.currentItemChanged.connect( self.person_form.chooseForm_slot ) # inform person formset about the item in question self.car_lis.widget.currentItemChanged.connect( self.car_form.chooseForm_slot ) # inform car formset about the item in question # Connect the user/car pair to the permission form self.person_lis.widget.currentItemChanged.connect( self.permission_form.chooseRecord1_slot ) # inform formset about the item in question self.car_lis.widget.currentItemChanged.connect( self.permission_form.chooseRecord2_slot ) # inform formset 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): """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.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 setupUi(self): self.setGeometry(QtCore.QRect(100,100,800,800)) self.w=QtWidgets.QWidget(self) self.setCentralWidget(self.w) self.lay=QtWidgets.QHBoxLayout(self.w) self.person_view =ListAndForm(self.data_model.getPersonList(), self.data_model.getPersonForm(), "Registered Persons", self.w) self.vehicle_view =ListAndForm(self.data_model.getVehicleList(),self.data_model.getVehicleForm(), "Registered Vehicles", self.w) self.device_view =ListAndForm(self.data_model.getDeviceList(), self.data_model.getDeviceForm(), "Registered Cameras", self.w) self.company_view =ListAndForm(self.data_model.getCompanyList(),self.data_model.getCompanyForm(), "Registered Companies",self.w) self.area_view =ListAndForm(self.data_model.getAreaList(), self.data_model.getAreaForm(), "Registered Areas", self.w) self.area_permission_view =PermissionListsAndForm("Area Permissions", self.data_model.getAreaList(), self.data_model.getVehicleList(), self.data_model.getAreaPermissionForm(), titles=["AREA","VEHICLE","PERMISSION"], parent=self.w) self.area_permission_per_company_view =PermissionListsAndForm("Area Permission per Company", self.data_model.getAreaList(), self.data_model.getCompanyList(), self.data_model.getAreaPerCompanyPermissionForm(), titles=["AREA","COMPANY","PERMISSION"], parent=self.w) # Update GUI's if relation targets change: self.device_view.modified. connect(self.area_view.update) self.vehicle_view.modified.connect(self.area_view.update) self.area_view.modified. connect(self.area_permission_view.update) self.vehicle_view.modified.connect(self.area_permission_view.update) self.area_view.modified. connect(self.area_permission_per_company_view.update) self.company_view.modified.connect(self.area_permission_per_company_view.update) self.all_views=[self.person_view, self.vehicle_view, self.device_view, self.company_view, self.area_view, self.area_permission_view, self.area_permission_per_company_view] self.hideAll() for view in self.all_views: self.lay.addWidget(view.widget) self.file_menu =self.menuBar().addMenu("File") self.config_menu =self.menuBar().addMenu("Configuration") self.perm_menu =self.menuBar().addMenu("Permissions") self.exit_action =self.file_menu.addAction("Exit") self.exit_action.triggered.connect(self.exit_slot) self.person_menu_action =self.config_menu.addAction("Persons") self.vehicle_menu_action =self.config_menu.addAction("Vehicles") self.device_menu_action =self.config_menu.addAction("Devices") self.company_menu_action =self.config_menu.addAction("Companies") self.area_menu_action =self.config_menu.addAction("Areas") self.area_permissions_action =self.perm_menu.addAction("Area Permissions") self.area_per_company_action =self.perm_menu.addAction("Area per Company Permissions") self.person_menu_action.triggered. connect(self.person_menu_slot) self.vehicle_menu_action.triggered. connect(self.vehicle_menu_slot) self.device_menu_action.triggered. connect(self.device_menu_slot) self.company_menu_action.triggered. connect(self.company_menu_slot) self.area_menu_action.triggered. connect(self.area_menu_slot) self.area_permissions_action.triggered. connect(self.area_permission_slot) self.area_per_company_action.triggered. connect(self.area_per_company_slot)
def makeWidget(self): self.widget = QtWidgets.QWidget() self.lay = QtWidgets.QVBoxLayout(self.widget) self.makeForm() self.lay.addWidget(self.form)
def setupUi(self): self.setGeometry(QtCore.QRect(100, 100, 800, 800)) self.w = QtWidgets.QWidget(self) self.setCentralWidget(self.w) # self.lay=QtWidgets.QGridLayout(self.w) self.lay = QtWidgets.QHBoxLayout(self.w)
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)