Esempio n. 1
0
class ModuleDetailsWindow(FramelessWindow):
    def __init__(self, parent):
        super(ModuleDetailsWindow, self).__init__(parent)
        self.content_widget = QWidget(self)
        self.widget_layout = QFormLayout(self.content_widget)
        self.content_widget.setLayout(self.widget_layout)
        self.addContentWidget(self.content_widget)

        self.module_code = QTextEdit(self.content_widget)
        self.module_code.setReadOnly(True)
        self.widget_layout.addWidget(self.module_code)

    def set_module(self, module: Module):
        try:
            self.module_code.setText(base64.b64decode(module.code).decode())
        except Exception as e:
            self.module_code.setText(
                "Exception while loading module's code: {}".format(e))
Esempio n. 2
0
    def __init__(self, parent=None, current_key='', selectable_keys=[]):
        QWidget.__init__(self, parent)
        self.setMinimumWidth(450)
        self.setMinimumHeight(200)
        self._dynamic = False
        self.setWindowTitle("Copy the style of {0} to other keys".format(current_key))
        self.activateWindow()

        layout = QFormLayout(self)

        self._ert = ERT.ert
        """:type: res.enkf.enkf_main.EnKFMain"""

        self.model = self._ert

        self._filter_popup = FilterPopup(self)
        self._filter_popup.filterSettingsChanged.connect(self.filterSettingsChanged)

        filter_popup_button = QToolButton()
        filter_popup_button.setIcon(resourceIcon("ide/cog_edit.png"))
        filter_popup_button.clicked.connect(self._filter_popup.show)

        self._list_model = FilterableKwListModel(self._ert, selectable_keys)
        self._list_model.unselectAll()

        self._cl = CheckList(self._list_model, custom_filter_button=filter_popup_button)

        layout.addWidget(self._cl)

        apply_button = QPushButton("Apply")
        apply_button.clicked.connect(self.accept)
        apply_button.setDefault(True)

        close_button = QPushButton("Close")
        close_button.setToolTip("Hide this dialog")
        close_button.clicked.connect(self.reject)

        button_layout = QHBoxLayout()
        button_layout.addStretch()
        button_layout.addWidget(apply_button)
        button_layout.addWidget(close_button)

        layout.addRow(button_layout)
Esempio n. 3
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.first = QLineEdit(self)
        self.second = QLineEdit(self)
        self.third = QLineEdit(self)
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)

        layout = QFormLayout(self)
        layout.addRow("Images/Video to annotate with bounding boxes, labels",
                      self.first)
        layout.addRow("Format of input, including .", self.second)
        layout.addRow(
            "Comma separated classes you want to annotate in the images",
            self.third)

        layout.addWidget(buttonBox)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
Esempio n. 4
0
    def __init__(self, parent, current_key, key_defs):
        QWidget.__init__(self, parent)
        self.setMinimumWidth(450)
        self.setMinimumHeight(200)
        self._dynamic = False
        self.setWindowTitle(f"Copy the style of {current_key} to other keys")
        self.activateWindow()

        layout = QFormLayout(self)

        self._filter_popup = FilterPopup(self, key_defs)
        self._filter_popup.filterSettingsChanged.connect(
            self.filterSettingsChanged)

        filter_popup_button = QToolButton()
        filter_popup_button.setIcon(resourceIcon("filter_list.svg"))
        filter_popup_button.clicked.connect(self._filter_popup.show)

        self._list_model = FilterableKwListModel(key_defs)
        self._list_model.unselectAll()

        self._cl = CheckList(self._list_model,
                             custom_filter_button=filter_popup_button)

        layout.addWidget(self._cl)

        apply_button = QPushButton("Apply")
        apply_button.clicked.connect(self.accept)
        apply_button.setDefault(True)

        close_button = QPushButton("Close")
        close_button.setToolTip("Hide this dialog")
        close_button.clicked.connect(self.reject)

        button_layout = QHBoxLayout()
        button_layout.addStretch()
        button_layout.addWidget(apply_button)
        button_layout.addWidget(close_button)

        layout.addRow(button_layout)
