Exemplo n.º 1
0
    def __init__(self, factory):
        QWidget.__init__(self)

        self.factory = factory

        self.damping = QLineEdit(
            str(
                self.factory.getHillClimberAcceptOption(
                    "simulated-annealing.damping")))
        self.damping.setAlignment(Qt.AlignRight)
        self.damping.setValidator(QDoubleValidator(0.0, 1.0, 4))
        self.temp = QLineEdit(
            str(
                self.factory.getHillClimberAcceptOption(
                    "simulated-annealing.temp")))
        self.temp.setAlignment(Qt.AlignRight)
        self.temp.setValidator(QDoubleValidator(0.0, 100000000.0, 4))

        layout = QVBoxLayout()
        layout.addWidget(QLabel("Damping:"))
        layout.addWidget(self.damping)
        layout.addWidget(QLabel("Temperature:"))
        layout.addWidget(self.temp)

        self.setLayout(layout)

        self.damping.textChanged.connect(self.setDamping)
        self.temp.textChanged.connect(self.setTemp)
Exemplo n.º 2
0
    def setup_buttons(self):
        # self.le_P.setValidator(QDoubleValidator())
        # self.le_D.setValidator(QDoubleValidator())
        # self.le_I.setValidator(QDoubleValidator())

        self.le_min.setValidator(QDoubleValidator())
        self.le_max.setValidator(QDoubleValidator())
        self.le_nbOfPoints.setValidator(QIntValidator())

        self.le_P.setMaxLength(5)
        self.le_I.setMaxLength(5)
        self.le_D.setMaxLength(5)
Exemplo n.º 3
0
 def _set_validators(self):
     """
     This methods sets validation rules for the input fields. It should be called only once when the 
     PreferencesDialog is instantiated.
     :return: Has no return values.
     """
     self.ui.contentWeightInput.setValidator(QDoubleValidator(self))
     self.ui.styleWeightInput.setValidator(QDoubleValidator(self))
     self.ui.tvWeightInput.setValidator(QDoubleValidator(self))
     self.ui.temporalWeightInput.setValidator(QDoubleValidator(self))
     self.ui.learningRateInput.setValidator(QDoubleValidator(self))
     self.ui.iterationsInput.setValidator(QIntValidator(0, 5000, self))
    def __init__(self, parent=None):
        """Constructor."""
        super(CoordinatorDockWidget, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect

        self.decDegreeValidator = QDoubleValidator(0.0, 180.0, 8, parent=self)
        self.decDegreeValidator.setNotation(QDoubleValidator.StandardNotation)

        self.projectedValidator = QDoubleValidator(-999999999.0,
                                                   999999999.0,
                                                   4,
                                                   parent=self)

        self._eastingLeftNorthingRight = True

        self._eastingInverted = False
        self._northingInverted = False

        self.sectionIsGeographic = {
            CoordinatorDockWidget.SectionInput: True,
            CoordinatorDockWidget.SectionOutput: True
        }

        self.setupUi(self)

        # setup some lists of the input for easier access later
        self._widgetlistInputDms = [
            self.inLeft, self.inRight, self.inLeftSec, self.inRightSec,
            self.inLeftMin, self.inRightMin
        ]
        self._widgetlistInput = self._widgetlistInputDms + [
            self.inLeftDec, self.inRightDec
        ]

        self.resetInterface()
        self.setupInternal()

        # need to init that after setupUi because of message icon label size
        messageIconWidgetSize = self.messageIcon.size()
        messageIconSize = QSize(messageIconWidgetSize.width() - 2,
                                messageIconWidgetSize.height() - 2)
        self.warningPixmap = QIcon(
            ':/plugins/coordinator/icons/warning.svg').pixmap(messageIconSize)

        self.messageHideTimer = QTimer(parent=self)
        self.messageHideTimer.setSingleShot(True)
        self.messageHideTimer.timeout.connect(self.hideMessages)
Exemplo n.º 5
0
    def __init__(self):
        QDialog.__init__(self)
        self.setupUi(self)

        self.validator = QDoubleValidator()

        self.txtRestricciones.setClearButtonEnabled(True)
        self.txtVariables.setClearButtonEnabled(True)

        self.txtRestricciones.setValidator(QIntValidator())
        self.txtVariables.setValidator(QIntValidator())

        self.scrollContent.setLayout(self.gridData)
        self.scrollAreaWidgetContents.setLayout(self.func_object)

        self.btnClose.clicked.connect(self.close)

        self.txtRestricciones.textChanged['QString'].connect(
            self.generateInputs)
        self.txtVariables.textChanged['QString'].connect(self.generateInputs)

        self.label_3.setVisible(False)
        self.label_4.setVisible(False)

        self.btnSolve.clicked.connect(self.solve)

        self.btnLimpiar.clicked.connect(lambda: self.clearLayout(True))
Exemplo n.º 6
0
    def __init__(self):
        super(MyWindow, self).__init__()
        self.resize(347, 347)
        self.setFixedSize(self.width(), self.height())
        self.setWindowTitle(u'KR1 Steam版 V2.2 跳波修改器')
        self.showMSG = QLabel(self)
        self.showMSG.setGeometry(QRect(30, 10, 300, 15))
        self.showChange = QLabel(self)
        self.showChange.setGeometry(QRect(200, 10, 147, 15))

        self.moneyGroup = QGroupBox(self)
        self.moneyGroup.setGeometry(QRect(23, 40, 300, 80))
        self.moneyGroup.setTitle(u'修改金钱 ')
        self.moneyLineEdit = QLineEdit(self)
        self.moneyLineEdit.setValidator(QIntValidator())
        self.moneyLineEdit.setGeometry(QRect(40, 65, 180, 35))
        self.moneyLineEdit.setText('10000')
        self.moneyLineEdit.setStyleSheet('color:#4F4F4F;')
        self.moneyLineEdit.setFont(QFont('Arial', 15))
        self.moneyButton = QPushButton(self)
        self.moneyButton.setGeometry(QRect(238, 64, 65, 37))
        self.moneyButton.setText(u'修改')
        self.moneyButton.clicked.connect(self.moneyModify)

        self.enemyHealthGroup = QGroupBox(self)
        self.enemyHealthGroup.setGeometry(QRect(23, 140, 300, 80))
        self.enemyHealthGroup.setTitle(u'修改Hard难度敌人血量倍数')
        self.enemyHealthLineEdit = QLineEdit(self)
        self.enemyHealthLineEdit.setValidator(QDoubleValidator())
        self.enemyHealthLineEdit.setGeometry(QRect(40, 165, 180, 35))
        self.enemyHealthLineEdit.setText('2.5')
        self.enemyHealthLineEdit.setStyleSheet('color:#4F4F4F;')
        self.enemyHealthLineEdit.setFont(QFont('Arial', 15))
        self.enemyHealthButton = QPushButton(self)
        self.enemyHealthButton.setGeometry(QRect(238, 164, 65, 37))
        self.enemyHealthButton.setText(u'修改')
        self.enemyHealthButton.setEnabled(False)
        self.enemyHealthLineEdit.setEnabled(False)
#         self.enemyHealthButton.clicked.connect(self.enemyHealthModify)

        self.enemyWaveGroup = QGroupBox(self)
        self.enemyWaveGroup.setGeometry(QRect(23, 240, 300, 80))
        self.enemyWaveGroup.setTitle(u'跳波功能 这关共有 0 波敌人')
        self.enemyWaveLineEdit = QLineEdit(self)
        self.enemyWaveLineEdit.setValidator(QIntValidator())
        self.enemyWaveLineEdit.setGeometry(QRect(40, 265, 180, 35))
        self.enemyWaveLineEdit.setText('0')
        self.enemyWaveLineEdit.setStyleSheet('color:#4F4F4F;')
        self.enemyWaveLineEdit.setFont(QFont('Arial', 15))
        self.enemyWaveButton = QPushButton(self)
        self.enemyWaveButton.setGeometry(QRect(238, 264, 65, 37))
        self.enemyWaveButton.setText(u'修改')
        self.enemyWaveButton.clicked.connect(self.skipWave)

        self.checkTotalWave = None
#         self.widgetList = [self.moneyLineEdit, self.moneyButton, self.enemyHealthLineEdit, self.enemyHealthButton, self.enemyWaveLineEdit, self.enemyWaveButton]
        self.widgetList = [self.moneyLineEdit, self.moneyButton, self.enemyWaveLineEdit, self.enemyWaveButton]
        self.checkKRHD = checkKRHD()
        self.checkKRHD.KRHDID.connect(self.KRModify)
        self.checkKRHD.start()
Exemplo n.º 7
0
 def __init__(self, *args):
     QWidget.__init__(self, *args)
     lo = QHBoxLayout(self)
     lo.setContentsMargins(0, 0, 0, 0)
     lo.setSpacing(5)
     # type selector
     self.wtypesel = QComboBox(self)
     for i, tp in enumerate(self.ValueTypes):
         self.wtypesel.addItem(tp.__name__)
     self.wtypesel.activated[int].connect(self._selectTypeNum)
     typesel_lab = QLabel("&Type:", self)
     typesel_lab.setBuddy(self.wtypesel)
     lo.addWidget(typesel_lab, 0)
     lo.addWidget(self.wtypesel, 0)
     self.wvalue = QLineEdit(self)
     self.wvalue_lab = QLabel("&Value:", self)
     self.wvalue_lab.setBuddy(self.wvalue)
     self.wbool = QComboBox(self)
     self.wbool.addItems(["false", "true"])
     self.wbool.setCurrentIndex(1)
     lo.addWidget(self.wvalue_lab, 0)
     lo.addWidget(self.wvalue, 1)
     lo.addWidget(self.wbool, 1)
     self.wvalue.hide()
     # make input validators
     self._validators = {int: QIntValidator(self), float: QDoubleValidator(self)}
     # select bool type initially
     self._selectTypeNum(0)
Exemplo n.º 8
0
 def createEditor(self, parent, option, index):
     """
     Set double validator to default editor.
     """
     editor = QStyledItemDelegate.createEditor(self, parent, option,
                                               index)
     validator = QDoubleValidator(editor)
     editor.setValidator(validator)
     return editor
Exemplo n.º 9
0
    def __init__(self, window, grid, name, plugin_id, address):

        # Save the window data.
        self.address = address
        self.name = name
        self.plugin_id = plugin_id

        # Initialize this class.
        super(PluginLog, self).__init__()

        # Initialize a UDP socket for this plugin.
        self.udp_socket = socket(AF_INET, SOCK_DGRAM)

        # Set socket options.
        self.udp_socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        self.udp_socket.settimeout(WV_REQ_TIMEOUT)

        # Initialize a timer to query data for this plugin.
        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh)

        # Initialize update thread.
        self.refresh_thread = LogRefreshThread(self.plugin_id, self.address,
                                               self.udp_socket)
        self.refresh_thread.start()

        # Connect the data signal.
        self.refresh_thread.data_signal.connect(self.do_update)

        # Initialize UI for this plugin.
        self.PluginName = QtWidgets.QLabel(window)
        self.PluginName.setText(name)
        grid.addWidget(self.PluginName, grid.rowCount(), 0)

        RefreshSpacer = QtWidgets.QSpacerItem(65535, 20,
                                              QtWidgets.QSizePolicy.Maximum,
                                              QtWidgets.QSizePolicy.Minimum)
        grid.addItem(RefreshSpacer, (grid.rowCount() - 1), 1)

        self.RefreshLable = QtWidgets.QLabel(window)
        self.RefreshLable.setText("Refresh Time (ms) :")
        grid.addWidget(self.RefreshLable, (grid.rowCount() - 1), 2)

        self.Refresh = QtWidgets.QLineEdit(window)
        self.Refresh.setValidator(QDoubleValidator(0, 999999, 2))
        self.Refresh.setMinimumWidth(50)
        self.Refresh.textChanged.connect(self.refersh_time_updated)
        self.Refresh.setText('1000')
        grid.addWidget(self.Refresh, (grid.rowCount() - 1), 3)

        self.PluginData = QtWidgets.QTextBrowser(window)
        font = QtGui.QFont()
        font.setFamily("Consolas")
        self.PluginData.setFont(font)
        grid.addWidget(self.PluginData, grid.rowCount(), 0, 1,
                       grid.columnCount())
    def __init__(self, degField, minField, secField, maxDegrees):
        super(DmsHandler, self).__init__()

        # init validators:
        self.intDegValidator = QIntValidator(0, maxDegrees, parent=self)
        self.minValidator = QIntValidator(0, 59, parent=self)

        self.secValidator = QDoubleValidator(0.0, 59.999, 3, parent=self)
        self.secValidator.setNotation(QDoubleValidator.StandardNotation)

        self._degField = degField
        self._minField = minField
        self._secField = secField

        self._maxDegrees = maxDegrees

        self._degFieldIncrementor = ValueIncrementor(self._degField,
                                                     maxDegrees,
                                                     doOverflow=False)
        self._degFieldIncrementor.fieldDidOverflow.connect(
            self.fieldDidOverflow)
        self._degField.setValidator(self.intDegValidator)
        self._degField.textEdited.connect(self.inputDidChange.emit)

        self._minFieldIncrementor = ValueIncrementor(
            self._minField, 59, wrapCallback=self.isWrapAllowedFor)
        self._minFieldIncrementor.fieldDidOverflow.connect(
            self.fieldDidOverflow)
        self._minField.setValidator(self.minValidator)
        self._minField.textChanged.connect(
            partial(self.minorFieldDidChange, self._minField))

        self._secFieldIncrementor = ValueIncrementor(
            self._secField, 59, wrapCallback=self.isWrapAllowedFor)
        self._secFieldIncrementor.fieldDidOverflow.connect(
            self.fieldDidOverflow)
        self._secField.setValidator(self.secValidator)
        self._secField.textChanged.connect(
            partial(self.minorFieldDidChange, self._secField))
