예제 #1
0
파일: Gui.py 프로젝트: netinggh/Eule.py
    def __init__(self, elder):
        super().__init__()
        self.elder = elder
        self.layout = QGridLayout(self)
        self.settings = elder.settings
        self.listener = elder.listener

        checkbox = QCheckBox(self)
        checkbox.setText('Abbrevations enabled')
        checkbox.setChecked(self.settings.special['abbrevations_enabled'])
        checkbox.clicked.connect(self.checkbox_clicked)
        self.layout.addWidget(checkbox)

        abbrevations = QGroupBox(self)
        abbrevations.setTitle('Current Abbrevations')
        abbrevations_layout = QGridLayout(abbrevations)
        self.layout.addWidget(abbrevations)

        self.abbrevations_list = QListWidget(abbrevations)
        self.abbrevations_list.setSelectionMode(QListWidget.SingleSelection)
        for abbrevation, msg in self.settings.abbrevations.items():
            # Add the new Item to QListWidget
            custom_widget = CustomListWidget(abbrevation, msg)
            item = QListWidgetItem(self.abbrevations_list)
            item.abbrevation = abbrevation
            item.msg_line_edit = custom_widget.msg_edit

            self.abbrevations_list.addItem(item)
            item.setSizeHint(custom_widget.minimumSizeHint())
            self.abbrevations_list.setItemWidget(item, custom_widget)
        abbrevations_layout.addWidget(self.abbrevations_list, 0, 0, 1, 0)

        button = QPushButton(abbrevations)
        button.setText('Save')
        button.clicked.connect(self.update_abbrevations)
        abbrevations_layout.addWidget(button, 1, 0)

        button = QPushButton(abbrevations)
        button.setText('Add new')
        button.clicked.connect(self.add_item)
        abbrevations_layout.addWidget(button, 1, 1)

        button = QPushButton(abbrevations)
        button.setText('Remove selected')
        button.clicked.connect(self.remove_selected_item)
        abbrevations_layout.addWidget(button, 1, 2)

        self.layout.addWidget(abbrevations)

        self.setLayout(self.layout)
예제 #2
0
파일: Gui.py 프로젝트: netinggh/Eule.py
    def add_item(self):
        dlg = AddItemDialog(self)
        if dlg.exec_():
            abbrevation = dlg.abbrevation_edit.text()
            msg = dlg.msg_edit.text()

            # Add the new Item to QListWidget
            custom_widget = CustomListWidget(abbrevation, msg)
            item = QListWidgetItem(self.abbrevations_list)
            item.abbrevation = abbrevation
            item.msg_line_edit = custom_widget.msg_edit

            self.abbrevations_list.addItem(item)
            item.setSizeHint(custom_widget.minimumSizeHint())
            self.abbrevations_list.setItemWidget(item, custom_widget)