Esempio n. 5
0
 def __init__(self, title, fields):
     super().__init__()
     self.setWindowTitle(title)
     self.inputs = []
     layout = QFormLayout(self)
     for field in fields:
         value = field[1]
         if type(value) is str:
             entry = QLineEdit(self)
             width = 200
             if len(field[1]) > 50:
                 width = 400
             entry.setMinimumWidth(width)
             entry.setText(value)
         elif isinstance(value, list):
             entry = QComboBox()
             entry.addItems(value)
         self.inputs.append(entry)
         layout.addRow(field[0], entry)
     buttonBox = QDialogButtonBox(
         QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
     layout.addWidget(buttonBox)
     buttonBox.accepted.connect(self.accept)
     buttonBox.rejected.connect(self.reject)
Esempio n. 6
0
    def __init__(self, *args, **kwargs):
        super(MainWidget, self).__init__(*args, **kwargs)
        
        #Widgets
        self.label_Title1 = QLabel()
        self.label_Title1.setText("INGRESE LOS DATOS")
        self.label_Title2 = QLabel()
        self.label_Title2.setText("DATOS BOMBILLOS ESTANDAR")
        self.label_Title3 = QLabel()
        self.label_Title3.setText("DATOS BOMBILLOS LED")
        
        self.label_Data1 = QLabel()
        self.label_Data1.setText("Costo de la electricidad (kW/hora)")
        self.label_Data2 = QLabel()
        self.label_Data2.setText("Numero de bombillos a reemplazar")
        self.label_Data3 = QLabel()
        self.label_Data3.setText("Vatios del bombillo existente")
        self.label_Data4 = QLabel()
        self.label_Data4.setText("Numero de Horas por Dia encendido")
        self.label_Data5 = QLabel()
        self.label_Data5.setText("Vida util bombillo actual")
        self.label_Data6 = QLabel()
        self.label_Data6.setText("Costo Bombillo actual")
        self.label_Data7 = QLabel()
        self.label_Data7.setText("Costo estimado mantenimiento por bombillo")
        self.label_Data8 = QLabel()
        self.label_Data8.setText("Vatios del bombillo LED")
        self.label_Data9 = QLabel()
        self.label_Data9.setText("Vida util estimada del bombillo")
        self.label_Data10 = QLabel()
        self.label_Data10.setText("Costo del bombillo led")
        
        
        #Widgets Titulos del Form
        self.label_Titlef1 = QLabel()
        self.label_Titlef1.setText("INFORMACION DE COSTOS CALCULADOS")
        self.label_Titlef2 = QLabel()
        self.label_Titlef2.setText("INFORMACION DE AHORROS CALCULADOS")
        
        self.line_Data1 = QLineEdit()
        #self.line_Data1.setValidator()
        self.line_Data2 = QLineEdit()
        self.line_Data2.setValidator(QIntValidator())
        self.line_Data3 = QLineEdit()
        self.line_Data3.setValidator(QIntValidator())
        self.line_Data4 = QLineEdit()
        self.line_Data4.setValidator(QIntValidator())
        self.line_Data5 = QLineEdit()
        self.line_Data5.setValidator(QIntValidator())
        self.line_Data6 = QLineEdit()
        #self.line_Data6.setValidator()
        self.line_Data7 = QLineEdit()
        #self.line_Data7.setValidator()
        self.line_Data8 = QLineEdit()
        #self.line_Data8.setValidator()
        self.line_Data9 = QLineEdit()
        #self.line_Data9.setValidator()
        self.line_Data10 = QLineEdit()
        #self.line_Data10.setValidator()
        
        #Widget Informacion Calculada Form1 Costos
        self.line_Inf1 = QLineEdit()
        self.line_Inf1.setValidator(QIntValidator())
        self.line_Inf2 = QLineEdit()
        self.line_Inf2.setValidator(QIntValidator())
        self.line_Inf3 = QLineEdit()
        self.line_Inf3.setValidator(QIntValidator())
        self.line_Inf4 = QLineEdit()
        self.line_Inf4.setValidator(QIntValidator())
        self.line_Inf5 = QLineEdit()
        self.line_Inf5.setValidator(QIntValidator())
        self.line_Inf6 = QLineEdit()
        self.line_Inf6.setValidator(QIntValidator())
        self.line_Inf7 = QLineEdit()
        self.line_Inf7.setValidator(QIntValidator())
        self.line_Inf8 = QLineEdit()
        self.line_Inf8.setValidator(QIntValidator())
        self.line_Inf9 = QLineEdit()
        self.line_Inf9.setValidator(QIntValidator())
        
        #Widget Informacion Calculada Form2 Ahorros
        self.line_Sav1 = QLineEdit()
        self.line_Sav1.setValidator(QIntValidator())
        self.line_Sav2 = QLineEdit()
        self.line_Sav2.setValidator(QIntValidator())
        self.line_Sav3 = QLineEdit()
        self.line_Sav3.setValidator(QIntValidator())
        self.line_Sav4 = QLineEdit()
        self.line_Sav4.setValidator(QIntValidator())
        self.line_Sav5 = QLineEdit()
        self.line_Sav5.setValidator(QIntValidator())
        self.line_Sav6 = QLineEdit()
        self.line_Sav6.setValidator(QIntValidator())
        
        
        self.button_Calc = QPushButton('Calcular Ahorro', parent=self)
        self.button_Impr = QPushButton('Imprimir', parent=self)
        
        #Layouts
        layout =  QGridLayout()
        layout.addWidget(self.label_Title1,0,0)
        layout.addWidget(self.label_Data1,1,0)
        layout.addWidget(self.line_Data1,1,1)
        layout.addWidget(self.label_Title2,2,0)
        layout.addWidget(self.label_Data2,3,0)
        layout.addWidget(self.line_Data2,3,1)
        layout.addWidget(self.label_Data5,3,2)
        layout.addWidget(self.line_Data5,3,3)
        layout.addWidget(self.label_Data3,4,0)
        layout.addWidget(self.line_Data3,4,1)
        layout.addWidget(self.label_Data6,4,2)
        layout.addWidget(self.line_Data6,4,3)
        layout.addWidget(self.label_Data4,5,0)
        layout.addWidget(self.line_Data4,5,1)
        layout.addWidget(self.label_Data7,5,2)
        layout.addWidget(self.line_Data7,5,3)
        layout.addWidget(self.label_Title3,6,0)
        layout.addWidget(self.label_Data8,7,0)
        layout.addWidget(self.line_Data8,7,1)
        layout.addWidget(self.label_Data10,7,2)
        layout.addWidget(self.line_Data10,7,3)
        layout.addWidget(self.label_Data9,8,0)
        layout.addWidget(self.line_Data9,8,1)
        layout.addWidget(self.button_Calc,8,3)
        
        layout1 = QFormLayout()
        layout1.addRow("Horas por año",self.line_Inf1)
        layout1.addRow("Costo de Energia por Dia",self.line_Inf2)
        layout1.addRow("Costo de Energia por Año",self.line_Inf3)
        layout1.addRow("Costo total de la Compra",self.line_Inf4)
        layout1.addRow("Costo Total de la compra con mantenimiento",self.line_Inf5)
        layout1.addRow("Costo Reemplazo Actuales Año",self.line_Inf6)
        layout1.addRow("Costo Energia por Dia LED",self.line_Inf7)
        layout1.addRow("Costo de Energia por Año LED",self.line_Inf8)
        layout1.addRow("Costo Total de la Compra LED",self.line_Inf9)
        
        layout2 = QFormLayout()
        layout2.addRow("Ahorro Energia Anual",self.line_Sav1)
        layout2.addRow("Ahorro Energia Mensual",self.line_Sav2)
        layout2.addRow("Periodo Retorno Inversion en Años",self.line_Sav3)
        layout2.addRow("Periodo Retorno Inversion en Meses",self.line_Sav4)
        layout2.addWidget(self.button_Impr)
        
        #Layout Horizontal Titulos del Form
        self.LayoutTitle = QHBoxLayout()
        self.LayoutTitle.addWidget(self.label_Titlef1)
        self.LayoutTitle.addWidget(self.label_Titlef2)

        ### Layout HOrizontal que une los dos Form
        self.LayoutForm = QHBoxLayout() 
        self.LayoutForm.addLayout(layout1)
        self.LayoutForm.addLayout(layout2)
        
        ## LAyout Vertical Final
        self.myLayout = QVBoxLayout()
        self.myLayout.setMargin(20)
        self.myLayout.addLayout(layout)
        self.myLayout.addLayout(self.LayoutTitle)
        self.myLayout.addLayout(self.LayoutForm)
       
        self.setLayout(self.myLayout)
        
        # Signals
        self.button_Calc.clicked.connect(self.result_method)
Esempio n. 7
0
class PayloadWindow(FramelessWindow):
    get_build_options = Signal()
    start_build = Signal(str, str, list)
    stop_build = Signal()

    def __init__(self, parent):
        super(PayloadWindow, self).__init__(parent)
        self.logger = logging.getLogger(self.__class__.__name__)
        self.setContentsMargins(11, 11, 11, 11)
        self.progress_windows = []

        self.content_widget = QWidget(self)
        self.addContentWidget(self.content_widget)

        self.widget_layout = QFormLayout(self.content_widget)
        self.content_widget.setLayout(self.widget_layout)

        self.spinner = WaitingSpinner(self,
                                      modality=Qt.WindowModal,
                                      roundness=70.0,
                                      fade=70.0,
                                      radius=15.0,
                                      lines=6,
                                      line_length=25.0,
                                      line_width=4.0,
                                      speed=1.0)

        self.build_name_label = QLabel("Name", self.content_widget)
        self.build_name_edit = QLineEdit(self.content_widget)
        self.widget_layout.addRow(self.build_name_label, self.build_name_edit)

        self.icon_label = QLabel("Icon", self.content_widget)
        self.icon_combobox = QComboBox(self.content_widget)
        self.widget_layout.addRow(self.icon_label, self.icon_combobox)

        self.generators_label = QLabel("Generators", self.content_widget)
        self.generators_list = QListWidget(self.content_widget)
        self.widget_layout.addRow(self.generators_label, self.generators_list)

        self.build_button = QPushButton("Build", self.content_widget)
        self.build_button.clicked.connect(self.on_build_button_clicked)
        self.widget_layout.addWidget(self.build_button)

        self.menu = QMenu(self)
        self.menu.setTitle("Payload")
        self.reload_action = QAction(self.menu)
        self.reload_action.setText("Reload options")
        self.reload_action.triggered.connect(self.setupUi)
        self.menu.addAction(self.reload_action)
        self.addMenu(self.menu)

    @Slot()
    def setupUi(self):
        self.spinner.start()
        self.get_build_options.emit()

    @Slot(dict)
    def process_build_message(self, message):
        if self.isVisible():
            event = message.get("event")
            if event == "options":
                options = message.get("options")
                self.set_options(options.get("generators"),
                                 options.get("icons"))
            elif event == "started":
                self.set_started(message.get("generator_name"))
            elif event == "stopped":
                self.set_stopped()
            elif event == "progress":
                self.set_progress(message.get("generator_name"),
                                  message.get("progress"))
            elif event == "error":
                self.set_error(message.get("error"))
            elif event == "generator_finished":
                self.set_generator_finished(message.get("generator_name"),
                                            message.get("exit_code"))
            elif event == "build_finished":
                self.set_build_finished()

    @Slot(str, str)
    def set_progress(self, generator_name, progress):
        for win in self.progress_windows:
            if win.generator() == generator_name:
                win.appendProgress(progress)

    @Slot(str)
    def set_started(self, generator_name):
        win = ProgressWindow(self, generator_name)
        win.show()
        self.progress_windows.append(win)
        self.logger.info("Generator {} started!".format(generator_name))
        self.reload_action.setEnabled(False)
        self.spinner.start()

    @Slot(str, int)
    def set_generator_finished(self, generator_name, exit_code):
        self.logger.info("Generator {} finished with exit code {}.".format(
            generator_name, exit_code))

    @Slot(list, list)
    def set_options(self, generators, icons):
        self.build_name_edit.clear()
        self.generators_list.clear()
        self.icon_combobox.clear()
        for generator in generators:
            item = QListWidgetItem(generator, self.generators_list)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
            item.setCheckState(Qt.Checked)
            self.generators_list.addItem(item)
        for icon in icons:
            name = icon.get("name")
            pix = QPixmap()
            pix.loadFromData(base64.b64decode(icon.get("ico")))
            ico = QIcon()
            ico.addPixmap(pix)
            self.icon_combobox.addItem(ico, name)
        self.spinner.stop()

    @Slot()
    def set_stopped(self):
        self.on_build_finished()
        self.build_button.setText("Build")
        self.stopped_messagebox = FramelessInformationMessageBox(self)
        self.stopped_messagebox.setText(
            "Build process has been stopped successfully.")
        self.stopped_messagebox.setStandardButtons(QDialogButtonBox.Ok)
        self.stopped_messagebox.button(QDialogButtonBox.Ok).clicked.connect(
            self.stopped_messagebox.close)
        self.stopped_messagebox.show()

    @Slot(str)
    def set_error(self, error):
        self.on_build_finished()
        self.build_button.setText("Build")
        self.error_messagebox = FramelessCriticalMessageBox(self)
        self.error_messagebox.setText(error)
        self.error_messagebox.setStandardButtons(QDialogButtonBox.Ok)
        self.error_messagebox.button(QDialogButtonBox.Ok).clicked.connect(
            self.error_messagebox.close)
        self.error_messagebox.show()

    @Slot()
    def set_build_finished(self):
        self.on_build_finished()
        self.build_button.setText("Build")
        self.build_finished_messagebox = FramelessInformationMessageBox(self)
        self.build_finished_messagebox.setText(
            "Build process has been finished.")
        self.build_finished_messagebox.setStandardButtons(QDialogButtonBox.Ok)
        self.build_finished_messagebox.button(
            QDialogButtonBox.Ok).clicked.connect(
                self.build_finished_messagebox.close)
        self.build_finished_messagebox.show()

    @Slot()
    def on_build_button_clicked(self):
        if self.build_button.text() == "Build":
            generators = []
            for i in range(self.generators_list.count()):
                item = self.generators_list.item(i)
                if item.checkState() == Qt.Checked:
                    generators.append(item.text())
            self.start_build.emit(self.build_name_edit.text(),
                                  self.icon_combobox.currentText(), generators)
            self.build_button.setText("Stop")
        else:
            self.stop_build_messagebox = FramelessQuestionMessageBox(self)
            self.stop_build_messagebox.setText(
                "Do you want to stop build process?")
            self.stop_build_messagebox.setStandardButtons(
                QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
            self.stop_build_messagebox.button(
                QDialogButtonBox.Cancel).clicked.connect(
                    self.stop_build_messagebox.close)
            self.stop_build_messagebox.button(
                QDialogButtonBox.Ok).clicked.connect(self.stop_build.emit)
            self.stop_build_messagebox.button(
                QDialogButtonBox.Ok).clicked.connect(
                    self.stop_build_messagebox.close)
            self.stop_build_messagebox.show()

    @Slot()
    def on_build_finished(self):
        self.reload_action.setEnabled(True)
        self.spinner.stop()

    @Slot()
    def close(self) -> bool:
        for win in self.progress_windows:
            win.close()
        return super().close()
Esempio n. 8
0
class TaskKwargsGroupBox(QGroupBox):
    def __init__(self, parent):
        super(TaskKwargsGroupBox, self).__init__(parent)
        self.widgets = []
        self.current_task = None

        self.widget_layout = QFormLayout(self)
        self.setLayout(self.widget_layout)

        self.setTitle("Options")

    @Slot(dict)
    def set_kwargs(self, task):
        """Creates widgets for each task keyword argument."""
        if not task or task is self.current_task:
            return
        else:
            for widget_dict in self.widgets:
                key_widget = widget_dict.get("key")
                value_widget = widget_dict.get("value")

                if key_widget:
                    key_widget.setParent(None)
                    self.widget_layout.removeWidget(key_widget)

                value_widget.setParent(None)
                self.widget_layout.removeWidget(value_widget)
            self.widgets.clear()
            self.current_task = task

        kwargs_dict = task.get("kwargs")
        for key, value in kwargs_dict.items():
            key_label = QLabel(str(key).replace("_", " ").capitalize(), self)
            val_type = value.get("type")
            default = value.get("default")

            if val_type is int:
                value_widget = QSpinBox(self)
                value_widget.setRange(-1, 100000)
                value_widget.setValue(int(default))
            elif val_type is list:
                value_widget = QListWidget(self)
                value_widget.addItems([str(item) for item in default])
                for i in range(value_widget.count()):
                    value_widget.item(i).setFlags(
                        value_widget.item(i).flags() | Qt.ItemIsEditable)
            elif val_type is str:
                value_widget = QLineEdit(self)
                value_widget.setText(str(default))
            elif val_type is bool:
                key_label = None
                value_widget = QCheckBox(
                    str(key).replace("_", " ").capitalize(), self)
                value_widget.setChecked(bool(default))
            elif val_type == "text":
                value_widget = QTextEdit(self)
                value_widget.setText(str(default))
            else:
                continue

            value_widget.setObjectName(key)
            value_widget.setToolTip(value.get("description"))
            self.widgets.append({"key": key_label, "value": value_widget})
            if type(value_widget) is QCheckBox:
                self.widget_layout.addWidget(value_widget)
            else:
                self.widget_layout.addRow(key_label, value_widget)

    def get_kwargs(self):
        """Returns user arguments"""
        kwargs = {}
        for widget_dict in self.widgets:
            value_widget = widget_dict.get("value")
            if type(value_widget) == QSpinBox:
                kwargs[value_widget.objectName()] = value_widget.value()
            elif type(value_widget) == QListWidget:
                kwargs[value_widget.objectName()] = [
                    value_widget.item(x).text()
                    for x in range(value_widget.count())
                ]
            elif type(value_widget) == QLineEdit:
                kwargs[value_widget.objectName()] = value_widget.text()
            elif type(value_widget) == QTextEdit:
                kwargs[value_widget.objectName()] = value_widget.toPlainText()
            elif type(value_widget) == QCheckBox:
                kwargs[value_widget.objectName()] = value_widget.isChecked()
        return kwargs
Esempio n. 9
0
class ConfigurePresentationWindow(QWidget):
    def __init__(self, parent):
        super().__init__()
        self.parent = parent
        # set title
        self.setWindowTitle("Configure Presentation")
        # set variables
        self.setupVariables()
        # setup Hymn Lyrics
        from glob import glob
        from pathlib import Path
        self.books = sorted([
            Path(filename).stem
            for filename in glob(r"./marvelData/books/Hymn Lyrics*.book")
        ])
        if len(self.books) > 0:
            self.setMinimumHeight(550)
        # setup interface
        self.setupUI()

    def setupVariables(self):
        pass

    def setupUI(self):

        from functools import partial
        from qtpy.QtCore import Qt
        from qtpy.QtWidgets import QHBoxLayout, QFormLayout, QSlider, QPushButton, QPlainTextEdit, QCheckBox, QComboBox
        from qtpy.QtWidgets import QRadioButton, QWidget, QVBoxLayout, QListView, QSpacerItem, QSizePolicy

        layout = QHBoxLayout()

        layout1 = QFormLayout()

        self.fontsizeslider = QSlider(Qt.Horizontal)
        self.fontsizeslider.setMinimum(1)
        self.fontsizeslider.setMaximum(12)
        self.fontsizeslider.setTickInterval(2)
        self.fontsizeslider.setSingleStep(2)
        self.fontsizeslider.setValue(config.presentationFontSize / 0.5)
        self.fontsizeslider.setToolTip(str(config.presentationFontSize))
        self.fontsizeslider.valueChanged.connect(
            self.presentationFontSizeChanged)
        layout1.addRow("Font Size", self.fontsizeslider)

        self.changecolorbutton = QPushButton()
        buttonStyle = "QPushButton {0}background-color: {2}; color: {3};{1}".format(
            "{", "}", config.presentationColorOnDarkTheme if config.theme
            == "dark" else config.presentationColorOnLightTheme,
            "white" if config.theme == "dark" else "black")
        self.changecolorbutton.setStyleSheet(buttonStyle)
        self.changecolorbutton.setToolTip("Change Color")
        self.changecolorbutton.clicked.connect(self.changeColor)
        layout1.addRow("Font Color", self.changecolorbutton)

        self.marginslider = QSlider(Qt.Horizontal)
        self.marginslider.setMinimum(0)
        self.marginslider.setMaximum(200)
        self.marginslider.setTickInterval(50)
        self.marginslider.setSingleStep(50)
        self.marginslider.setValue(config.presentationMargin)
        self.marginslider.setToolTip(str(config.presentationMargin))
        self.marginslider.valueChanged.connect(self.presentationMarginChanged)
        layout1.addRow("Margin", self.marginslider)

        self.verticalpositionslider = QSlider(Qt.Horizontal)
        self.verticalpositionslider.setMinimum(10)
        self.verticalpositionslider.setMaximum(90)
        self.verticalpositionslider.setTickInterval(10)
        self.verticalpositionslider.setSingleStep(10)
        self.verticalpositionslider.setValue(
            config.presentationVerticalPosition)
        self.verticalpositionslider.setToolTip(
            str(config.presentationVerticalPosition))
        self.verticalpositionslider.valueChanged.connect(
            self.presentationVerticalPositionChanged)
        layout1.addRow("Vertical Position", self.verticalpositionslider)

        self.horizontalpositionslider = QSlider(Qt.Horizontal)
        self.horizontalpositionslider.setMinimum(10)
        self.horizontalpositionslider.setMaximum(90)
        self.horizontalpositionslider.setTickInterval(10)
        self.horizontalpositionslider.setSingleStep(10)
        self.horizontalpositionslider.setValue(
            config.presentationHorizontalPosition)
        self.horizontalpositionslider.setToolTip(
            str(config.presentationHorizontalPosition))
        self.horizontalpositionslider.valueChanged.connect(
            self.presentationHorizontalPositionChanged)
        layout1.addRow("Horizontal Position", self.horizontalpositionslider)

        self.showBibleSelection = QRadioButton()
        self.showBibleSelection.setChecked(True)
        self.showBibleSelection.clicked.connect(
            lambda: self.selectRadio("bible"))
        layout1.addRow("Bible", self.showBibleSelection)

        if len(self.books) > 0:
            self.showHymnsSelection = QRadioButton()
            self.showHymnsSelection.setChecked(False)
            self.showHymnsSelection.clicked.connect(
                lambda: self.selectRadio("hymns"))
            layout1.addRow("Hymns", self.showHymnsSelection)

        # Second column

        layout2 = QVBoxLayout()

        self.bibleWidget = QWidget()
        self.bibleLayout = QFormLayout()

        checkbox = QCheckBox()
        checkbox.setText("")
        checkbox.setChecked(config.presentationParser)
        checkbox.stateChanged.connect(self.presentationParserChanged)
        checkbox.setToolTip("Parse bible verse reference in the entered text")
        self.bibleLayout.addRow("Bible Reference", checkbox)

        versionCombo = QComboBox()
        self.bibleVersions = self.parent.textList
        versionCombo.addItems(self.bibleVersions)
        initialIndex = 0
        if config.mainText in self.bibleVersions:
            initialIndex = self.bibleVersions.index(config.mainText)
        versionCombo.setCurrentIndex(initialIndex)
        versionCombo.currentIndexChanged.connect(self.changeBibleVersion)
        self.bibleLayout.addRow("Bible Version", versionCombo)

        self.textEntry = QPlainTextEdit("John 3:16; Rm 5:8")
        self.bibleLayout.addRow(self.textEntry)

        button = QPushButton("Presentation")
        button.setToolTip("Go to Presentation")
        button.clicked.connect(self.goToPresentation)
        self.bibleLayout.addWidget(button)

        self.bibleLayout.addItem(
            QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))

        self.bibleWidget.setLayout(self.bibleLayout)

        self.hymnWidget = QWidget()
        self.hymnLayout = QFormLayout()

        selected = 0
        book = "Hymn Lyrics - English"
        if book in self.books:
            selected = self.books.index(book)
        self.bookList = QComboBox()
        self.bookList.addItems(self.books)
        self.bookList.setCurrentIndex(selected)
        self.bookList.currentIndexChanged.connect(self.selectHymnBook)
        self.hymnLayout.addWidget(self.bookList)

        self.chapterlist = QListView()
        self.chapterlist.clicked.connect(self.selectHymn)
        # self.chapterlist.selectionModel().selectionChanged.connect(self.selectHymn)
        self.hymnLayout.addWidget(self.chapterlist)

        self.buttons = []
        for count in range(0, 10):
            hymnButton = QPushButton()
            hymnButton.setText(" ")
            hymnButton.setEnabled(False)
            hymnButton.clicked.connect(partial(self.selectParagraph, count))
            self.hymnLayout.addWidget(hymnButton)
            self.buttons.append(hymnButton)

        self.selectHymnBook(selected)

        self.hymnWidget.setLayout(self.hymnLayout)
        self.hymnWidget.hide()

        layout2.addWidget(self.bibleWidget)
        if len(self.books) > 0:
            layout2.addWidget(self.hymnWidget)

        layout.addLayout(layout1)
        layout.addLayout(layout2)
        self.setLayout(layout)

    def selectRadio(self, option):
        if option == "bible":
            self.bibleWidget.show()
            if len(self.books) > 0:
                self.hymnWidget.hide()
        elif option == "hymns":
            self.bibleWidget.hide()
            if len(self.books) > 0:
                self.hymnWidget.show()

    def selectHymnBook(self, option):
        from ToolsSqlite import Book
        from qtpy.QtCore import QStringListModel
        if len(self.books) > 0:
            self.hymnBook = self.books[option]
            self.hymns = sorted(Book(self.hymnBook).getTopicList())
            self.chapterModel = QStringListModel(self.hymns)
            self.chapterlist.setModel(self.chapterModel)

    def selectHymn(self, option):
        from ToolsSqlite import Book
        row = option.row()
        self.hymn = self.hymns[row]
        book = Book(self.hymnBook)
        sections = book.getParagraphSectionsByChapter(self.hymn)
        count = 0
        for button in self.buttons:
            if count < len(sections):
                section = sections[count]
                text = section.replace("<br>", "")[:30]
                button.setText(text)
                button.setEnabled(True)
            else:
                button.setText(" ")
                button.setEnabled(False)
            count += 1

    def selectParagraph(self, paragraph):
        command = "SCREENBOOK:::{0}:::{1}:::{2}".format(
            self.hymnBook, self.hymn, paragraph)
        self.parent.runTextCommand(command)

    def goToPresentation(self):
        command = "SCREEN:::{0}".format(self.textEntry.toPlainText())
        self.parent.runTextCommand(command)

    def changeColor(self):

        from qtpy.QtGui import QColor
        from qtpy.QtWidgets import QColorDialog

        color = QColorDialog.getColor(
            QColor(config.presentationColorOnDarkTheme if config.theme ==
                   "dark" else config.presentationColorOnLightTheme), self)
        if color.isValid():
            colorName = color.name()
            if config.theme == "dark":
                config.presentationColorOnDarkTheme = colorName
            else:
                config.presentationColorOnLightTheme = colorName
            buttonStyle = "QPushButton {0}background-color: {2}; color: {3};{1}".format(
                "{", "}", colorName,
                "white" if config.theme == "dark" else "black")
            self.changecolorbutton.setStyleSheet(buttonStyle)

    def presentationFontSizeChanged(self, value):
        config.presentationFontSize = value * 0.5
        self.fontsizeslider.setToolTip(str(config.presentationFontSize))

    def presentationMarginChanged(self, value):
        config.presentationMargin = value
        self.marginslider.setToolTip(str(config.presentationMargin))

    def presentationVerticalPositionChanged(self, value):
        config.presentationVerticalPosition = value
        self.verticalpositionslider.setToolTip(
            str(config.presentationVerticalPosition))

    def presentationHorizontalPositionChanged(self, value):
        config.presentationHorizontalPosition = value
        self.horizontalpositionslider.setValue(
            config.presentationHorizontalPosition)

    def presentationParserChanged(self):
        config.presentationParser = not config.presentationParser

    def changeBibleVersion(self, index):
        if __name__ == '__main__':
            config.mainText = self.bibleVersions[index]
        else:
            command = "TEXT:::{0}".format(self.bibleVersions[index])
            self.parent.runTextCommand(command)