Exemplo n.º 11
0
    def __init__(self, parent=None):
        super(TeamPokerUIControllerClass, self).__init__(parent)
        self.setupUi(self)
        self.setStyleSheet(WINDOW_STYLE)
        self.line_starting_ammount.setValidator(QDoubleValidator(
            0.0, 100.0, 2))
        self.line_raise_amount.setValidator(QDoubleValidator(0.0, 100.0, 2))
        self.stackedWidget.setCurrentIndex(PAGE_MAIN)
        self.tabWidget_client_window.setCurrentIndex(0)
        self.line_host_game_ip.setText(get_ip())  # TODO: remove
        self.line_host_game_port.setText(str(5555))  # TODO: remove
        self.table_money_stats.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.table_player_server_statuses.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.listView.setModel(QStandardItemModel())
        self.setServerControls(False)
        self.init_connects()

        self.player_action_array = [
            False, False, False, True
        ]  # will hold which of the 3 actions player has selected (CALL, RAISE, FOLD, UNDECIDED)
        self.history_rows = -1  # in order to put first row at index 0
Exemplo n.º 12
0
 def __init__(self, parent=None):
     super(TeamPokerUIControllerClass, self).__init__(parent)
     self.setupUi(self)
     self.setStyleSheet(WINDOW_STYLE)
     self.stackedWidget.setCurrentIndex(PAGE_MAIN)
     self.buttonHostAGame.clicked.connect(lambda f: self.stackedWidget.setCurrentIndex(PAGE_HOST_A_GAME))
     self.buttonJoinAGame.clicked.connect(lambda f: self.stackedWidget.setCurrentIndex(PAGE_JOIN_A_GAME))
     self.button_test_play_arena.clicked.connect(lambda f: self.stackedWidget.setCurrentIndex(PAGE_PLAYING_ARENA))
     self.button_client_to_main_page.clicked.connect(lambda f: self.stackedWidget.setCurrentIndex(PAGE_MAIN))
     self.button_host_to_main_page.clicked.connect(lambda f: self.stackedWidget.setCurrentIndex(PAGE_MAIN))
     self.button_dev_play_arena_to_main_page.clicked.connect(lambda f: self.stackedWidget.setCurrentIndex(PAGE_MAIN))
     self.line_starting_ammount.setValidator(QDoubleValidator(0.0, 100.0, 2))
     self.line_host_game_ip.setText(self.get_ip())
     self.line_host_game_port.setText(str(5555))
Exemplo n.º 13
0
    def __init__(self) -> None:
        """Inicialize."""

        super(NumberEdit, self).__init__()

        self.line_edit = QLineEdit(self)
        self.label_line_edit = QLabel(self)
        self.label_line_edit.setMinimumWidth(150)
        lay = QHBoxLayout(self)
        lay.addWidget(self.label_line_edit)
        lay.addWidget(self.line_edit)
        lay.setContentsMargins(0, 0, 0, 0)
        self.setLayout(lay)
        self.validator = QDoubleValidator()
        self.line_edit.setValidator(self.validator)
Exemplo n.º 14
0
class AttributeEntryCell (QLineEdit):
    selected = pyqtSignal([int, int])
    edited = pyqtSignal([int, int])
    edited_key = pyqtSignal([object, object])  # will be [list, self.type_]
    validators = {
            int: QIntValidator(),
            float: QDoubleValidator(),
            str: None,
            }

    def __init__(self, row, column, type_, key=None):
        super().__init__()
        self.row_ = row
        self.column_ = column
        self.type_ = type_
        self.key = key
        self.setValidator(self.validators[type_])
        self.setFrame(False)
        self.setAlignment(Qt.AlignCenter)
        self.editingFinished.connect(self.emit_edited)
        self.setAcceptDrops(True)

    def mousePressEvent(self, ev):
        self.select_all()

    def focusInEvent(self, ev):
        self.select_all()

    def select_all(self):
        self.selectAll()
        self.selected.emit(self.row_, self.column_)

    def emit_edited(self):
        self.edited.emit(self.row_, self.column_)
        self.edited_key.emit(self.key, self.type_(self.text()))

    def dragEnterEvent(self, event):
        if event.mimeData().hasText() and not event.mimeData().hasUrls():
            event.accept()
        else:
            event.ignore()

    def dropEvent(self, event):
        self.selectAll()
        self.insert(event.mimeData().text().strip())
        self.deselect()
        self.emit_edited()
Exemplo n.º 15
0
    def __init__(self):
        QDialog.__init__(self)
        self.setupUi(self)

        self.btnClose.clicked.connect(self.close)

        self.validator = QDoubleValidator()

        self.txtDestinos.setClearButtonEnabled(True)
        self.txtOrigenes.setClearButtonEnabled(True)

        self.txtDestinos.setValidator(QIntValidator())
        self.txtOrigenes.setValidator(QIntValidator())

        self.scrollContent.setLayout(self.gridData)

        self.txtOrigenes.textChanged['QString'].connect(self.generate_inputs)
        self.txtDestinos.textChanged['QString'].connect(self.generate_inputs)

        self.resize(720, 480)
Exemplo n.º 16
0
 def __init__(self, parent):
     LineEdit.__init__(self, parent)
     self.setValidator(QDoubleValidator())
     self.editComplete.connect(self._set_value)
     self.valueChanged.connect(self._set_text)
Exemplo n.º 17
0
    def __init__(self, window, grid, name, plugin_id, address):

        # Save the window data.
        self.address = address
        self.name = name
        self.plugin_id = plugin_id

        # Initialize this class.
        super(PluginSwitch, self).__init__()

        # Initialize a UDP socket for this plugin.
        self.udp_socket = socket(AF_INET, SOCK_DGRAM)

        # Set socket options.
        self.udp_socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        self.udp_socket.settimeout(WV_REQ_TIMEOUT)

        # Initialize a timer to query data for this plugin.
        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh)

        # Initialize update thread.
        self.refresh_thread = SwitchRefreshThread(self.plugin_id, self.address,
                                                  self.udp_socket)
        self.refresh_thread.start()

        # Connect the data signal.
        self.refresh_thread.data_signal.connect(self.do_update)

        # Initialize UI for this plugin.
        self.PluginName = QtWidgets.QLabel(window)
        self.PluginName.setText(name)
        grid.addWidget(self.PluginName, grid.rowCount(), 0)

        RefreshSpacer = QtWidgets.QSpacerItem(65535, 20,
                                              QtWidgets.QSizePolicy.Maximum,
                                              QtWidgets.QSizePolicy.Minimum)
        grid.addItem(RefreshSpacer, (grid.rowCount() - 1), 1)

        self.RefreshLable = QtWidgets.QLabel(window)
        self.RefreshLable.setText("Refresh Time (ms) :")
        grid.addWidget(self.RefreshLable, (grid.rowCount() - 1), 2)

        self.Refresh = QtWidgets.QLineEdit(window)
        self.Refresh.setValidator(QDoubleValidator(0, 999999, 2))
        self.Refresh.setMinimumWidth(50)
        self.Refresh.textChanged.connect(self.refersh_time_updated)
        self.Refresh.setText('500')
        grid.addWidget(self.Refresh, (grid.rowCount() - 1), 3)

        self.StateLable = QtWidgets.QLabel(window)
        self.StateLable.setText("Current State :")
        grid.addWidget(self.StateLable, grid.rowCount(), 0)

        self.State = QtWidgets.QLabel(window)
        self.State.setText("?")
        grid.addWidget(self.State, (grid.rowCount() - 1), 1)

        self.StateOn = QtWidgets.QPushButton(window)
        self.StateOn.setText("On")
        self.StateOn.clicked.connect(self.set_on)
        grid.addWidget(self.StateOn, (grid.rowCount() - 1), 2)

        self.StateOff = QtWidgets.QPushButton(window)
        self.StateOff.setText("Off")
        self.StateOff.clicked.connect(self.set_off)
        grid.addWidget(self.StateOff, (grid.rowCount() - 1), 3)
Exemplo n.º 18
0
    def __init__(self, window, grid, name, plugin_id, address):

        # Save the window data.
        self.address = address
        self.name = name
        self.plugin_id = plugin_id

        # Initialize this class.
        super(PluginAnalog, self).__init__()

        # Initialize a UDP socket for this plugin.
        self.udp_socket = socket(AF_INET, SOCK_DGRAM)

        # Set socket options.
        self.udp_socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        self.udp_socket.settimeout(WV_REQ_TIMEOUT)

        # Initialize a timer to query data for this plugin.
        self.timer = QTimer()
        self.timer.timeout.connect(self.refresh)

        # Initialize update thread.
        self.refresh_thread = AnalogRefreshThread(self.plugin_id, self.address,
                                                  self.udp_socket)
        self.refresh_thread.start()

        # Connect the data signal.
        self.refresh_thread.data_signal.connect(self.do_update)

        # Initialize UI for this plugin.
        self.PluginName = QtWidgets.QLabel(window)
        self.PluginName.setText(name)
        grid.addWidget(self.PluginName, grid.rowCount(), 0)

        RefreshSpacer = QtWidgets.QSpacerItem(65535, 20,
                                              QtWidgets.QSizePolicy.Maximum,
                                              QtWidgets.QSizePolicy.Minimum)
        grid.addItem(RefreshSpacer, (grid.rowCount() - 1), 1)

        self.RefreshLable = QtWidgets.QLabel(window)
        self.RefreshLable.setText("Refresh Time (ms) :")
        grid.addWidget(self.RefreshLable, (grid.rowCount() - 1), 2)

        self.Refresh = QtWidgets.QLineEdit(window)
        self.Refresh.setValidator(QDoubleValidator(0, 999999, 2))
        self.Refresh.setMinimumWidth(50)
        self.Refresh.textChanged.connect(self.refersh_time_updated)
        self.Refresh.setText('500')
        grid.addWidget(self.Refresh, (grid.rowCount() - 1), 3)

        self.AnalogDial = QtWidgets.QDial(window)
        self.AnalogDial.setNotchesVisible(True)
        self.AnalogDial.setEnabled(False)
        grid.addWidget(self.AnalogDial, grid.rowCount(), 2, 5, 1)

        self.AnalogMaxLable = QtWidgets.QLabel(window)
        self.AnalogMaxLable.setText("Max Value :")
        grid.addWidget(self.AnalogMaxLable, (grid.rowCount() - 2), 0)

        self.AnalogMax = QtWidgets.QLabel(window)
        self.AnalogMax.setText("?")
        grid.addWidget(self.AnalogMax, (grid.rowCount() - 2), 1)

        self.AnalogCurrentLable = QtWidgets.QLabel(window)
        self.AnalogCurrentLable.setText("Current Value :")
        grid.addWidget(self.AnalogCurrentLable, (grid.rowCount() - 1), 0)

        self.AnalogCurrent = QtWidgets.QLabel(window)
        self.AnalogCurrent.setText("?")
        grid.addWidget(self.AnalogCurrent, (grid.rowCount() - 1), 1)
Exemplo n.º 19
0
    def __init__(self, settings_dictionary):
        """
        Settings user interface (UI) constructor.

        Returns:
            QDialog (`obj`):     Settings ui object
        """
        super(SettingsDialog, self).__init__()
        uic.loadUi(resource_path(os.path.join('ui', 'setting_dialog.ui')),
                   self)
        self.setWindowTitle('pyIMD :: Settings')
        self.settingsIcon = QIcon()
        self.settingsIcon.addPixmap(
            self.style().standardPixmap(QStyle.SP_FileDialogDetailedView),
            QIcon.Disabled, QIcon.Off)
        self.setWindowIcon(self.settingsIcon)
        self.frequency_offset_spin.setMinimum(1)
        self.frequency_offset_spin.setMaximum(10**9)
        self.settings_dictionary = settings_dictionary

        # Establish connections
        self.defaultBtn.clicked.connect(self.set_defaults)
        self.commitBtn.clicked.connect(self.commit_parameters)
        self.cancelBtn.clicked.connect(self.close_settings_dialog)
        self.do_offset_corr_chkbox.clicked.connect(
            self.on_toggle_frequency_offset)
        self.offsetGroupBox.setEnabled(False)
        self.frequency_offset_edit.setEnabled(False)
        self.frequency_offset_mode_auto.setChecked(True)
        self.frequency_offset_mode_auto.toggled.connect(
            self.on_frequency_offset_mode_auto)
        self.frequency_offset_mode_manual.toggled.connect(
            self.on_frequency_offset_mode_manual)

        double_validator = QDoubleValidator()
        self.figure_width_edit.setValidator(double_validator)
        self.figure_width_edit.textChanged.connect(self.check_state)
        self.figure_height_edit.setValidator(double_validator)
        self.figure_height_edit.textChanged.connect(self.check_state)
        self.figure_resolution_edit.setValidator(double_validator)
        self.figure_resolution_edit.textChanged.connect(self.check_state)
        self.conversion_factor_hz_edit.setValidator(double_validator)
        self.conversion_factor_hz_edit.textChanged.connect(self.check_state)
        self.conversion_factor_deg_edit.setValidator(double_validator)
        self.conversion_factor_deg_edit.textChanged.connect(self.check_state)
        self.spring_constant_edit.setValidator(double_validator)
        self.spring_constant_edit.textChanged.connect(self.check_state)
        self.cantilever_length_edit.setValidator(double_validator)
        self.cantilever_length_edit.textChanged.connect(self.check_state)
        self.cell_position_edit.setValidator(double_validator)
        self.cell_position_edit.textChanged.connect(self.check_state)
        self.read_text_data_from_line_edit.setValidator(double_validator)
        self.read_text_data_from_line_edit.textChanged.connect(
            self.check_state)
        self.figure_plot_every_nth_point_edit.setValidator(double_validator)
        self.figure_plot_every_nth_point_edit.textChanged.connect(
            self.check_state)
        self.rolling_window_size_edit.setValidator(double_validator)
        self.rolling_window_size_edit.textChanged.connect(self.check_state)
        self.frequency_offset_edit.setValidator(double_validator)
        self.frequency_offset_edit.textChanged.connect(self.check_state)

        reg_ex = QRegExp("[0-9-a-z-A-Z_]+")
        self.figure_name_wo_cell_edit.setValidator(
            QRegExpValidator(reg_ex, self.figure_name_wo_cell_edit))
        self.figure_name_wo_cell_edit.textChanged.connect(self.check_state)
        self.figure_name_w_cell_edit.setValidator(
            QRegExpValidator(reg_ex, self.figure_name_w_cell_edit))
        self.figure_name_w_cell_edit.textChanged.connect(self.check_state)
        self.figure_name_data_edit.setValidator(
            QRegExpValidator(reg_ex, self.figure_name_data_edit))
        self.figure_name_data_edit.textChanged.connect(self.check_state)

        self.figure_unit_edit.setValidator(
            QRegExpValidator(QRegExp("[a-z-A-Z_]+"),
                             self.figure_name_wo_cell_edit))
        self.figure_unit_edit.textChanged.connect(self.check_state)

        self.figure_format_edit.setValidator(
            QRegExpValidator(QRegExp(".+[a-z-A-Z_]"),
                             self.figure_name_wo_cell_edit))
        self.figure_format_edit.textChanged.connect(self.check_state)
        self.text_data_delimiter_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\\{1}\w*)"),
                             self.text_data_delimiter_edit))
        self.text_data_delimiter_edit.textChanged.connect(self.check_state)

        self.intial_param_guess_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\[\d+.+,\s*)+\d+.+\\]{1}"),
                             self.intial_param_guess_edit))
        self.intial_param_guess_edit.textChanged.connect(self.check_state)

        self.lower_param_bound_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\[\d+.+,\s*)+\d+.+\\]{1}"),
                             self.lower_param_bound_edit))
        self.lower_param_bound_edit.textChanged.connect(self.check_state)

        self.upper_param_bound_edit.setValidator(
            QRegExpValidator(QRegExp("(?:\\[\d+.+,\s*)+\d+.+\\]{1}"),
                             self.upper_param_bound_edit))
        self.upper_param_bound_edit.textChanged.connect(self.check_state)
Exemplo n.º 20
0
    def initUI(self):
        self.container = QToolBox()
        self.setWidget(self.container)

        self.b_save_edit = QPushButton("Save current edit")
        self.b_save_edit.clicked.connect(self._applySaveEdit)
        self.container.addItem(OptionBox([self.b_save_edit]), "Save")

        self.tf_importance_point_count = QLineEdit()
        self.tf_importance_point_count.setPlaceholderText(
            "Number of Points to Sample")
        self.tf_importance_point_count.setValidator(
            QIntValidator(1, 1000000, self))
        self.b_importance_apply = QPushButton("Apply Sampling")
        self.b_importance_apply.clicked.connect(
            self._applyFaceImportanceSampling)
        self.container.addItem(
            OptionBox(
                [self.tf_importance_point_count, self.b_importance_apply]),
            "Importance Sampling (Mesh)")

        self.tf_poisson_point_count = QLineEdit()
        self.tf_poisson_point_count.setPlaceholderText(
            "Number of Points to Sample")
        self.tf_poisson_point_count.setValidator(
            QIntValidator(1, 1000000, self))
        self.tf_poisson_radius = QLineEdit()
        self.tf_poisson_radius.setPlaceholderText(
            "Radius of the poisson disks")
        self.tf_poisson_radius.setValidator(QDoubleValidator(
            0.0, 2.0, 5, self))
        self.b_poisson_apply = QPushButton("Apply Sampling")
        self.b_poisson_apply.clicked.connect(self._applyPoissonDiskSampling)
        self.container.addItem(
            OptionBox([
                self.tf_poisson_point_count, self.tf_poisson_radius,
                self.b_poisson_apply
            ]), "Poisson Sampling (Mesh)")

        self.tf_montecarlo_point_count = QLineEdit()
        self.tf_montecarlo_point_count.setPlaceholderText(
            "Number of Points to Sample")
        self.tf_montecarlo_point_count.setValidator(
            QIntValidator(1, 1000000, self))
        self.b_montecarlo_apply = QPushButton("Apply Sampling")
        self.b_montecarlo_apply.clicked.connect(self._applyMontecarloSampling)
        self.container.addItem(
            OptionBox(
                [self.tf_montecarlo_point_count, self.b_montecarlo_apply]),
            "Montecarlo Sampling (Mesh)")

        self.tf_centroid_count = QLineEdit()
        self.tf_centroid_count.setPlaceholderText("Centroid Count")
        self.tf_centroid_count.setValidator(QIntValidator(1, 1000000, self))
        self.b_show_centroids = QPushButton("Apply FPS")
        self.b_show_centroids.clicked.connect(self._applyFPS)
        self.container.addItem(
            OptionBox([self.tf_centroid_count, self.b_show_centroids]),
            "FPS Sampling (Point)")

        self.tf_show_pp2_centroids = QLineEdit()
        self.tf_show_pp2_centroids.setPlaceholderText("Number of Centroids")
        self.tf_show_pp2_centroids.setValidator(QIntValidator(
            1, 1000000, self))
        self.tf_show_pp2_centroids_with_ball = QLineEdit()
        self.tf_show_pp2_centroids_with_ball.setPlaceholderText(
            "Number of Centroids with plotted radius")
        self.tf_show_pp2_centroids_with_ball.setValidator(
            QIntValidator(1, 1000000, self))
        self.tf_show_pp2_radius = QLineEdit()
        self.tf_show_pp2_radius.setPlaceholderText(
            "Radius of the neighbour area")
        self.tf_show_pp2_radius.setValidator(
            QDoubleValidator(0.0, 2.0, 5, self))
        self.b_show_pp2_step = QPushButton("Apply Sampling")
        self.b_show_pp2_step.clicked.connect(self._show_pp2_step)
        self.container.addItem(
            OptionBox([
                self.tf_show_pp2_centroids,
                self.tf_show_pp2_centroids_with_ball, self.tf_show_pp2_radius,
                self.b_show_pp2_step
            ]), "Show PointNet2 sampling")
Exemplo n.º 21
0
    def generate_inputs(self):

        if self.txtOrigenes.text() == '' or self.txtDestinos.text() == '':
            self.n_destinos = 0
            self.n_origenes = 0
        else:
            self.n_origenes = int(self.txtOrigenes.text()) + 2
            self.n_destinos = int(self.txtDestinos.text()) + 2

        i = 1

        for origen in range(self.n_origenes):

            for destino in range(self.n_destinos):

                if origen == 0 and destino == 0:

                    label = QLabel("Origen\\Destino")
                    self.gridData.addWidget(label, origen, destino)

                elif origen == 0 and destino != self.n_destinos - 1:

                    input_ = QLineEdit()
                    input_.setPlaceholderText("Destino " + str(destino))
                    self.gridData.addWidget(input_, origen, destino)

                elif origen == 0 and destino == self.n_destinos - 1:

                    label = QLabel("Oferta")
                    self.gridData.addWidget(label, origen, destino)

                elif origen != self.n_origenes - 1 and destino == 0:

                    input_ = QLineEdit()
                    input_.setPlaceholderText("Origen " + str(origen))
                    self.gridData.addWidget(input_, origen, destino)

                elif origen == self.n_origenes - 1 and destino == 0:

                    label = QLabel("Demanda")
                    self.gridData.addWidget(label, origen, destino)

                elif origen == self.n_origenes - 1 and destino < self.n_destinos - 1:

                    input_ = QLineEdit()
                    input_.setValidator(QDoubleValidator())
                    input_.setPlaceholderText("Demanda " + str(destino))
                    self.gridData.addWidget(input_, origen, destino)

                elif origen > 0 and origen < self.n_origenes - 1 and destino == self.n_destinos - 1:

                    input_ = QLineEdit()
                    input_.setValidator(QDoubleValidator())
                    input_.setPlaceholderText("Oferta " + str(origen))
                    self.gridData.addWidget(input_, origen, destino)

                elif origen > 0 and origen < self.n_origenes - 1 and destino > 0 and destino < self.n_destinos - 1:

                    input_ = QLineEdit()
                    input_.setValidator(QDoubleValidator())
                    input_.setPlaceholderText("costo " + str(i))
                    self.gridData.addWidget(input_, origen, destino)

                    i += 1
Exemplo n.º 22
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.model = None
     self._model_dir = None
     self.setModal(modal)
     self.setWindowTitle("Convert sources to FITS brick")
     lo = QVBoxLayout(self)
     lo.setContentsMargins(10, 10, 10, 10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="FITS filename:",
                               dialog_label="Output FITS file",
                               default_suffix="fits",
                               file_types="FITS files (*.fits *.FITS)",
                               file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile)
     # reference frequency
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     label = QLabel("Frequency, MHz:", self)
     lo1.addWidget(label)
     tip = """<P>If your sky model contains spectral information (such as spectral indices), then a brick may be generated
 for a specific frequency. If a frequency is not specified here, the reference frequency of the model sources will be assumed.</P>"""
     self.wfreq = QLineEdit(self)
     self.wfreq.setValidator(QDoubleValidator(self))
     label.setToolTip(tip)
     self.wfreq.setToolTip(tip)
     lo1.addWidget(self.wfreq)
     # beam gain
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.wpb_apply = QCheckBox("Apply primary beam expression:", self)
     self.wpb_apply.setChecked(True)
     lo1.addWidget(self.wpb_apply)
     tip = """<P>If this option is specified, a primary power beam gain will be applied to the sources before inserting
 them into the brick. This can be any valid Python expression making use of the variables 'r' (corresponding
 to distance from field centre, in radians) and 'fq' (corresponding to frequency.)</P>"""
     self.wpb_exp = QLineEdit(self)
     self.wpb_apply.setToolTip(tip)
     self.wpb_exp.setToolTip(tip)
     lo1.addWidget(self.wpb_exp)
     # overwrite or add mode
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.woverwrite = QRadioButton("overwrite image", self)
     self.woverwrite.setChecked(True)
     lo1.addWidget(self.woverwrite)
     self.waddinto = QRadioButton("add into image", self)
     lo1.addWidget(self.waddinto)
     # add to model
     self.wadd = QCheckBox(
         "Add resulting brick to sky model as a FITS image component", self)
     lo.addWidget(self.wadd)
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.wpad = QLineEdit(self)
     self.wpad.setValidator(QDoubleValidator(self))
     self.wpad.setText("1.1")
     lab = QLabel("...with padding factor:", self)
     lab.setToolTip(
         """<P>The padding factor determines the amount of null padding inserted around the image during
   the prediction stage. Padding alleviates the effects of tapering and detapering in the uv-brick, which can show
   up towards the edges of the image. For a factor of N, the image will be padded out to N times its original size.
   This increases memory use, so if you have no flux at the edges of the image anyway, then a pad factor of 1 is
   perfectly fine.</P>""")
     self.wpad.setToolTip(lab.toolTip())
     self.wadd.toggled[bool].connect(self.wpad.setEnabled)
     self.wadd.toggled[bool].connect(lab.setEnabled)
     self.wpad.setEnabled(False)
     lab.setEnabled(False)
     lo1.addStretch(1)
     lo1.addWidget(lab, 0)
     lo1.addWidget(self.wpad, 1)
     self.wdel = QCheckBox(
         "Remove from the sky model sources that go into the brick", self)
     lo.addWidget(self.wdel)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(5, 5, 5, 5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     self.wokbtn.clicked.connect(self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     cancelbtn.clicked.connect(self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     self.wfile.filenameSelected.connect(self._fileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
class DmsHandler(QObject):

    inputDidChange = pyqtSignal()

    def __init__(self, degField, minField, secField, maxDegrees):
        super(DmsHandler, self).__init__()

        # init validators:
        self.intDegValidator = QIntValidator(0, maxDegrees, parent=self)
        self.minValidator = QIntValidator(0, 59, parent=self)

        self.secValidator = QDoubleValidator(0.0, 59.999, 3, parent=self)
        self.secValidator.setNotation(QDoubleValidator.StandardNotation)

        self._degField = degField
        self._minField = minField
        self._secField = secField

        self._maxDegrees = maxDegrees

        self._degFieldIncrementor = ValueIncrementor(self._degField,
                                                     maxDegrees,
                                                     doOverflow=False)
        self._degFieldIncrementor.fieldDidOverflow.connect(
            self.fieldDidOverflow)
        self._degField.setValidator(self.intDegValidator)
        self._degField.textEdited.connect(self.inputDidChange.emit)

        self._minFieldIncrementor = ValueIncrementor(
            self._minField, 59, wrapCallback=self.isWrapAllowedFor)
        self._minFieldIncrementor.fieldDidOverflow.connect(
            self.fieldDidOverflow)
        self._minField.setValidator(self.minValidator)
        self._minField.textChanged.connect(
            partial(self.minorFieldDidChange, self._minField))

        self._secFieldIncrementor = ValueIncrementor(
            self._secField, 59, wrapCallback=self.isWrapAllowedFor)
        self._secFieldIncrementor.fieldDidOverflow.connect(
            self.fieldDidOverflow)
        self._secField.setValidator(self.secValidator)
        self._secField.textChanged.connect(
            partial(self.minorFieldDidChange, self._secField))

    def fieldDidOverflow(self, field, overflow):
        if field == self._minField:
            self._degFieldIncrementor.doStepwiseIncrement(overflow)
        elif field == self._secField:
            self._minFieldIncrementor.doStepwiseIncrement(overflow)

    def minorFieldDidChange(self, field):
        degrees = QLocale().toInt(self._degField.text())[0]
        if degrees == self._maxDegrees:
            field.setText("0")

        self.inputDidChange.emit()

    def isWrapAllowedFor(self, field, direction):
        if (field == self._minField):
            degrees = QLocale().toInt(self._degField.text())[0]
            res = degrees + direction
            return 0 <= res <= self._maxDegrees
        elif (field == self._secField):
            minutes = QLocale().toInt(self._minField.text())[0]
            res = minutes + direction
            if not (0 <= res < 60):
                return self.isWrapAllowedFor(self._minField, direction)
            else:
                return True
        elif (field == self._degField):
            degrees = QLocale().toInt(self._degField.text())[0]
            res = degrees + direction
            return 0 <= res <= self._maxDegrees

        return True
Exemplo n.º 24
0
    def BuildWindowLayout(self):
        self.rootGridLayout = QtGui.QGridLayout()
        self.rootGridLayout.setContentsMargins(0, 0, 0, 0)    
        self.mainGridLayout1 = QtGui.QGridLayout()
        self.mainGridLayout1.setContentsMargins(0, 0, 0, 0)
        self.mainGridLayout2 = QtGui.QGridLayout()
        self.mainGridLayout2.setContentsMargins(0, 0, 0, 0)        
        self.setLayout(self.rootGridLayout)
        self.rootGridLayout.addLayout(self.mainGridLayout1, 1, 1)
        self.rootGridLayout.addLayout(self.mainGridLayout2, 3, 1)
        self.mainGridLayout1.setColumnStretch(0, 2)
        self.mainGridLayout1.setColumnStretch(1, 1)
        self.mainGridLayout2.setColumnStretch(0, 2)
        self.mainGridLayout2.setColumnStretch(1, 1)
        rowNumber = 0
        
        # Root left and right
        self.rootLeftBlock = QtGui.QWidget()
        self.rootLeftBlock.setStyleSheet(self.STR_BORDER_BLOCK_STYLESHEET)
        self.rootLeftBlock.setFixedWidth(20)
        self.rootRightBlock = QtGui.QWidget()
        self.rootRightBlock.setStyleSheet(self.STR_BORDER_BLOCK_STYLESHEET)
        self.rootRightBlock.setFixedWidth(20)
        self.rootGridLayout.addWidget(self.rootLeftBlock, 0, 0, 5, 1)
        self.rootGridLayout.addWidget(self.rootRightBlock, 0, 3, 5, 1)
        
        # Root top and bottom
        self.rootTopBlock = QtGui.QWidget()
        self.rootTopBlock.setStyleSheet(self.STR_BORDER_BLOCK_STYLESHEET)
        self.rootTopBlock.setFixedHeight(20)
        self.rootBottomBlock = QtGui.QWidget()
        self.rootBottomBlock.setStyleSheet(self.STR_BORDER_BLOCK_STYLESHEET)
        self.rootBottomBlock.setFixedHeight(60)
        self.rootGridLayout.addWidget(self.rootTopBlock, 0, 0, 1, 4)
        self.rootGridLayout.addWidget(self.rootBottomBlock, 4, 0, 1, 4)
        
        # Reuse ============================================================================
        self.SeparatorLine = QtGui.QWidget()
        self.SeparatorLine.setStyleSheet(self.STR_BORDER_BLOCK_STYLESHEET)
        self.SeparatorLine.setFixedHeight(15)
        self.SeparatorLine2 = QtGui.QWidget()
        self.SeparatorLine2.setStyleSheet(self.STR_BORDER_BLOCK_STYLESHEET)
        self.SeparatorLine2.setFixedHeight(15)
        
        # Trading Account layout ===========================================================
        self.lblTitleTradingAccount = QtGui.QLabel("Coinbase Pro Connexion parameters")
        self.lblTitleTradingAccount.setStyleSheet(self.STR_QLABEL_TITLE_STYLESHEET);
        self.mainGridLayout1.addWidget(self.lblTitleTradingAccount, rowNumber, 0)
        rowNumber += 1
        
        # API Key
        self.lblAPIKey = QtGui.QLabel("API Key:")
        self.lblAPIKey.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblAPIKey.setFixedHeight(30)
        self.lblAPIKey.setContentsMargins(20,0,0,0)
        self.mainGridLayout1.addWidget(self.lblAPIKey, rowNumber, 0)
        self.txtAPIKey = QtGui.QLineEdit()
        self.txtAPIKey.setStyleSheet(self.STR_QTEXTEDIT_STYLESHEET)
        self.mainGridLayout1.addWidget(self.txtAPIKey, rowNumber, 1)
        rowNumber += 1
        
        # Secret Key
        self.lblSecretKey = QtGui.QLabel("Secret Key:")
        self.lblSecretKey.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblSecretKey.setFixedHeight(30)
        self.lblSecretKey.setContentsMargins(20,0,0,0)
        self.mainGridLayout1.addWidget(self.lblSecretKey, rowNumber, 0)
        self.txtSecretKey = QtGui.QLineEdit()
        self.txtSecretKey.setStyleSheet(self.STR_QTEXTEDIT_STYLESHEET)
        self.txtSecretKey.setEchoMode(QtGui.QLineEdit.Password)
        self.mainGridLayout1.addWidget(self.txtSecretKey, rowNumber, 1)
        rowNumber += 1
        
        # Passphrase
        self.lblPassPhrase = QtGui.QLabel("Passphrase:")
        self.lblPassPhrase.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblPassPhrase.setFixedHeight(30)
        self.lblPassPhrase.setContentsMargins(20,0,0,0)
        self.mainGridLayout1.addWidget(self.lblPassPhrase, rowNumber, 0)
        self.txtPassPhrase = QtGui.QLineEdit()
        self.txtPassPhrase.setStyleSheet(self.STR_QTEXTEDIT_STYLESHEET)
        self.txtPassPhrase.setEchoMode(QtGui.QLineEdit.Password)
        self.mainGridLayout1.addWidget(self.txtPassPhrase, rowNumber, 1)
        rowNumber += 1

        # Authorization checkbox
        self.lblPermissions = QtGui.QLabel("Note: Make sure you enabled the <b>View</b> and <b>Trade</b> permissions when creating your API keys on your Coinbase Pro profile. These permissions are required for Astibot to operate.")
        self.lblPermissions.setWordWrap(True)
        self.lblPermissions.setStyleSheet(self.STR_QLABEL_NOTE_STYLESHEET);
        self.lblAuthorization = QtGui.QLabel(self.STR_CHECKBOX_AUTHORIZATION_TEXT)
        self.lblAuthorization.setStyleSheet(self.STR_QCHECKBOX_LABEL_STYLESHEET)
        self.lblAuthorization.setWordWrap(True)

        self.mainGridLayout1.addWidget(self.lblPermissions, rowNumber, 0, 1, 2)
        rowNumber += 1
        self.mainGridLayout1.addWidget(self.lblAuthorization, rowNumber, 0, 1, 2)
        rowNumber += 1

        # Separator
        self.rootGridLayout.addWidget(self.SeparatorLine, 2, 0, 1, 4)
        rowNumber = 0
        
        # Trading Parameters layout ========================================================
        self.lblTitleTradingParameters = QtGui.QLabel("Trading parameters")
        self.lblTitleTradingParameters.setStyleSheet(self.STR_QLABEL_TITLE_STYLESHEET);
        self.mainGridLayout2.addWidget(self.lblTitleTradingParameters, rowNumber, 0)
        rowNumber += 1

        # Trading pair
        self.lblTradingPair = QtGui.QLabel("Trading pair:")
        self.lblTradingPair.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblTradingPair.setFixedHeight(30)
        self.lblTradingPair.setContentsMargins(20,0,0,0)
        self.mainGridLayout2.addWidget(self.lblTradingPair, rowNumber, 0)
        self.comboTradingPair = QtGui.QComboBox()
        self.comboTradingPair.setView(QtGui.QListView())    # Necessary to allow height change

        for pair in self.pairs:
            self.comboTradingPair.addItem(pair)

        self.comboTradingPair.currentIndexChanged.connect(self.EventComboTradingPairChanged)
        self.comboTradingPair.setStyleSheet(self.STR_COMBO_STYLESHEET)
        self.mainGridLayout2.addWidget(self.comboTradingPair, rowNumber, 1)
        rowNumber += 1
        
        # Fiat amount to invest
        self.lblFiatPercentageToInvest = QtGui.QLabel("Percentage of " + self.theSettings.SETT_GetSettings()["strFiatType"] + " account balance to invest in trades:")
        self.lblFiatPercentageToInvest.setStyleSheet(self.STR_QLABEL_STYLESHEET)
        self.lblFiatPercentageToInvest.setFixedHeight(30)
        self.lblFiatPercentageToInvest.setContentsMargins(20,0,0,0)
        self.mainGridLayout2.addWidget(self.lblFiatPercentageToInvest, rowNumber, 0)
        self.hBoxFiatAmount = QtGui.QHBoxLayout()
        self.sliderFiatAmount = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.sliderFiatAmount.setMinimum(1)
        self.sliderFiatAmount.setMaximum(99)
        self.sliderFiatAmount.setValue(50)
        self.sliderFiatAmount.setStyleSheet(self.STR_QSLIDER_STYLESHEET)
        self.sliderFiatAmount.valueChanged.connect(self.EventMovedSliderFiatAmountInvest)
        self.lblFiatAmountValue = QtGui.QLabel("90 %")
        self.lblFiatAmountValue.setStyleSheet(self.STR_QLABEL_STYLESHEET)
        self.lblFiatAmountValue.setFixedWidth(self.RIGHT_LABELS_WIDTH_IN_PX)
        self.hBoxFiatAmount.addWidget(self.sliderFiatAmount)
        self.hBoxFiatAmount.addWidget(self.lblFiatAmountValue)
        self.mainGridLayout2.addLayout(self.hBoxFiatAmount, rowNumber, 1)
        rowNumber += 1
    
        # Coinbase Pro Taker fee
        self.lblTakerFee = QtGui.QLabel("Coinbase Pro Taker and Maker order fee:")
        self.lblTakerFee.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblTakerFee.setFixedHeight(30)
        self.lblTakerFee.setContentsMargins(20,0,0,0)
        self.mainGridLayout2.addWidget(self.lblTakerFee, rowNumber, 0)
        self.sliderTakerFee = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.sliderTakerFee.setMinimum(theConfig.CONFIG_PLATFORM_TAKER_FEE_MIN_ON_SLIDER)
        self.sliderTakerFee.setMaximum(theConfig.CONFIG_PLATFORM_TAKER_FEE_MAX_ON_SLIDER)
        self.sliderTakerFee.setSingleStep(1)
        self.sliderTakerFee.setValue(theConfig.CONFIG_PLATFORM_TAKER_FEE_DEFAULT_VALUE)
        self.sliderTakerFee.setStyleSheet(self.STR_QSLIDER_STYLESHEET)
        self.sliderTakerFee.valueChanged.connect(self.EventMovedSliderTakerFee)
        self.lblTakerFeePercent = QtGui.QLabel("%")
        self.lblTakerFeePercent.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblTakerFeePercent.setFixedWidth(self.RIGHT_LABELS_WIDTH_IN_PX)
        self.hBoxTakerFee = QtGui.QHBoxLayout()
        self.hBoxTakerFee.addWidget(self.sliderTakerFee)
        self.hBoxTakerFee.addWidget(self.lblTakerFeePercent)
        self.mainGridLayout2.addLayout(self.hBoxTakerFee, rowNumber, 1)
        rowNumber += 1
        
        # Sell trigger
        self.lblSellTrigger = QtGui.QLabel("Auto-Sell trigger (% above buy price, set 0 to disable):")
        self.lblSellTrigger.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblSellTrigger.setFixedHeight(30)
        self.lblSellTrigger.setContentsMargins(20,0,0,0)
        self.mainGridLayout2.addWidget(self.lblSellTrigger, rowNumber, 0)
        self.sliderSellTrigger = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.sliderSellTrigger.setMinimum(theConfig.CONFIG_SELL_TRIGGER_PERCENTAGE_MIN_ON_SLIDER)
        self.sliderSellTrigger.setMaximum(theConfig.CONFIG_SELL_TRIGGER_PERCENTAGE_MAX_ON_SLIDER)
        self.sliderSellTrigger.setSingleStep(1)
        self.sliderSellTrigger.setValue(theConfig.CONFIG_SELL_TRIGGER_PERCENTAGE_DEFAULT_VALUE)
        self.sliderSellTrigger.setStyleSheet(self.STR_QSLIDER_STYLESHEET)
        self.sliderSellTrigger.valueChanged.connect(self.EventMovedSliderSellTrigger)
        self.lblSellTriggerPercent = QtGui.QLabel("%")
        self.lblSellTriggerPercent.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblSellTriggerPercent.setFixedWidth(self.RIGHT_LABELS_WIDTH_IN_PX)
        self.hBoxSellTrigger = QtGui.QHBoxLayout()
        self.hBoxSellTrigger.addWidget(self.sliderSellTrigger)
        self.hBoxSellTrigger.addWidget(self.lblSellTriggerPercent)
        self.mainGridLayout2.addLayout(self.hBoxSellTrigger, rowNumber, 1)
        rowNumber += 1
        
        # Auto-sell by percentage threshold
        self.lblAutoSellThreshold = QtGui.QLabel("Stop-loss trigger (% below buy price, set 0 to disable):")
        self.lblAutoSellThreshold.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblAutoSellThreshold.setFixedHeight(30)
        self.lblAutoSellThreshold.setContentsMargins(20,0,0,0)
        self.mainGridLayout2.addWidget(self.lblAutoSellThreshold, rowNumber, 0)
        self.sliderAutoSellThreshold = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.sliderAutoSellThreshold.setMinimum(theConfig.CONFIG_PLATFORM_AUTO_SELL_THRESHOLD_MIN_ON_SLIDER)
        self.sliderAutoSellThreshold.setMaximum(theConfig.CONFIG_PLATFORM_AUTO_SELL_THRESHOLD_MAX_ON_SLIDER)
        self.sliderAutoSellThreshold.setSingleStep(1)
        self.sliderAutoSellThreshold.setValue(theConfig.CONFIG_PLATFORM_AUTO_SELL_THRESHOLD_DEFAULT_VALUE)
        self.sliderAutoSellThreshold.setStyleSheet(self.STR_QSLIDER_STYLESHEET)
        self.sliderAutoSellThreshold.valueChanged.connect(self.EventMovedSliderAutoSell)
        self.lblAutoSellPercent = QtGui.QLabel("%")
        self.lblAutoSellPercent.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblAutoSellPercent.setFixedWidth(self.RIGHT_LABELS_WIDTH_IN_PX)
        self.hBoxAutoSell = QtGui.QHBoxLayout()
        self.hBoxAutoSell.addWidget(self.sliderAutoSellThreshold)
        self.hBoxAutoSell.addWidget(self.lblAutoSellPercent)
        self.mainGridLayout2.addLayout(self.hBoxAutoSell, rowNumber, 1)
        rowNumber += 1
        
        # Simulated fiat account balance
        self.lblSimulatedFiatBalance = QtGui.QLabel("Simulated fiat account balance (simulation mode only):")
        self.lblSimulatedFiatBalance.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblSimulatedFiatBalance.setFixedHeight(30)
        self.lblSimulatedFiatBalance.setContentsMargins(20,0,0,0)
        self.mainGridLayout2.addWidget(self.lblSimulatedFiatBalance, rowNumber, 0)
        self.txtSimulatedFiatBalance = QtGui.QLineEdit()
        self.txtSimulatedFiatBalance.setStyleSheet(self.STR_QTEXTEDIT_STYLESHEET)
        self.txtSimulatedFiatBalance.setFixedWidth(80)
        self.txtSimulatedFiatBalance.setValidator(QDoubleValidator())
        self.lblSimulatedFiatBalance = QtGui.QLabel(self.theSettings.SETT_GetSettings()["strFiatType"])
        self.lblSimulatedFiatBalance.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblSimulatedFiatBalance.setFixedWidth(self.RIGHT_LABELS_WIDTH_IN_PX)
        self.hBoxSimulatedFiatBalance = QtGui.QHBoxLayout()
        self.hBoxSimulatedFiatBalance.addWidget(self.txtSimulatedFiatBalance, QtCore.Qt.AlignLeft)
        self.hBoxSimulatedFiatBalance.addWidget(self.lblSimulatedFiatBalance, QtCore.Qt.AlignLeft)
        self.mainGridLayout2.addLayout(self.hBoxSimulatedFiatBalance, rowNumber, 1, QtCore.Qt.AlignLeft)
        rowNumber += 1
        
        # Simulation speed
        self.lblSimulationSpeed = QtGui.QLabel("Simulation speed (simulation mode only):")
        self.lblSimulationSpeed.setStyleSheet(self.STR_QLABEL_STYLESHEET)
        self.lblSimulationSpeed.setFixedHeight(30)
        self.lblSimulationSpeed.setContentsMargins(20, 0, 0, 0)
        self.mainGridLayout2.addWidget(self.lblSimulationSpeed, rowNumber, 0)
        self.sliderSimulationSpeed = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.sliderSimulationSpeed.setMinimum(0)
        self.sliderSimulationSpeed.setMaximum(100)
        self.sliderSimulationSpeed.setValue(50)
        self.sliderSimulationSpeed.setStyleSheet(self.STR_QSLIDER_STYLESHEET)
        self.sliderSimulationSpeed.valueChanged.connect(self.EventMovedSliderSimulationSpeed)
        self.lblSlow = QtGui.QLabel("Slow")
        self.lblSlow.setStyleSheet(self.STR_QLABEL_STYLESHEET)
        self.lblFast = QtGui.QLabel("Fast")
        self.lblFast.setStyleSheet(self.STR_QLABEL_STYLESHEET)
        self.lblFast.setFixedWidth(self.RIGHT_LABELS_WIDTH_IN_PX)
        self.hBoxSimulationSpeed = QtGui.QHBoxLayout()
        self.hBoxSimulationSpeed.addWidget(self.lblSlow)
        self.hBoxSimulationSpeed.addWidget(self.sliderSimulationSpeed)
        self.hBoxSimulationSpeed.addWidget(self.lblFast, QtCore.Qt.AlignLeft)
        self.mainGridLayout2.addLayout(self.hBoxSimulationSpeed, rowNumber, 1)
        rowNumber += 1
        
        # Simulation time range
        self.lblSimulationTimeRange = QtGui.QLabel("Simulation time range (simulation mode only):")
        self.lblSimulationTimeRange.setFixedHeight(30)
        self.lblSimulationTimeRange.setStyleSheet(self.STR_QLABEL_STYLESHEET);
        self.lblSimulationTimeRange.setContentsMargins(20, 0, 0, 0)
        self.mainGridLayout2.addWidget(self.lblSimulationTimeRange, rowNumber, 0)
        self.comboSimulationTimeRange = QtGui.QComboBox()
        self.comboSimulationTimeRange.setView(QtGui.QListView()) # Necessary to allow height change
        self.comboSimulationTimeRange.addItem("Last 24h")
        self.comboSimulationTimeRange.addItem("Last 48h")
        self.comboSimulationTimeRange.addItem("Last 72h")
        self.comboSimulationTimeRange.addItem("Last Week")
        self.comboSimulationTimeRange.setStyleSheet(self.STR_COMBO_STYLESHEET)
        self.comboSimulationTimeRange.currentIndexChanged.connect(self.EventComboSimulationTimeRange)
        self.mainGridLayout2.addWidget(self.comboSimulationTimeRange, rowNumber, 1)
        rowNumber += 1
        
        # Bottom buttons
        self.btnCancel = QtGui.QPushButton("Cancel")
        self.btnCancel.setStyleSheet(self.STR_QBUTTON_CANCEL_STYLESHEET)
        self.btnCancel.setFixedWidth(120)
        self.btnCancel.setFixedHeight(38)
        self.btnCancel.clicked.connect(self.EventCancelButtonClick)
        self.btnCancel.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.btnApply = QtGui.QPushButton("Apply and Close")
        self.btnApply.setStyleSheet(self.STR_QBUTTON_APPLY_STYLESHEET)
        self.btnApply.setFixedWidth(140)
        self.btnApply.setFixedHeight(38)
        self.btnApply.clicked.connect(self.EventApplylButtonClick)
        self.btnApply.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.hBoxBottomButtons = QtGui.QHBoxLayout()
        self.hBoxBottomButtons.addWidget(self.btnCancel, QtCore.Qt.AlignRight)
        self.hBoxBottomButtons.addWidget(self.btnApply, QtCore.Qt.AlignRight)
        self.rootBottomBlock.setLayout(self.hBoxBottomButtons)
        rowNumber += 1
Exemplo n.º 25
0
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.model = None
     self.setModal(modal)
     self.setWindowTitle("Restore model into image")
     lo = QVBoxLayout(self)
     lo.setContentsMargins(10, 10, 10, 10)
     lo.setSpacing(5)
     # file selector
     self.wfile_in = FileSelector(self,
                                  label="Input FITS file:",
                                  dialog_label="Input FITS file",
                                  default_suffix="fits",
                                  file_types="FITS files (*.fits *.FITS)",
                                  file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile_in)
     self.wfile_out = FileSelector(self,
                                   label="Output FITS file:",
                                   dialog_label="Output FITS file",
                                   default_suffix="fits",
                                   file_types="FITS files (*.fits *.FITS)",
                                   file_mode=QFileDialog.AnyFile)
     lo.addWidget(self.wfile_out)
     # beam size
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     lo1.addWidget(QLabel("Restoring beam FWHM, major axis:", self))
     self.wbmaj = QLineEdit(self)
     lo1.addWidget(self.wbmaj)
     lo1.addWidget(QLabel("\"     minor axis:", self))
     self.wbmin = QLineEdit(self)
     lo1.addWidget(self.wbmin)
     lo1.addWidget(QLabel("\"     P.A.:", self))
     self.wbpa = QLineEdit(self)
     lo1.addWidget(self.wbpa)
     lo1.addWidget(QLabel("\u00B0", self))
     for w in self.wbmaj, self.wbmin, self.wbpa:
         w.setValidator(QDoubleValidator(self))
     lo1 = QHBoxLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     self.wfile_psf = FileSelector(
         self,
         label="Set restoring beam by fitting PSF image:",
         dialog_label="PSF FITS file",
         default_suffix="fits",
         file_types="FITS files (*.fits *.FITS)",
         file_mode=QFileDialog.ExistingFile)
     lo1.addSpacing(32)
     lo1.addWidget(self.wfile_psf)
     # selection only
     self.wselonly = QCheckBox("restore selected model sources only", self)
     lo.addWidget(self.wselonly)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setContentsMargins(5, 5, 5, 5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     self.wokbtn.clicked.connect(self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     cancelbtn.clicked.connect(self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     self.wfile_in.filenameSelected.connect(self._fileSelected)
     self.wfile_in.filenameSelected.connect(self._inputFileSelected)
     self.wfile_out.filenameSelected.connect(self._fileSelected)
     self.wfile_psf.filenameSelected.connect(self._psfFileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)
class CoordinatorDockWidget(QtWidgets.QDockWidget, FORM_CLASS):

    SectionInput = 1
    SectionOutput = 2
    SectionBoth = 3

    SideRight = 1
    SideLeft = 2
    SideBoth = 3

    closingPlugin = pyqtSignal()

    inputChanged = pyqtSignal()
    mapConnectionChanged = pyqtSignal(int, bool)

    def __init__(self, parent=None):
        """Constructor."""
        super(CoordinatorDockWidget, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect

        self.decDegreeValidator = QDoubleValidator(0.0, 180.0, 8, parent=self)
        self.decDegreeValidator.setNotation(QDoubleValidator.StandardNotation)

        self.projectedValidator = QDoubleValidator(-999999999.0,
                                                   999999999.0,
                                                   4,
                                                   parent=self)

        self._eastingLeftNorthingRight = True

        self._eastingInverted = False
        self._northingInverted = False

        self.sectionIsGeographic = {
            CoordinatorDockWidget.SectionInput: True,
            CoordinatorDockWidget.SectionOutput: True
        }

        self.setupUi(self)

        # setup some lists of the input for easier access later
        self._widgetlistInputDms = [
            self.inLeft, self.inRight, self.inLeftSec, self.inRightSec,
            self.inLeftMin, self.inRightMin
        ]
        self._widgetlistInput = self._widgetlistInputDms + [
            self.inLeftDec, self.inRightDec
        ]

        self.resetInterface()
        self.setupInternal()

        # need to init that after setupUi because of message icon label size
        messageIconWidgetSize = self.messageIcon.size()
        messageIconSize = QSize(messageIconWidgetSize.width() - 2,
                                messageIconWidgetSize.height() - 2)
        self.warningPixmap = QIcon(
            ':/plugins/coordinator/icons/warning.svg').pixmap(messageIconSize)

        self.messageHideTimer = QTimer(parent=self)
        self.messageHideTimer.setSingleShot(True)
        self.messageHideTimer.timeout.connect(self.hideMessages)

    def setupInternal(self):
        self.leftDecimal.hide()
        self.rightDecimal.hide()

        self.leftDmsDisplay = DmsHandler(self.inLeft, self.inLeftMin,
                                         self.inLeftSec, 180)
        self.leftDmsDisplay.inputDidChange.connect(
            self.__inputFieldsChangedInternal)
        self.rightDmsDisplay = DmsHandler(self.inRight, self.inRightMin,
                                          self.inRightSec, 90)
        self.rightDmsDisplay.inputDidChange.connect(
            self.__inputFieldsChangedInternal)

        for dirButton in [self.leftDirButton, self.rightDirButton]:
            # see https://stackoverflow.com/questions/4578861/connecting-slots-and-signals-in-pyqt4-in-a-loop
            dirButton.clicked.connect(
                partial(self.toggleCardinalDirectionButton, dirButton))

        for inputField in self._widgetlistInputDms:
            inputField.installEventFilter(self)

        for inputField in [self.inLeftDec, self.inRightDec]:
            inputField.textEdited.connect(self.__inputFieldsChangedInternal)
            inputField.setValidator(self.decDegreeValidator)
            inputField.installEventFilter(self)

        self.leftDecIncrementor = ValueIncrementor(self.inLeftDec, 180, -180)
        self.rightDecIncrementor = ValueIncrementor(self.inLeftDec, 90, -90)

        self.outputCrsConn.clicked.connect(
            partial(self.toggledMapConnection,
                    CoordinatorDockWidget.SectionOutput))

        self.copyLeft.clicked.connect(
            partial(self.copyResultToClipBoard,
                    CoordinatorDockWidget.SideLeft))
        self.copyRight.clicked.connect(
            partial(self.copyResultToClipBoard,
                    CoordinatorDockWidget.SideRight))
        self.copyResultComplete.clicked.connect(
            partial(self.copyResultToClipBoard,
                    CoordinatorDockWidget.SideBoth))
        self.clearInput.clicked.connect(
            partial(self.resetInterface, self.SectionBoth))
        self.showHelp.clicked.connect(self.showHelpButtonClicked)

    def _setToolsEnabled(self, enabled, section=None):
        if (section == None): section = self.SectionBoth

        if (section & self.SectionInput):
            self.moveCanvas.setEnabled(enabled)

        if (section & self.SectionOutput):
            for widget in [
                    self.copyResultComplete, self.copyLeft, self.copyRight
            ]:
                widget.setEnabled(enabled)

    def resetInterface(self, section=None):
        if section == None: section = self.SectionBoth
        self.clearSection(section)
        self._setToolsEnabled(False, section)

    def eventFilter(self, obj, event):
        if (type(event) == QKeyEvent and event.type() == QEvent.KeyRelease):
            key = event.key()
            if (self.sectionIsGeographic[self.SectionInput]
                    and event.text() == "-"):
                # maybe we should switch the hemisphere?
                if (obj in [
                        self.inLeft, self.inLeftDec, self.inLeftMin,
                        self.inLeftSec
                ]):
                    self.toggleCardinalDirectionButton(self.leftDirButton)
                else:
                    self.toggleCardinalDirectionButton(self.rightDirButton)
            elif (key in [Qt.Key_Return, Qt.Key_Enter]):
                if (self.addFeatureButton.isEnabled()):
                    #coordinatorLog("Clicking add Feature Button")
                    self.addFeatureButton.click()

            #coordinatorLog("Yakub Key Event (Filter): %s (%s)" % (event.key(), event.text()) )

        return super(CoordinatorDockWidget, self).eventFilter(obj, event)

    def __styleInputStyleSelectorForGeographicCrs(self, isGeographic):

        for widget in [self.geoLabel, self.inputAsDMS, self.inputAsDec]:
            widget.setEnabled(isGeographic)

    def setSectionIsGeographic(self, section, isGeographic):
        if (section & self.SectionInput):
            # switch validators for the decimal field, as we may support different ranges
            # switch to DMS view accordingly
            if isGeographic:
                self.inLeftDec.setValidator(self.decDegreeValidator)
                self.inRightDec.setValidator(self.decDegreeValidator)
                # switch to DMS view if it is selected
                self.setInputToDMS(self.inputAsDMS.isChecked())
            else:
                self.inLeftDec.setValidator(self.projectedValidator)
                self.inRightDec.setValidator(self.projectedValidator)

                self.setInputToDMS(False)

            for widget in [
                    self.labelDecDegreeLeft, self.labelDecDegreeRight,
                    self.leftDirButton, self.rightDirButton
            ]:
                widget.show() if isGeographic else widget.hide()

            self.__styleInputStyleSelectorForGeographicCrs(isGeographic)

        if (section & self.SectionOutput):
            for widget in [self.resultAsDMS, self.resultAsDec]:
                widget.setEnabled(isGeographic)

        self.sectionIsGeographic[section] = isGeographic

    def setSectionCrs(self, section, crs):
        #QgsMessageLog.logMessage("set SectionCrs, is Geographic: %s" % crs.isGeographic(), "Coordinator")

        self.setSectionIsGeographic(section, crs.isGeographic())

        if (section == self.SectionInput):
            self.selectCrsButton.setText(crs.authid())
        elif (section == self.SectionOutput):
            self.outputCrs.setText(crs.authid())

    def setInputToDMS(self, isDms):
        if isDms:
            self.leftDMS.show()
            self.rightDMS.show()
            self.leftDecimal.hide()
            self.rightDecimal.hide()
        else:
            self.leftDMS.hide()
            self.rightDMS.hide()
            self.leftDecimal.show()
            self.rightDecimal.show()

    def setInputPoint(self, point):
        #QgsMessageLog.logMessage("%s/%s" % (point.x(), point.y()))

        if self.sectionIsGeographic[self.SectionInput]:
            precision = 9
            # remove leading minus when setting decimal fields. The correct state for
            # the hemisphere buttons is applied in setDmsInputFromDecimal() later.
            xDec = abs(point.x())
            yDec = abs(point.y())
        else:
            precision = 3
            xDec = point.x()
            yDec = point.y()

        self.inLeftDec.setText(QLocale().toString(
            xDec if self._eastingLeftNorthingRight else yDec, "f", precision))
        self.inRightDec.setText(QLocale().toString(
            yDec if self._eastingLeftNorthingRight else xDec, "f", precision))

        self.setDmsInputFromDecimal(point.x(), point.y())

        self.__inputFieldsChangedInternal()

    def setDmsInputFromDecimal(self, x, y, setEastingNorthingInversion=True):
        xDMS = coordinatorDecimalToDms(x)
        yDMS = coordinatorDecimalToDms(y)

        #QgsMessageLog.logMessage(str(xDMS))

        if (setEastingNorthingInversion):
            self.setEastingInverted(xDMS[0])
            self.setNorthingInverted(yDMS[0])

        leftDMS = xDMS if self._eastingLeftNorthingRight else yDMS
        rightDMS = yDMS if self._eastingLeftNorthingRight else xDMS

        self.inLeft.setText(QLocale().toString(leftDMS[1]))
        self.inLeftMin.setText(QLocale().toString(leftDMS[2]))
        self.inLeftSec.setText(QLocale().toString(leftDMS[3], "f", 2))

        self.inRight.setText(QLocale().toString(rightDMS[1]))
        self.inRightMin.setText(QLocale().toString(rightDMS[2]))
        self.inRightSec.setText(QLocale().toString(rightDMS[3], "f", 2))

    def setResultPoint(self, point):
        if self.sectionIsGeographic[CoordinatorDockWidget.SectionOutput]:
            if (self.resultAsDec.isChecked()):
                f = QgsCoordinateFormatter.FormatDecimalDegrees
                precision = 9
            else:
                f = QgsCoordinateFormatter.FormatDegreesMinutesSeconds
                precision = 3

            transformedX = QgsCoordinateFormatter.formatX(
                point.x(), f, precision)
            transformedY = QgsCoordinateFormatter.formatY(
                point.y(), f, precision)
            # if we use FormatDecimalDegrees QgsCoordinateFormatter produces
            # a string just with a QString::number(). Therefore the string is NOT
            # localized. But QgsCoordinateFormatter provides coordinate wrapping already
            # so we just hack the correct decimal sign into the string and should be
            # fine... juuust fine!
            decPoint = QLocale().decimalPoint()
            #coordinatorLog("Decimal Point: %s" % decPoint)
            if (decPoint != "."):
                #coordinatorLog("replace!!")
                transformedX = transformedX.replace(".", decPoint)
                transformedY = transformedY.replace(".", decPoint)

        else:
            #self.log(" -> using decimal output")
            transformedX = QLocale().toString(point.x(), 'f', 2)
            transformedY = QLocale().toString(point.y(), 'f', 2)

        self.setResult(transformedX, transformedY)

    def setResult(self, x, y):
        if (self._eastingLeftNorthingRight):
            self.resultLeft.setText(x)
            self.resultRight.setText(y)
        else:
            self.resultLeft.setText(y)
            self.resultRight.setText(x)

    def setWarningMessage(self, message):
        if (message and len(message) > 0):
            self.messageIcon.setPixmap(self.warningPixmap)
            self.messageIcon.show()
            self.messageText.setText(message)
        else:
            self.hideMessages()

    def showInfoMessage(self, message, hideAfterMilliseconds=None):
        self.messageIcon.clear()
        self.messageText.setText(message)
        if (hideAfterMilliseconds):
            self.messageHideTimer.setInterval(hideAfterMilliseconds)
            self.messageHideTimer.start()

    def hideMessages(self):
        self.messageIcon.clear()
        self.messageIcon.hide()
        self.messageText.clear()

    def clearFieldsInSection(self, section):
        if (section & self.SectionInput):
            for inputField in self._widgetlistInput:
                inputField.setText("")
        if (section & self.SectionOutput):
            for inputField in [
                    self.resultRight,
                    self.resultLeft,
            ]:
                inputField.setText("")

    def clearSection(self, section):
        self.clearFieldsInSection(section)

        # the following code will also reset
        # the buttons designating the hemisphere:
        #if (section & self.SectionInput ) :
        #    self.setEastingInverted(False)
        #    self.setNorthingInverted(False)

        self.addFeatureButton.setEnabled(False)

        self.inputChanged.emit()

    def calculateDecimalDegreesFromDMS(self):
        #QgsMessageLog.logMessage("calc DMS", "Coordinator")
        valueLeft = coordinatorDmsStringsToDecimal(self.inLeft.text(),
                                                   self.inLeftMin.text(),
                                                   self.inLeftSec.text())
        valueRight = coordinatorDmsStringsToDecimal(self.inRight.text(),
                                                    self.inRightMin.text(),
                                                    self.inRightSec.text())
        return (valueLeft, valueRight)

    def hasInput(self):
        if self.leftDMS.isVisible():
            hasInput = False
            for field in self._widgetlistInputDms:
                if len(field.text()) > 0:
                    hasInput = True
                    break
        else:
            hasInput = (len(self.inLeftDec.text()) > 0
                        or len(self.inRightDec.text()) > 0)
        return hasInput

    def __rawInputCoordinates(self):
        if (self.leftDMS.isVisible()):
            return (self.calculateDecimalDegreesFromDMS())
        else:
            valueLeft = 0.0
            valueRight = 0.0
            if (len(self.inLeftDec.text())):
                valueLeft = QLocale().toFloat(self.inLeftDec.text())[0]
            if (len(self.inRightDec.text())):
                valueRight = QLocale().toFloat(self.inRightDec.text())[0]

            return (valueLeft, valueRight)

    def inputCoordinates(self):
        (valueLeft, valueRight) = self.__rawInputCoordinates()

        if (self._eastingLeftNorthingRight):
            inX = valueLeft
            inY = valueRight
        else:
            inX = valueRight
            inY = valueLeft

        if (self.sectionIsGeographic[self.SectionInput]
                and self._eastingInverted):
            inX *= -1
        if (self.sectionIsGeographic[self.SectionInput]
                and self._northingInverted):
            inY *= -1

        return (inX, inY)

    def setNorthingInverted(self, northingInverted):
        self._northingInverted = northingInverted
        label = self.tr("S", "lblSouth") if northingInverted else self.tr(
            "N", "lblNorth")
        if (self._eastingLeftNorthingRight):
            self.rightDirButton.setText(label)
        else:
            self.leftDirButton.setText(label)

    def setEastingInverted(self, eastingInverted):
        self._eastingInverted = eastingInverted
        label = self.tr("W", "lblWest") if eastingInverted else self.tr(
            "E", "lblEast")
        if (self._eastingLeftNorthingRight):
            self.leftDirButton.setText(label)
        else:
            self.rightDirButton.setText(label)

    def toggleCardinalDirectionButton(self, button):
        if (self._eastingLeftNorthingRight):
            toggleEasting = (button == self.leftDirButton)
        else:
            toggleEasting = (button == self.rightDirButton)

        if (toggleEasting):
            self.setEastingInverted(not self._eastingInverted)
        else:
            self.setNorthingInverted(not self._northingInverted)

        self.inputChanged.emit()

    def toggledMapConnection(self, section, isConnected):
        if section == CoordinatorDockWidget.SectionOutput:
            self.outputCrs.setEnabled(not isConnected)

        self.mapConnectionChanged.emit(section, isConnected)

    def __inputFieldsChangedInternal(self):
        #coordinatorLog("fields changed internal triggered")

        self._setToolsEnabled(self.hasInput())

        if (self.hasInput()):

            if (self.leftDMS.isVisible()):
                (leftValue, rightValue) = self.calculateDecimalDegreesFromDMS()
                self.inLeftDec.setText(QLocale().toString(leftValue, "f", 9))
                self.inRightDec.setText(QLocale().toString(rightValue, "f", 9))
            else:
                # calculate DMS Values

                leftValue = QLocale().toFloat(self.inLeftDec.text())[0]
                rightValue = QLocale().toFloat(self.inRightDec.text())[0]

                x = leftValue if self._eastingLeftNorthingRight else rightValue
                y = rightValue if self._eastingLeftNorthingRight else leftValue

                self.setDmsInputFromDecimal(x, y, False)
        else:
            if (self.leftDMS.isVisible()):
                self.inLeftDec.setText(None)
                self.inRightDec.setText(None)
            else:
                for f in self._widgetlistInputDms:
                    f.setText(None)

        self.inputChanged.emit()

    def copyResultToClipBoard(self, which):
        cb = QApplication.clipboard()
        cb.clear(mode=cb.Clipboard)
        if which == CoordinatorDockWidget.SideLeft:
            content = self.resultLeft.text()
        elif which == CoordinatorDockWidget.SideRight:
            content = self.resultRight.text()
        else:
            content = "%s\t%s" % (self.resultLeft.text(),
                                  self.resultRight.text())

        cb.setText(content, mode=cb.Clipboard)

    def showHelpButtonClicked(self):

        if not hasattr(self, "helpview"):
            helpBasepath = "%s/help" % os.path.normpath(
                os.path.dirname(__file__))
            helpUrl = QUrl(
                pathlib.Path("%s/index.html" % helpBasepath).as_uri())
            cssUrl = QUrl(pathlib.Path("%s/help.css" % helpBasepath).as_uri())
            self.helpview = QWebView()
            self.helpview.settings().setUserStyleSheetUrl(cssUrl)

            self.helpview.load(helpUrl)

        self.helpview.show()

    def closeEvent(self, event):
        self.closingPlugin.emit()
        event.accept()
Exemplo n.º 27
0
    def create_widgets(self):
        '''create widgets on main window'''
        self.main_listview = TableWidgetDragRows(self)
        self.main_listview.move(10, 60)
        self.main_listview.setFixedSize(200, 500)
        self.main_listview.setColumnCount(2)
        self.main_listview.setHorizontalHeaderLabels(
            ['file name', 'file path'])
        self.main_listview.setEditTriggers(QTableWidget.NoEditTriggers)
        self.main_listview.setColumnWidth(0, 140)
        self.main_listview.setColumnWidth(1, 400)
        self.main_listview.hideColumn(1)

        self.label_drop_here = QLabel('File Drop Here', self)
        self.label_drop_here.move(25, 30)

        self.pbutton_remove_row = QPushButton('remove', self)
        self.pbutton_remove_row.move(15, 570)
        self.pbutton_remove_row.clicked.connect(self.remove_row)

        self.pbutton_remove_row = QPushButton('remove all', self)
        self.pbutton_remove_row.move(15, 590)
        self.pbutton_remove_row.clicked.connect(self.remove_row_all)

        self.label_legend = QLabel('Graph Legend', self)
        self.label_legend.move(235, 30)

        self.textedit_legend = QTextEdit(self)
        self.textedit_legend.setFixedSize(200, 480)
        self.textedit_legend.move(220, 80)

        self.label_legend_unit = QLabel('Legend unit', self)
        self.label_legend_unit.move(220, 570)
        self.textbox_legend_unit = QLineEdit(self)
        self.textbox_legend_unit.move(220, 590)

        self.label_xlabel = QLabel('xlabel', self)
        self.label_xlabel.move(465, 30)
        self.textbox_xlabel = QLineEdit(self)
        self.textbox_xlabel.move(465, 50)
        self.textbox_xlabel.setFixedWidth(300)

        self.label_ylabel = QLabel('ylabel', self)
        self.label_ylabel.move(465, 80)
        self.textbox_ylabel = QLineEdit(self)
        self.textbox_ylabel.move(465, 100)
        self.textbox_ylabel.setFixedWidth(300)

        self.checkbox_xlog = QCheckBox('x logscale', self)
        self.checkbox_xlog.move(465, 130)
        self.checkbox_ylog = QCheckBox('y logscale', self)
        self.checkbox_ylog.move(465, 150)

        self.checkbox_xtick_label = QCheckBox('without xtick label', self)
        self.checkbox_xtick_label.move(630, 130)
        self.checkbox_ytick_label = QCheckBox('without ytick label', self)
        self.checkbox_ytick_label.move(630, 150)

        self.checkbox_wline_plot = QCheckBox('without line plot', self)
        self.checkbox_wline_plot.move(465, 180)
        self.checkbox_normarize_plot = QCheckBox('normarized plot', self)
        self.checkbox_normarize_plot.move(465, 200)

        self.checkbox_legend_plot = QCheckBox('with legend', self)
        self.checkbox_legend_plot.move(630, 180)
        self.combobox_legend_position = QComboBox(self)
        self.combobox_legend_position.move(630, 195)
        self.combobox_legend_position.addItems(
            ['upper right', 'upper left', 'lower right', 'lower left'])
        self.combobox_legend_position.setFixedWidth(140)

        self.checkbox_xrange = QCheckBox('set x range', self)
        self.checkbox_xrange.move(465, 240)
        self.textbox_xmin = QLineEdit(self)
        self.textbox_xmin.move(470, 260)
        self.textbox_xmin.setValidator(QDoubleValidator())
        self.label_x_to = QLabel('to', self)
        self.label_x_to.move(600, 260)
        self.textbox_xmax = QLineEdit(self)
        self.textbox_xmax.move(620, 260)
        self.textbox_xmax.setValidator(QDoubleValidator())

        self.checkbox_yrange = QCheckBox('set y range', self)
        self.checkbox_yrange.move(465, 290)
        self.textbox_ymin = QLineEdit(self)
        self.textbox_ymin.move(470, 310)
        self.textbox_ymin.setValidator(QDoubleValidator())
        self.label_y_to = QLabel('to', self)
        self.label_y_to.move(600, 310)
        self.textbox_ymax = QLineEdit(self)
        self.textbox_ymax.move(620, 310)
        self.textbox_ymax.setValidator(QDoubleValidator())

        self.label_plot_style = QLabel('Plot Style', self)
        self.label_plot_style.move(465, 535)
        self.combobox_plot_style = QComboBox(self)
        self.combobox_plot_style.move(550, 530)
        self.combobox_plot_style.addItems([PLOTMODE_1, PLOTMODE_2])
        self.combobox_plot_style.setFixedWidth(200)

        self.pbutton_save = QPushButton('Plot and Save', self)
        self.pbutton_save.move(465, 570)
        self.pbutton_save.clicked.connect(self.graph_save)
Exemplo n.º 28
0
 def __init__(self):
     super().__init__()
     self.setAlignment(Qt.AlignRight)
     self.setValidator(QDoubleValidator())
    def __init__(self):
        QWidget.__init__(self)

        self.main_layout = QVBoxLayout()
        self.l = QFormLayout()
        self.l2 = QHBoxLayout()
        self.l3 = QHBoxLayout()

        self.group_box = QGroupBox('Ustawienia ogólne')
        self.group_box2 = QGroupBox('Pobieraj metadane')
        self.group_box3 = QGroupBox(
            'Pobieraj dodatkowe metadane i dołącz je do komentarza')

        # general settings
        self.max_results_label = QLabel('Maksymalna liczba wyników')
        self.max_results_label.setToolTip(
            'Maksymalna liczba pobieranych metadanych. Dla książek o nieunikalnych tytułach \
pierwszy wynik może być niepoprawny')
        self.max_results = QLineEdit(self)
        self.max_results.setValidator(QIntValidator())
        self.max_results.setText(str(PREFS['max_results']))
        self.max_results_label.setBuddy(self.max_results)
        self.l.addRow(self.max_results_label, self.max_results)

        self.authors_search_label = QLabel('Używaj autorów do wyszukiwań')
        self.authors_search_label.setToolTip(
            'Wyszukuj uwzględniając autorów. Może poprawić trafność wyników, ale błędni autorzy spowodują brak wyników'
        )
        self.authors_search = QCheckBox()
        self.authors_search.setChecked(PREFS['authors_search'])
        self.authors_search_label.setBuddy(self.authors_search)
        self.l.addRow(self.authors_search_label, self.authors_search)

        self.only_first_author_label = QLabel(
            'Używaj tylko pierwszego autora do wyszukiwania')
        self.only_first_author_label.setToolTip(
            'Używaj tylko pierwszego autora do wyszukiwań, obowiązuje tylko gdy wyszukiwanie z autorami jest aktywowane'
        )
        self.only_first_author = QCheckBox()
        self.only_first_author.setChecked(PREFS['only_first_author'])
        self.only_first_author_label.setBuddy(self.only_first_author)
        self.l.addRow(self.only_first_author_label, self.only_first_author)

        self.covers_label = QLabel('Pobieraj okładki')
        self.covers = QCheckBox()
        self.covers.setChecked(PREFS['covers'])
        self.covers_label.setBuddy(self.covers)
        self.l.addRow(self.covers_label, self.covers)

        self.max_covers_label = QLabel('Maksymalna liczba okładek')
        self.max_covers_label.setToolTip(
            'Maksymalna liczba pobieranych okładek')
        self.max_covers = QLineEdit(self)
        self.max_covers.setValidator(QIntValidator())
        self.max_covers.setText(str(PREFS['max_covers']))
        self.max_covers_label.setBuddy(self.max_covers)
        self.l.addRow(self.max_covers_label, self.max_covers)

        self.threads_label = QLabel('Wielowątkowe przetwarzanie')
        self.threads_label.setToolTip(
            'Przyśpiesza pracę używając wielu wątków')
        self.threads = QCheckBox()
        self.threads.setChecked(PREFS['threads'])
        self.threads_label.setBuddy(self.threads)
        self.l.addRow(self.threads_label, self.threads)

        self.max_threads_label = QLabel('Maksymalna liczba wątków')
        self.max_threads = QLineEdit(self)
        self.max_threads.setValidator(QIntValidator())
        self.max_threads.setText(str(PREFS['max_threads']))
        self.max_threads_label.setBuddy(self.max_threads)
        self.l.addRow(self.max_threads_label, self.max_threads)

        self.thread_delay_label = QLabel('Opóźnienie wątku')
        self.thread_delay_label.setToolTip(
            'Czas oczekiwania na uruchomienie kolejnego wątku')
        self.thread_delay = QLineEdit(self)
        self.thread_delay.setValidator(QDoubleValidator())
        self.thread_delay.setText(str(PREFS['thread_delay']))
        self.thread_delay_label.setBuddy(self.thread_delay)
        self.l.addRow(self.thread_delay_label, self.thread_delay)

        # metadata settings
        if 'title' in PREFS.defaults:
            self.title = QCheckBox('Tytuł')
            self.title.setChecked(PREFS['title'])
            self.l2.addWidget(self.title)

        if 'authors' in PREFS.defaults:
            self.authors = QCheckBox('Autorzy')
            self.authors.setChecked(PREFS['authors'])
            self.l2.addWidget(self.authors)

        if 'pubdate' in PREFS.defaults:
            self.pubdate = QCheckBox('Data wydania')
            self.pubdate.setChecked(PREFS['pubdate'])
            self.l2.addWidget(self.pubdate)

        if 'publisher' in PREFS.defaults:
            self.publisher = QCheckBox('Wydawca')
            self.publisher.setChecked(PREFS['publisher'])
            self.l2.addWidget(self.publisher)

        if 'isbn' in PREFS.defaults:
            self.isbn = QCheckBox('ISBN')
            self.isbn.setChecked(PREFS['isbn'])
            self.l2.addWidget(self.isbn)

        if 'comments' in PREFS.defaults:
            self.comments = QCheckBox('Opis')
            self.comments.setChecked(PREFS['comments'])
            self.l2.addWidget(self.comments)

        if 'languages' in PREFS.defaults:
            self.languages = QCheckBox('Języki')
            self.languages.setChecked(PREFS['languages'])
            self.l2.addWidget(self.languages)

        if 'rating' in PREFS.defaults:
            self.rating = QCheckBox('Ocena')
            self.rating.setChecked(PREFS['rating'])
            self.l2.addWidget(self.rating)

        if 'tags' in PREFS.defaults:
            self.tags = QCheckBox('Etykiety (tagi)')
            self.tags.setChecked(PREFS['tags'])
            self.l2.addWidget(self.tags)

        if 'series' in PREFS.defaults:
            self.series = QCheckBox('Cykle')
            self.series.setChecked(PREFS['series'])
            self.l2.addWidget(self.series)

        if 'identifier' in PREFS.defaults:
            self.identifier = QCheckBox('Identyfikator')
            self.identifier.setChecked(PREFS['identifier'])
            self.l2.addWidget(self.identifier)

        # custom metadata
        if 'translators' in PREFS.defaults:
            self.translators = QCheckBox('Tłumaczenie')
            self.translators.setChecked(PREFS['translators'])
            self.l3.addWidget(self.translators)

        if 'original_title' in PREFS.defaults:
            self.original_title = QCheckBox('Tytuł oryginału')
            self.original_title.setChecked(PREFS['original_title'])
            self.l3.addWidget(self.original_title)

        if 'categories' in PREFS.defaults:
            self.categories = QCheckBox('Kategorie')
            self.categories.setChecked(PREFS['categories'])
            self.l3.addWidget(self.categories)

        if 'genres' in PREFS.defaults:
            self.genres = QCheckBox('Gatunki')
            self.genres.setChecked(PREFS['genres'])
            self.l3.addWidget(self.genres)

        self.group_box.setLayout(self.l)
        self.group_box2.setLayout(self.l2)
        self.group_box3.setLayout(self.l3)
        self.main_layout.addWidget(self.group_box)
        self.main_layout.addWidget(self.group_box2)
        self.main_layout.addWidget(self.group_box3)
        self.main_layout.setAlignment(Qt.AlignTop)
        self.setLayout(self.main_layout)
Exemplo n.º 30
-1
 def __init__(self, parent, modal=True, flags=Qt.WindowFlags()):
     QDialog.__init__(self, parent, flags)
     self.model = None
     self._model_dir = None
     self.setModal(modal)
     self.setWindowTitle("Add FITS brick")
     lo = QVBoxLayout(self)
     lo.setContentsMargins(10, 10, 10, 10)
     lo.setSpacing(5)
     # file selector
     self.wfile = FileSelector(self,
                               label="FITS filename:",
                               dialog_label="FITS file",
                               default_suffix="fits",
                               file_types="FITS files (*.fits *.FITS)",
                               file_mode=QFileDialog.ExistingFile)
     lo.addWidget(self.wfile)
     # overwrite or add mode
     lo1 = QGridLayout()
     lo.addLayout(lo1)
     lo1.setContentsMargins(0, 0, 0, 0)
     lo1.addWidget(QLabel("Padding factor:", self), 0, 0)
     self.wpad = QLineEdit("2", self)
     self.wpad.setValidator(QDoubleValidator(self))
     lo1.addWidget(self.wpad, 0, 1)
     lo1.addWidget(QLabel("Assign source name:", self), 1, 0)
     self.wname = QLineEdit(self)
     lo1.addWidget(self.wname, 1, 1)
     # OK/cancel buttons
     lo.addSpacing(10)
     lo2 = QHBoxLayout()
     lo.addLayout(lo2)
     lo2.setContentsMargins(0, 0, 0, 0)
     lo2.setContentsMargins(5, 5, 5, 5)
     self.wokbtn = QPushButton("OK", self)
     self.wokbtn.setMinimumWidth(128)
     self.wokbtn.clicked.connect(self.accept)
     self.wokbtn.setEnabled(False)
     cancelbtn = QPushButton("Cancel", self)
     cancelbtn.setMinimumWidth(128)
     cancelbtn.clicked.connect(self.reject)
     lo2.addWidget(self.wokbtn)
     lo2.addStretch(1)
     lo2.addWidget(cancelbtn)
     self.setMinimumWidth(384)
     # signals
     self.wfile.filenameSelected.connect(self._fileSelected)
     # internal state
     self.qerrmsg = QErrorMessage(self)