def __init__(self,parent=None):
        super(Form,self).__init__(parent)

        date = self.get_data()
        rates = sorted(self.rates.keys())

        dateLabel = QLabel(date)

        self.fromComboBox = QComboBox()
        self.toComboBox = QComboBox()

        self.fromComboBox.addItems(rates)
        self.toComboBox.addItems(rates)

        self.fromSpinBox = QDoubleSpinBox()
        self.fromSpinBox.setRange(0.01,1000)
        self.fromSpinBox.setValue(1.00)

        self.toLabel = QLabel("1.00")

        layout = QGridLayout();
        layout.addWidget(dateLabel,5,0)
        layout.addWidget(self.fromComboBox, 1,0)
        layout.addWidget(self.toComboBox,2,0)
        layout.addWidget(self.fromSpinBox,1,1)
        layout.addWidget(self.toLabel,2,1)

        self.setLayout(layout)

        #Connect Signal
        self.fromComboBox.currentIndexChanged.connect(self.update_ui)
        self.toComboBox.currentIndexChanged.connect(self.update_ui)
        self.fromSpinBox.valueChanged.connect(self.update_ui)
Exemple #2
0
 def testQRealSignal(self):
     foo1 = QDoubleSpinBox()
     effect = QGraphicsBlurEffect()
     effect.blurRadiusChanged['qreal'].connect(
         foo1.setValue)  # check if qreal is a valid type
     effect.setBlurRadius(0.42)
     self.assertAlmostEqual(foo1.value(), effect.blurRadius())
Exemple #3
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        factory = self.factory
        if not factory.low_name:
            self.low = factory.low

        if not factory.high_name:
            self.high = factory.high

        self.sync_value(factory.low_name, 'low', 'from')
        self.sync_value(factory.high_name, 'high', 'from')
        low = self.low
        high = self.high

        self.control = QDoubleSpinBox()
        if factory.step:
            self.control.setSingleStep(factory.step)

        self.control.setMinimum(low)
        self.control.setMaximum(high)
        self.control.setValue(self.value)
        QtCore.QObject.connect(self.control,
                               QtCore.SIGNAL('valueChanged(int)'),
                               self.update_object)
        self.set_tooltip()
 def editor(self, defaultValue):
     if self.integer:
         self.spinBox = QSpinBox()
     else:
         self.spinBox = QDoubleSpinBox()
     self.spinBox.setRange(0,10**5)
     self.spinBox.setValue(float(QSettings().value(self.settingsName, defaultValue)))
     self.spinBox.setToolTip('Default value: %s' % defaultValue)
     self.spinBox.setAlignment(Qt.AlignLeft|Qt.AlignTop)
     self.layout().addWidget(self.spinBox)
Exemple #5
0
class Double3(QFrame):
    """
    A 3 slider Line for 3d arrays
    """
    valuesChanged = Signal(list)

    def __init__(self, parent=None):
        super(Double3, self).__init__(parent)

        self.x = QDoubleSpinBox()
        self.y = QDoubleSpinBox()
        self.z = QDoubleSpinBox()

        self.setLayout(line(self.x, self.y, self.z))
        # connecting all signals
        for elem in (self.x, self.y, self.z):
            elem.valueChanged.connect(self.element_value_changed)

    def element_value_changed(self):
        self.valuesChanged.emit([self.x.value(), self.y.value(), self.z.value()])

    def setValues(self, xyz):
        x, y, z = xyz
        self.x.setValue(x)
        self.y.setValue(y)
        self.z.setValue(z)
Exemple #6
0
class Double3(QFrame):
    """
    A 3 slider Line for 3d arrays
    """
    valuesChanged = Signal(list)

    def __init__(self, parent=None):
        super(Double3, self).__init__(parent)

        self.x = QDoubleSpinBox()
        self.y = QDoubleSpinBox()
        self.z = QDoubleSpinBox()

        self.setLayout(line(self.x, self.y, self.z))
        # connecting all signals
        for elem in (self.x, self.y, self.z):
            elem.valueChanged.connect(self.element_value_changed)

    def element_value_changed(self):
        self.valuesChanged.emit(
            [self.x.value(), self.y.value(),
             self.z.value()])

    def setValues(self, xyz):
        x, y, z = xyz
        self.x.setValue(x)
        self.y.setValue(y)
        self.z.setValue(z)
Exemple #7
0
    def __init__(self, parent=None):
        super(Double3, self).__init__(parent)

        self.x = QDoubleSpinBox()
        self.y = QDoubleSpinBox()
        self.z = QDoubleSpinBox()

        self.setLayout(line(self.x, self.y, self.z))
        # connecting all signals
        for elem in (self.x, self.y, self.z):
            elem.valueChanged.connect(self.element_value_changed)
Exemple #8
0
class _DoubleSpinnerEditor(SimpleSpinEditor):
    def init (self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        factory = self.factory
        if not factory.low_name:
            self.low = factory.low

        if not factory.high_name:
            self.high = factory.high

        self.sync_value(factory.low_name, 'low', 'from')
        self.sync_value(factory.high_name, 'high', 'from')
        low = self.low
        high = self.high

        self.control = QDoubleSpinBox()
        if factory.step:
            self.control.setSingleStep(factory.step)

        self.control.setMinimum(low)
        self.control.setMaximum(high)
        self.control.setValue(self.value)
        QtCore.QObject.connect(self.control,
                QtCore.SIGNAL('valueChanged(int)'), self.update_object)
        self.set_tooltip()
Exemple #9
0
 def testFloatSignal(self):
     foo1 = QDoubleSpinBox()
     foo2 = QDoubleSpinBox()
     foo1.valueChanged[float].connect(foo2.setValue)
     foo2.valueChanged[float].connect(foo1.setValue)
     foo1.setValue(0.42)
     self.assertEqual(foo1.value(), foo2.value())
Exemple #10
0
    def insertRow(self, index, propertyName, label):
        propertyKey = self.resultSet.propertyKey(str(propertyName))

        propertyType = self.resultSet.propertyType(propertyKey)
        propertyAttributes = self.resultSet.propertyAttributes(propertyKey)

        widget = None

        if propertyAttributes & QGalleryProperty.CanWrite:
            if propertyType == str:
                widget = QLineEdit()
            elif propertyType == float:
                widget = QDoubleSpinBox()
            elif propertyType == int:
                widget = QSpinBox()
            elif propertyType == QDateTime:
                widget = QDateTimeEdit()
            else:
                widget = QLabel()
        elif propertyAttributes & QGalleryProperty.CanRead:
            widget = QLabel()

        self.propertyKeys.insert(index, propertyKey)
        self.widgets.insert(index, widget)

        self.layout().insertRow(index, label, widget)
Exemple #11
0
class AddFilterDlg(QDialog):
	
	def __init__(self, parent=None):
		super(AddFilterDlg, self).__init__(parent)
		self.setWindowTitle("Advanced Filtering Options")
		
		note_label = QLabel("NOTE: These filtering options apply exclusively to relief devices, not to the relief device area they belong to or to their scenarios.")
		pressure_label = QLabel("Filter where <b>Set Pressure</b> is")
		self.pressure_combobox = QComboBox()
		self.pressure_combobox.addItems(["Greater Than", "Less Than", "Equal To", "Not Equal To"])
		self.pressure_value = QDoubleSpinBox()
		pressure_layout = QHBoxLayout()
		pressure_layout.addWidget(pressure_label)
		pressure_layout.addWidget(self.pressure_combobox)
		pressure_layout.addWidget(self.pressure_value)
		button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
		
		layout = QGridLayout()
		layout.addWidget(note_label, 0, 0)
		layout.addLayout(pressure_layout, 1, 0)
		layout.addWidget(button_box, 2, 0)
		self.setLayout(layout)
		
		button_box.accepted.connect(self.accept)
		button_box.rejected.connect(self.reject)
		
	def returnVals(self):
		return (self.pressure_combobox.currentText(), self.pressure_value.value())
 def _initGUI(self):
     self.layout = QVBoxLayout()
     self.form = QFormLayout()
     
     self.name = QLineEdit()
     self.surname = QLineEdit()
     
     self.birthdate = QCalendarWidget()
     self.birthdate.setGridVisible(True)
     self.birthdate.setMinimumDate(QDate(1850,1,1))
     self.birthdate.setMaximumDate(QDate.currentDate())
     
     self.male = QRadioButton("Male")
     self.male.setChecked(True)
     self.female = QRadioButton("Female")
     
     self.height = QDoubleSpinBox()
     self.height.setMaximum(250)
     self.height.setMinimum(50)
     self.height.setValue(165)
     self.height.setSuffix(" cm")
     
     self.mass = QDoubleSpinBox()
     self.mass.setMaximum(300)
     self.mass.setMinimum(20)
     self.mass.setValue(60)
     self.mass.setSuffix(" Kg")
     
     btnLayout = QVBoxLayout()
     
     self.form.addRow("Name", self.name)
     self.form.addRow("Surname", self.surname)
     self.form.addRow("Birth date",self.birthdate)
     
     sexLayout = QHBoxLayout()
     sexLayout.addWidget(self.male)
     sexLayout.addWidget(self.female)
     self.form.addRow("Sex", sexLayout)
     
     self.form.addRow("Height", self.height)
     self.form.addRow("Mass", self.mass)
             
     self.layout.addLayout(self.form)
     self.layout.addLayout(btnLayout)
     self.setLayout(self.layout)
    def _initGUI(self):
        self.layout = QVBoxLayout()
        self.form = QFormLayout()

        self.name = QLineEdit()
        self.surname = QLineEdit()

        self.birthdate = QCalendarWidget()
        self.birthdate.setGridVisible(True)
        self.birthdate.setMinimumDate(QDate(1850, 1, 1))
        self.birthdate.setMaximumDate(QDate.currentDate())

        self.male = QRadioButton("Male")
        self.male.setChecked(True)
        self.female = QRadioButton("Female")

        self.height = QDoubleSpinBox()
        self.height.setMaximum(250)
        self.height.setMinimum(50)
        self.height.setValue(165)
        self.height.setSuffix(" cm")

        self.mass = QDoubleSpinBox()
        self.mass.setMaximum(300)
        self.mass.setMinimum(20)
        self.mass.setValue(60)
        self.mass.setSuffix(" Kg")

        btnLayout = QVBoxLayout()

        self.form.addRow("Name", self.name)
        self.form.addRow("Surname", self.surname)
        self.form.addRow("Birth date", self.birthdate)

        sexLayout = QHBoxLayout()
        sexLayout.addWidget(self.male)
        sexLayout.addWidget(self.female)
        self.form.addRow("Sex", sexLayout)

        self.form.addRow("Height", self.height)
        self.form.addRow("Mass", self.mass)

        self.layout.addLayout(self.form)
        self.layout.addLayout(btnLayout)
        self.setLayout(self.layout)
    def get_frame(self):
        # Info stuff.
        self.infos = {}
        infogrp = QGroupBox('Scene Info')
        grdlay = QGridLayout()
        grdlay.addWidget(QLabel('<b>Name</b>'), 0, 0)
        namebox = QLineEdit()
        self.infos['name'] = namebox
        namebox.setText(self.info.name)

        rangebox1 = QSpinBox()
        rangebox1.setMinimum(0)
        rangebox1.setMaximum(1000)
        self.infos['rangestart'] = rangebox1
        rangebox1.setValue(self.info.frame_range[0])

        rangebox2 = QSpinBox()
        rangebox2.setMinimum(0)
        rangebox2.setMaximum(1000)
        self.infos['rangeend'] = rangebox2
        rangebox2.setValue(self.info.frame_range[1])

        fpsbox = QDoubleSpinBox()
        self.infos['fps'] = fpsbox
        fpsbox.setValue(self.info.fps)

        bbox_btn = QPushButton('Bounding Box')
        bbox_btn.clicked.connect(self.edit_bbox)
        grdlay.addWidget(namebox, 0, 1)
        grdlay.addWidget(QLabel('<b>StartFrame</b>'), 1, 0)
        grdlay.addWidget(rangebox1, 1, 1)
        grdlay.addWidget(QLabel('<b>EndFrame</b>'), 1, 2)
        grdlay.addWidget(fpsbox, 0, 3)
        grdlay.addWidget(rangebox2, 1, 3)
        grdlay.addWidget(QLabel('<b>FPS</b>'), 0, 2)

        grdlay.addWidget(bbox_btn, 2, 0)

        grplay = QVBoxLayout()
        grplay.addLayout(grdlay)
        #grplay.addStretch()
        infogrp.setLayout(grplay)

        return infogrp
class SetRangeStringCompound(QWidget):
  def __init__(self, parent=None):
    super(SetRangeStringCompound, self).__init__(parent)
    label_string = QLabel("Range string")
    self.lineedit_string = QLineEdit()
    self.lineedit_string.setMinimumWidth(100)
    label_value = QLabel("Value")
    self.spinbox_value = QDoubleSpinBox()
    self.spinbox_value.setMaximum(9999)
    self.spinbox_value.setValue(1.0)
    row = 0 ; col = 0;
    layout = QGridLayout()
    layout.addWidget(label_string, row, col)
    col += 1
    layout.addWidget(self.lineedit_string, row, col)
    row += 1; col = 0;
    layout.addWidget(label_value, row, col)
    col += 1
    layout.addWidget(self.spinbox_value, row, col)
    self.setLayout(layout)
Exemple #16
0
 def testFloatSignal(self):
     foo1 = QDoubleSpinBox()
     foo2 = QDoubleSpinBox()
     foo1.valueChanged[float].connect(foo2.setValue)
     foo2.valueChanged[float].connect(foo1.setValue)
     foo1.setValue(0.42)
     self.assertEqual(foo1.value(), foo2.value())
Exemple #17
0
    def __init__(self):
        super(SliderFloatWidget, self).__init__()

        self.label = QLabel()
        self.slider = QSlider(Qt.Horizontal)
        self.spinbox = QDoubleSpinBox()

        self.slider.valueChanged.connect(self.changedValueFromSlider)
        self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

        # Keep track of whether one of the values was changed
        # By setting the value of the slider and the spinbox, valueChanged
        # events are fired. These events have to be ignored
        self._changed = False

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setVerticalSpacing(0)
        layout.addWidget(self.label, 0, 0)
        layout.addWidget(self.slider, 0, 1)
        layout.addWidget(self.spinbox, 0, 2)
        self.setLayout(layout)
Exemple #18
0
def _createInputField(unit=None):
    if within_FreeCADGui:
        Value = QDoubleSpinBox(
        )  # Gui.InputField()  # widget = ui.createWidget("Gui::InputField")
    else:
        Value = QDoubleSpinBox()  #
        Value.setValue(0.0)
    return Value
Exemple #19
0
    def __init__(self, parent=None):
        super(Double3, self).__init__(parent)

        self.x = QDoubleSpinBox()
        self.y = QDoubleSpinBox()
        self.z = QDoubleSpinBox()

        self.setLayout(line(self.x, self.y, self.z))
        # connecting all signals
        for elem in (self.x, self.y, self.z):
            elem.valueChanged.connect(self.element_value_changed)
	def __init__(self):
		super(SliderFloatWidget, self).__init__()

		self.label = QLabel()
		self.slider = QSlider(Qt.Horizontal)
		self.spinbox = QDoubleSpinBox()

		self.slider.valueChanged.connect(self.changedValueFromSlider)
		self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(0)
		# layout.setHorizontalSpacing(0)
		layout.addWidget(self.label, 0, 0)
		layout.addWidget(self.slider, 0, 1)
		layout.addWidget(self.spinbox, 0, 2)
		self.setLayout(layout)
    def __init__(self, parent=None):

        self.rates = {}
        super(Form, self).__init__(parent)

        date = self.get_data()
        rates = sorted(self.rates.keys())

        # Create UI Elements -------------------------------------------------------------------------------------------
        dateLabel = QLabel(date)
        self.fromComboBox = QComboBox()
        self.toComboBox = QComboBox()

        self.fromComboBox.addItems(rates)
        self.toComboBox.addItems(rates)

        self.fromSpinBox = QDoubleSpinBox()

        # Saturation of minimum and maximum values
        self.fromSpinBox.setRange(0.01, 1000)
        # Set initial value
        self.fromSpinBox.setValue(1.00)

        self.toLabel = QLabel('1.00')

        # Layout -------------------------------------------------------------------------------------------------------
        layout = QGridLayout()
        # addWidget (Widget, row, column)
        layout.addWidget(dateLabel, 0, 0)
        layout.addWidget(self.fromComboBox, 1, 0)
        layout.addWidget(self.toComboBox, 2, 0)
        layout.addWidget(self.fromSpinBox, 1, 1)
        layout.addWidget(self.toLabel, 2, 1)
        self.setLayout(layout)

        # Signals ------------------------------------------------------------------------------------------------------
        self.fromComboBox.currentIndexChanged.connect(self.update_ui)
        self.toComboBox.currentIndexChanged.connect(self.update_ui)

        self.fromSpinBox.valueChanged.connect(self.update_ui)


        # Force window to stay on top when start
        self.setWindowFlags(Qt.WindowStaysOnTopHint)
Exemple #22
0
class Double4(Double3):
    """
    A 4 slider Line for 4d arrays (quaternion)
    """
    def __init__(self, parent=None):
        super(Double4, self).__init__(parent)
        self.w = QDoubleSpinBox()
        self.layout().addWidget(self.w)

        self.w.valueChanged.connect(self.element_value_changed)

    def element_value_changed(self):
        self.valuesChanged.emit([self.x.value(), self.y.value(), self.z.value(), self.w.value()])

    def setValues(self, xyzw):
        x, y, z, w = xyzw
        self.x.setValue(x)
        self.y.setValue(y)
        self.z.setValue(z)
        self.z.setValue(w)
	def __init__(self):
		super(SliderFloatWidget, self).__init__()

		self.label = QLabel()
		self.slider = QSlider(Qt.Horizontal)
		self.spinbox = QDoubleSpinBox()

		self.slider.valueChanged.connect(self.changedValueFromSlider)
		self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

		# Keep track of whether one of the values was changed
		# By setting the value of the slider and the spinbox, valueChanged
		# events are fired. These events have to be ignored
		self._changed = False

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(0)
		layout.addWidget(self.label, 0, 0)
		layout.addWidget(self.slider, 0, 1)
		layout.addWidget(self.spinbox, 0, 2)
		self.setLayout(layout)
Exemple #24
0
	def keyPressEvent(self, event):
		if event.key() == Qt.Key_Z:
			if event.modifiers() & Qt.ControlModifier:
				if self.mw.undo_group.activeStack().index() > 0:
					self.mw.view.setFocus()
					self.mw.undo_group.undo()
			else:
				QDoubleSpinBox.keyPressEvent(self, event)
		elif event.key() == Qt.Key_Y:
			if event.modifiers() & Qt.ControlModifier:
				if self.mw.undo_group.activeStack().index() < self.mw.undo_group.activeStack().count():
					self.mw.view.setFocus()
					self.mw.undo_group.redo()
			else:
				QDoubleSpinBox.keyPressEvent(self, event)
		else:
			QDoubleSpinBox.keyPressEvent(self, event)
Exemple #25
0
 def __init__(self):
     super(Layer, self).__init__()
     self.orientation = Quaternion()
     self.picked = None
     self.show = QCheckBox()
     self.show.setChecked(True)
     self.alpha_slider = QSlider(QtCore.Qt.Orientation.Horizontal)
     self.alpha_slider.setRange(0, 1024)
     self.alpha_slider.setValue(1024)
     self.alpha_number = QDoubleSpinBox()
     self.alpha_number.setDecimals(3)
     self.alpha_number.setSingleStep(0.01)
     self.alpha_number.setRange(0, 1)
     self.alpha_number.setValue(1)
     self.alpha_slider.valueChanged.connect(self._alphaSliderChanged)
     self.alpha_number.valueChanged.connect(self._alphaNumberChanged)
     self.move = QCheckBox()
     self.move.setChecked(True)
     self.quat = QLineEdit()
     font = QFont('monospace')
     font.setStyleHint(QFont.TypeWriter)
     self.quat.setFont(font)
     default_quat = '+0.000, +1.000, +0.000, +0.000'
     margins = self.quat.textMargins()
     self.quat.setFixedWidth(
         # HACK -------------------------------------------v
         QFontMetrics(self.quat.font()).width(default_quat + '  ') +
         margins.left() + margins.right()
     )
     self.quat.setInputMask('#0.000, #0.000, #0.000, #0.000')
     self.quat.setMaxLength(30)
     self.quat.setText(default_quat)
     self.quat.editingFinished.connect(self._orientationChanged)
     self.nbytes = QLabel()
     self.nbytes.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
     self.nbytes.setText('0')
     self.label = QLabel()
     self.label.setText('<empty>')
Exemple #26
0
class Double4(Double3):
    """
    A 4 slider Line for 4d arrays (quaternion)
    """
    def __init__(self, parent=None):
        super(Double4, self).__init__(parent)
        self.w = QDoubleSpinBox()
        self.layout().addWidget(self.w)

        self.w.valueChanged.connect(self.element_value_changed)

    def element_value_changed(self):
        self.valuesChanged.emit(
            [self.x.value(),
             self.y.value(),
             self.z.value(),
             self.w.value()])

    def setValues(self, xyzw):
        x, y, z, w = xyzw
        self.x.setValue(x)
        self.y.setValue(y)
        self.z.setValue(z)
        self.z.setValue(w)
Exemple #27
0
def _createInputField(quantityname=None, quantityunit=None):
    if within_FreeCADGui:
        if quantityname and hasattr(FreeCAD.Units, quantityname):
            widget = ui.createWidget("Gui::InputField")
            unit = getattr(FreeCAD.Units, quantityname)  # string type?
            if qunit:
                widget.setProperty('unit', quantityunit)
            else:
                quantity = FreeCAD.Units.Quantity(1, unit)
                widget.setProperty(
                    'unit',
                    quantity.getUserPreferred()[2])  # by the third [2]?
            return widget
        else:
            FreeCAD.Console.PrintMessage(
                'Not known unit for property: {}\n'.format(quantityname))

    widget = QDoubleSpinBox()  #
    widget.setValue(0.0)
    widget.setRange(-1e10, 1e10)  # give a range big enough
    return widget
Exemple #28
0
 def testQRealSignal(self):
     foo1 = QDoubleSpinBox()
     effect = QGraphicsBlurEffect()
     effect.blurRadiusChanged["qreal"].connect(foo1.setValue)  # check if qreal is a valid type
     effect.setBlurRadius(0.42)
     self.assertAlmostEqual(foo1.value(), effect.blurRadius())
Exemple #29
0
    def __init__(self, parent=None):
        super(Double4, self).__init__(parent)
        self.w = QDoubleSpinBox()
        self.layout().addWidget(self.w)

        self.w.valueChanged.connect(self.element_value_changed)
Exemple #30
0
	def focusOutEvent(self, event):
		if not self.right_clicked:
			if self.value() != self.init_value:
				command = CommandEdit(self, self.init_value, self.node, self.mw, "editing {0} in {1}".format(self.label, self.node.name))
				self.mw.undo_group.activeStack().push(command)
			QDoubleSpinBox.focusOutEvent(self, event)
 def __init__(self, mainwindow, config):
     super(SettingsDialog, self).__init__()
     self.setWindowTitle(self.str_title)
     # Reference kept to set settings in MainWindow
     self.mainwindow = mainwindow
     """A reference to the top window of the app."""
     self.config = config
     """The settings of our app."""
     # Setting log handlers
     logHandlers = QGroupBox(self.str_logHandlers)
     logHandlersLayout = QVBoxLayout()
     logHandlers.setLayout(logHandlersLayout)
     logToGui = QCheckBox(self.str_logToGui)
     logToGui.setChecked(self.config.getboolean('LogHandlers', 'gui'))
     logToGui.stateChanged.connect(
         lambda: self.chooseHandler(logToGui, 'gui'))
     logHandlersLayout.addWidget(logToGui)
     logtoStdout = QCheckBox(self.str_logToStdout)
     logtoStdout.setChecked(self.config.getboolean('LogHandlers', 'stdout'))
     logtoStdout.stateChanged.connect(
         lambda: self.chooseHandler(logtoStdout, 'stdout'))
     logHandlersLayout.addWidget(logtoStdout)
     logToFile = QCheckBox(self.str_logToFile)
     logToFile.setChecked(self.config.getboolean('LogHandlers', 'file'))
     logToFile.stateChanged.connect(
         lambda: self.chooseHandler(logToFile, 'file'))
     logHandlersLayout.addWidget(logToFile)
     # Setting log verbosity
     logVerbosity = QGroupBox(self.str_logVerbosity)
     logVerbosityLayout = QHBoxLayout()
     logVerbosity.setLayout(logVerbosityLayout)
     self.verbosityOptions = QTreeWidget()
     self.verbosityOptions.header().setVisible(False)
     for k, v in self.str_treeItems.items():
         node = QTreeWidgetItem(self.verbosityOptions, [k])
         if isinstance(v, str):
             node.setText(1, v)
             node.setCheckState(
                 0, boolToCheckState(
                     self.config.getboolean('LogVerbosity', v)))
         else:
             count = 0
             for key, val in v.items():
                 item = QTreeWidgetItem(node, [key, val])
                 checked = self.config.getboolean('LogVerbosity', val)
                 item.setCheckState(0, boolToCheckState(checked))
                 if checked:
                     count += 1
             if count == node.childCount():
                 node.setCheckState(0, Qt.Checked)
             elif count == 0:
                 node.setCheckState(0, Qt.Unchecked)
             else:
                 node.setCheckState(0, Qt.PartiallyChecked)
     self.verbosityOptions.itemChanged.connect(self.chooseVerbosity)
     logVerbosityLayout.addWidget(self.verbosityOptions)
     # Setting clock speed
     clock = QGroupBox(self.str_clock)
     clockLayout = QHBoxLayout()
     clock.setLayout(clockLayout)
     clockLayout.addWidget(QLabel(self.str_clockSpeed))
     spin = QDoubleSpinBox()
     spin.setValue(self.config.getfloat('Clock', 'speed'))
     clockLayout.addWidget(spin)
     # Setting appearance
     appearance = QGroupBox(self.str_appearance)
     appearanceLayout = QHBoxLayout()
     appearance.setLayout(appearanceLayout)
     appearanceLayout.addWidget(QLabel(self.str_circBgColor))
     circBgBtn = QPushButton(self.str_choose)
     circBgBtn.setPalette(QPalette(
         QColor(self.config.get('Appearance', 'circ_bg_color'))))
     circBgBtn.clicked.connect(
         lambda: self.chooseColor(circBgBtn, 'circ_bg_color'))
     appearanceLayout.addWidget(circBgBtn)
     appearanceLayout.addWidget(QLabel(self.str_logBgColor))
     logBgBtn = QPushButton(self.str_choose)
     logBgBtn.setPalette(QPalette(
         QColor(self.config.get('Appearance', 'log_bg_color'))))
     logBgBtn.clicked.connect(
         lambda: self.chooseColor(logBgBtn, 'log_bg_color'))
     appearanceLayout.addWidget(logBgBtn)
     # Saving settings to file and effectively setting them
     close = QPushButton(self.str_close)
     close.clicked.connect(self.closeAndApply)
     layout = QGridLayout(self)
     layout.addWidget(logHandlers, 0, 0, 1, 1)
     layout.addWidget(logVerbosity, 0, 1, 1, 1)
     layout.addWidget(clock, 1, 0, 1, 2)
     layout.addWidget(appearance, 2, 0, 1, 2)
     layout.addWidget(close, 3, 1, 1, 1)
     self.setLayout(layout)
    def initUI(self):
        grp = QGroupBox('Material')
        grplay = QGridLayout()

        name = QLineEdit()
        name.setText(self.mat.name)
        self.controls['name'] = name

        tex0 = QLineEdit()
        tex0.setText(self.mat.tex0)
        self.controls['tex0'] = tex0

        tex1 = QLineEdit()
        tex1.setText(self.mat.tex1)
        self.controls['tex1'] = tex1

        tex2 = QLineEdit()
        tex2.setText(self.mat.tex2)
        self.controls['tex2'] = tex2

        tex3 = QLineEdit()
        tex3.setText(self.mat.tex3)
        self.controls['tex3'] = tex3

        flags = QGroupBox('Flags')
        fllay = QGridLayout()

        for ind, flag in enumerate(self.mat.flags):
            fllay.addWidget(QLabel(self.pretty_flags[flag[0]]), ind, 0)
            box = QCheckBox()
            fllay.addWidget(box, ind, 1)
            if flag[1]:
                box.toggle()
            self.controls[flag[0]] = box

        fllay.addWidget(QLabel('<b>RenderType</b>'), 8, 0)
        numbox = QComboBox()
        numbox.addItems(self.render_types)
        numbox.setCurrentIndex(self.mat.render_type)
        fllay.addWidget(numbox)
        self.controls['render_type'] = numbox

        fllay.addWidget(QLabel('<b>Data0</b>'), 9, 0)
        d0 = QSpinBox()
        d0.setValue(self.mat.data0)
        d0.setMinimum(0)
        d0.setMaximum(255)
        fllay.addWidget(d0)
        self.controls['data0'] = d0

        fllay.addWidget(QLabel('<b>Data1</b>'), 10, 0)
        d1 = QSpinBox()
        d1.setValue(self.mat.data1)
        d1.setMinimum(0)
        d1.setMaximum(255)
        fllay.addWidget(d1)
        self.controls['data1'] = d1

        flags.setLayout(fllay)

        colors = QGroupBox('Colors')
        collay = QGridLayout()

        self.add_color('<b>Diffuse</b>', self.mat.diff_color, collay, 3)
        self.add_color('<b>Specular</b>', self.mat.spec_color, collay, 4)
        self.add_color('<b>Ambient</b>', self.mat.ambt_color, collay, 5)

        colors.setLayout(collay)

        grplay.addWidget(QLabel('<b>Name</b>'), 0, 0)
        grplay.addWidget(name, 0, 1)

        grplay.addWidget(QLabel('<b>Texture0</b>'), 1, 0)
        grplay.addWidget(tex0, 1, 1)
        grplay.addWidget(QLabel('<b>Texture1</b>'), 1, 2)
        grplay.addWidget(tex1, 1, 3)

        grplay.addWidget(QLabel('<b>Texture2</b>'), 2, 0)
        grplay.addWidget(tex2, 2, 1)
        grplay.addWidget(QLabel('<b>Texture3</b>'), 2, 2)
        grplay.addWidget(tex3, 2, 3)

        grplay.addWidget(QLabel('<b>Gloss</b>'), 3, 0)
        gloss = QDoubleSpinBox()
        gloss.setValue(self.mat.gloss)
        grplay.addWidget(gloss, 3, 1)
        self.controls['gloss'] = gloss

        grplay.addWidget(colors, 4, 0, 1, 5)
        grplay.addWidget(flags, 5, 0, 1, 3)

        grp.setLayout(grplay)

        btns = QHBoxLayout()

        save = QPushButton('Save')
        save.clicked.connect(self.save)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.close)

        btns.addStretch()
        btns.addWidget(save)
        btns.addWidget(cancel)

        mainlay = QVBoxLayout()
        mainlay.addWidget(grp)
        mainlay.addLayout(btns)

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 440, 200)
        self.setWindowTitle('MSH Suite - {0}'.format(self.mat.name))
        self.show()
    def initUI(self):
        grp = QGroupBox('Bounding Box')
        grplay = QGridLayout()

        # Extents.
        extx = QDoubleSpinBox()
        extx.setMinimum(0)
        extx.setMaximum(100)
        extx.setValue(self.bbox.extents[0])
        self.controls['extx'] = extx
        exty = QDoubleSpinBox()
        exty.setMinimum(0)
        exty.setMaximum(100)
        exty.setValue(self.bbox.extents[1])
        self.controls['exty'] = exty
        extz = QDoubleSpinBox()
        extz.setMinimum(0)
        extz.setMaximum(100)
        extz.setValue(self.bbox.extents[2])
        self.controls['extz'] = extz
        grplay.addWidget(QLabel('<b>Extents</b>'), 0, 0)
        grplay.addWidget(QLabel('X'), 0, 1)
        grplay.addWidget(extx, 0, 2)
        grplay.addWidget(QLabel('Y'), 0, 3)
        grplay.addWidget(exty, 0, 4)
        grplay.addWidget(QLabel('Z'), 0, 5)
        grplay.addWidget(extz, 0, 6)
        # Center.
        cntx = QDoubleSpinBox()
        cntx.setMinimum(-10000)
        cntx.setMaximum(10000)
        cntx.setValue(self.bbox.center[0])
        self.controls['cntx'] = cntx
        cnty = QDoubleSpinBox()
        cnty.setMinimum(-10000)
        cnty.setMaximum(10000)
        cnty.setValue(self.bbox.center[1])
        self.controls['cnty'] = cnty
        cntz = QDoubleSpinBox()
        cntz.setMinimum(-10000)
        cntz.setMaximum(10000)
        cntz.setValue(self.bbox.center[2])
        self.controls['cntz'] = cntz
        grplay.addWidget(QLabel('<b>Center</b>'), 1, 0)
        grplay.addWidget(QLabel('X'), 1, 1)
        grplay.addWidget(cntx, 1, 2)
        grplay.addWidget(QLabel('Y'), 1, 3)
        grplay.addWidget(cnty, 1, 4)
        grplay.addWidget(QLabel('Z'), 1, 5)
        grplay.addWidget(cntz, 1, 6)
        # Radius.
        radius = QDoubleSpinBox()
        cntz.setMinimum(0)
        cntz.setMaximum(10000)
        radius.setValue(self.bbox.radius)
        self.controls['radius'] = radius
        grplay.addWidget(QLabel('<b>BSphereRadius'), 2, 0)
        grplay.addWidget(radius, 2, 1, 1, 2)

        grp.setLayout(grplay)
        # Buttons.
        save_btn = QPushButton('Save')
        save_btn.clicked.connect(self.save)
        cancel_btn = QPushButton('Cancel')
        cancel_btn.clicked.connect(self.close)
        btns = QHBoxLayout()
        btns.addStretch()
        btns.addWidget(save_btn)
        btns.addWidget(cancel_btn)

        # Main Layout.
        mainlay = QVBoxLayout()
        mainlay.addWidget(grp)
        mainlay.addLayout(btns)
        mainlay.addStretch()

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 400, 100)
        self.setWindowTitle('MSH Suite - Edit BBox')
        self.show()
class Form(QDialog):
    def __init__(self, parent=None):

        self.rates = {}
        super(Form, self).__init__(parent)

        date = self.get_data()
        rates = sorted(self.rates.keys())

        # Create UI Elements -------------------------------------------------------------------------------------------
        dateLabel = QLabel(date)
        self.fromComboBox = QComboBox()
        self.toComboBox = QComboBox()

        self.fromComboBox.addItems(rates)
        self.toComboBox.addItems(rates)

        self.fromSpinBox = QDoubleSpinBox()

        # Saturation of minimum and maximum values
        self.fromSpinBox.setRange(0.01, 1000)
        # Set initial value
        self.fromSpinBox.setValue(1.00)

        self.toLabel = QLabel('1.00')

        # Layout -------------------------------------------------------------------------------------------------------
        layout = QGridLayout()
        # addWidget (Widget, row, column)
        layout.addWidget(dateLabel, 0, 0)
        layout.addWidget(self.fromComboBox, 1, 0)
        layout.addWidget(self.toComboBox, 2, 0)
        layout.addWidget(self.fromSpinBox, 1, 1)
        layout.addWidget(self.toLabel, 2, 1)
        self.setLayout(layout)

        # Signals ------------------------------------------------------------------------------------------------------
        self.fromComboBox.currentIndexChanged.connect(self.update_ui)
        self.toComboBox.currentIndexChanged.connect(self.update_ui)

        self.fromSpinBox.valueChanged.connect(self.update_ui)


        # Force window to stay on top when start
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

    def get_data(self):
        date = 'Unknown'

        url = "http://www.bankofcanada.ca/en/markets/csv/exchange_eng.csv"
        try:
            date = None
            fh = urllib2.urlopen(url)
            for line in fh:
                line = line.rstrip()
                if not line or line.startswith(("#", "Closing ")):
                    continue
                fields = line.split(",")
                if line.startswith("Date "):
                    date = fields[-1]
                else:
                    try:
                        value = float(fields[-1])
                        self.rates[unicode(fields[0])] = value
                    except ValueError:
                        pass
            return "Exchange Rates Date: " + date
        except Exception, e:
            return "Failed to download: \n%s" % e
Exemple #35
0
    def __init__(self, parent=None):
        super(Double4, self).__init__(parent)
        self.w = QDoubleSpinBox()
        self.layout().addWidget(self.w)

        self.w.valueChanged.connect(self.element_value_changed)
class ProfileFormWidget(QWidget):
    '''
    classdocs
    '''
    def __init__(self):
        '''
        Constructor
        '''
        QWidget.__init__(self)
        self._initGUI()

    def _initGUI(self):
        self.layout = QVBoxLayout()
        self.form = QFormLayout()

        self.name = QLineEdit()
        self.surname = QLineEdit()

        self.birthdate = QCalendarWidget()
        self.birthdate.setGridVisible(True)
        self.birthdate.setMinimumDate(QDate(1850, 1, 1))
        self.birthdate.setMaximumDate(QDate.currentDate())

        self.male = QRadioButton("Male")
        self.male.setChecked(True)
        self.female = QRadioButton("Female")

        self.height = QDoubleSpinBox()
        self.height.setMaximum(250)
        self.height.setMinimum(50)
        self.height.setValue(165)
        self.height.setSuffix(" cm")

        self.mass = QDoubleSpinBox()
        self.mass.setMaximum(300)
        self.mass.setMinimum(20)
        self.mass.setValue(60)
        self.mass.setSuffix(" Kg")

        btnLayout = QVBoxLayout()

        self.form.addRow("Name", self.name)
        self.form.addRow("Surname", self.surname)
        self.form.addRow("Birth date", self.birthdate)

        sexLayout = QHBoxLayout()
        sexLayout.addWidget(self.male)
        sexLayout.addWidget(self.female)
        self.form.addRow("Sex", sexLayout)

        self.form.addRow("Height", self.height)
        self.form.addRow("Mass", self.mass)

        self.layout.addLayout(self.form)
        self.layout.addLayout(btnLayout)
        self.setLayout(self.layout)

    def getLayout(self):
        return self.layout

    def getWidget(self):
        widget = QWidget()
        widget.setLayout(self.layout)

        return widget

    def setProfile(self, athlete):
        self.name.setText(athlete._name)
        self.surname.setText(athlete._surname)
        self.birthdate.setSelectedDate(athlete._birthDate)

        if athlete._sex == "Male":
            self.male.setChecked(True)
        else:
            self.female.setChecked(True)

        self.height.setValue(athlete._height)
        self.mass.setValue(athlete._mass)

    def getProfile(self):
        qDate = self.birthdate.selectedDate()
        birthDate = self.qDate_to_date(qDate)

        athleteProfile = Athlete(self.name.text(), self.surname.text(),
                                 self._getSex(), birthDate,
                                 self.height.value(), self.mass.value())
        return athleteProfile

    def qDate_to_date(self, qDate):
        return date(qDate.year(), qDate.month(), qDate.day())

    def _getSex(self):
        if (self.male.isChecked()):
            return "Male"
        elif (self.female.isChecked()):
            return "Female"
        else:
            print "Error: No sex selected"
            return False
class ConfigDialog(QtGui.QDialog):

    pressedclosebutton = False
    moreToggling = False

    def moreToggled(self):
        if self.moreToggling == False:
            self.moreToggling = True

            if self.showmoreCheckbox.isChecked():
                self.tabListFrame.show()
                self.resetButton.show()
                self.nostoreCheckbox.show()
                self.alwaysshowCheckbox.show()
                self.saveMoreState(True)
                self.tabListWidget.setCurrentRow(0)
                self.ensureTabListIsVisible()
            else:
                self.tabListFrame.hide()
                self.resetButton.hide()
                self.nostoreCheckbox.hide()
                self.alwaysshowCheckbox.hide()
                self.saveMoreState(False)
                self.stackedLayout.setCurrentIndex(0)

            self.adjustSize()
            self.setFixedSize(self.sizeHint())
        self.moreToggling = False
        self.setFixedWidth(self.minimumSizeHint().width())
        self.executablepathCombobox.setFixedWidth(self.mediapathTextbox.width())

    def runButtonTextUpdate(self):
        if self.nostoreCheckbox.isChecked():
            self.runButton.setText(getMessage("run-label"))
        else:
            self.runButton.setText(getMessage("storeandrun-label"))

    def openHelp(self):
        self.QtGui.QDesktopServices.openUrl("http://syncplay.pl/guide/client/")

    def _tryToFillPlayerPath(self, playerpath, playerpathlist):
        settings = QSettings("Syncplay", "PlayerList")
        settings.beginGroup("PlayerList")
        savedPlayers = settings.value("PlayerList", [])
        if not isinstance(savedPlayers, list):
            savedPlayers = []
        playerpathlist = list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist + savedPlayers)))
        settings.endGroup()
        foundpath = ""

        if playerpath != None and playerpath != "":
            if not os.path.isfile(playerpath):
                expandedpath = PlayerFactory().getExpandedPlayerPathByPath(playerpath)
                if expandedpath != None and os.path.isfile(expandedpath):
                    playerpath = expandedpath

            if os.path.isfile(playerpath):
                foundpath = playerpath
                self.executablepathCombobox.addItem(foundpath)

        for path in playerpathlist:
            if os.path.isfile(path) and os.path.normcase(os.path.normpath(path)) != os.path.normcase(os.path.normpath(foundpath)):
                self.executablepathCombobox.addItem(path)
                if foundpath == "":
                    foundpath = path

        if foundpath != "":
            settings.beginGroup("PlayerList")
            playerpathlist.append(os.path.normcase(os.path.normpath(foundpath)))
            settings.setValue("PlayerList", list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist))))
            settings.endGroup()
        return foundpath

    def updateExecutableIcon(self):
        currentplayerpath = unicode(self.executablepathCombobox.currentText())
        iconpath = PlayerFactory().getPlayerIconByPath(currentplayerpath)
        if iconpath != None and iconpath != "":
            self.executableiconImage.load(self.resourcespath + iconpath)
            self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(self.executableiconImage))
        else:
            self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage()))


    def browsePlayerpath(self):
        options = QtGui.QFileDialog.Options()
        defaultdirectory = ""
        browserfilter = "All files (*)"

        if os.name == 'nt':
            browserfilter = "Executable files (*.exe);;All files (*)"
            if "PROGRAMFILES(X86)" in os.environ:
                defaultdirectory = os.environ["ProgramFiles(x86)"]
            elif "PROGRAMFILES" in os.environ:
                defaultdirectory = os.environ["ProgramFiles"]
            elif "PROGRAMW6432" in os.environ:
                defaultdirectory = os.environ["ProgramW6432"]
        elif sys.platform.startswith('linux'):
            defaultdirectory = "/usr/bin"
        elif sys.platform.startswith('darwin'):
            defaultdirectory = "/Applications/"

        fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,
                "Browse for media player executable",
                defaultdirectory,
                browserfilter, "", options)
        if fileName:
            self.executablepathCombobox.setEditText(os.path.normpath(fileName))

    def loadMediaBrowseSettings(self):
        settings = QSettings("Syncplay", "MediaBrowseDialog")
        settings.beginGroup("MediaBrowseDialog")
        self.mediadirectory = settings.value("mediadir", "")
        settings.endGroup()

    def saveMediaBrowseSettings(self):
        settings = QSettings("Syncplay", "MediaBrowseDialog")
        settings.beginGroup("MediaBrowseDialog")
        settings.setValue("mediadir", self.mediadirectory)
        settings.endGroup()

    def getMoreState(self):
        settings = QSettings("Syncplay", "MoreSettings")
        settings.beginGroup("MoreSettings")
        morestate = unicode.lower(unicode(settings.value("ShowMoreSettings", "false")))
        settings.endGroup()
        if morestate == "true":
            return True
        else:
            return False

    def saveMoreState(self, morestate):
        settings = QSettings("Syncplay", "MoreSettings")
        settings.beginGroup("MoreSettings")
        settings.setValue("ShowMoreSettings", morestate)
        settings.endGroup()

    def browseMediapath(self):
        self.loadMediaBrowseSettings()
        options = QtGui.QFileDialog.Options()
        if os.path.isdir(self.mediadirectory):
            defaultdirectory = self.mediadirectory
        elif os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)):
            defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)
        elif os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)):
            defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
        else:
            defaultdirectory = ""
        browserfilter = "All files (*)"
        fileName, filtr = QtGui.QFileDialog.getOpenFileName(self, "Browse for media files", defaultdirectory,
                browserfilter, "", options)
        if fileName:
            self.mediapathTextbox.setText(os.path.normpath(fileName))
            self.mediadirectory = os.path.dirname(fileName)
            self.saveMediaBrowseSettings()

    def _saveDataAndLeave(self):
        self.processWidget(self, lambda w: self.saveValues(w))
        if self.hostTextbox.text():
            self.config['host'] = self.hostTextbox.text() if ":" in self.hostTextbox.text() else self.hostTextbox.text() + ":" + unicode(constants.DEFAULT_PORT)
        else:
            self.config['host'] = None
        self.config['playerPath'] = unicode(self.executablepathCombobox.currentText())
        if self.mediapathTextbox.text() == "":
            self.config['file'] = None
        elif os.path.isfile(os.path.abspath(self.mediapathTextbox.text())):
            self.config['file'] = os.path.abspath(self.mediapathTextbox.text())
        else:
            self.config['file'] = unicode(self.mediapathTextbox.text())

        if not self.slowdownThresholdSpinbox.text:
            self.slowdownThresholdSpinbox.value = constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD
        if not self.rewindThresholdSpinbox.text:
            self.rewindThresholdSpinbox.value = constants.DEFAULT_REWIND_THRESHOLD
        self.config['slowdownThreshold'] = self.slowdownThresholdSpinbox.value()
        self.config['rewindThreshold'] = self.rewindThresholdSpinbox.value()

        self.pressedclosebutton = True
        self.close()
        return

    def closeEvent(self, event):
        if self.pressedclosebutton == False:
            sys.exit()
            raise GuiConfiguration.WindowClosed
            event.accept()

    def dragEnterEvent(self, event):
        data = event.mimeData()
        urls = data.urls()
        if urls and urls[0].scheme() == 'file':
            event.acceptProposedAction()

    def dropEvent(self, event):
        data = event.mimeData()
        urls = data.urls()
        if urls and urls[0].scheme() == 'file':
            if sys.platform.startswith('win'):
                dropfilepath = unicode(urls[0].path())[1:]  # Removes starting slash
            else:
                dropfilepath = unicode(urls[0].path())
            if dropfilepath[-4:].lower() == ".exe":
                self.executablepathCombobox.setEditText(dropfilepath)
            else:
                self.mediapathTextbox.setText(dropfilepath)

    def processWidget(self, container, torun):
        for widget in container.children():
            self.processWidget(widget, torun)
            if hasattr(widget, 'objectName') and widget.objectName() and widget.objectName()[:3] != "qt_":
                torun(widget)

    def loadTooltips(self, widget):
        tooltipName = widget.objectName().lower().split(constants.CONFIG_NAME_MARKER)[0] + "-tooltip"
        if tooltipName[:1] == constants.INVERTED_STATE_MARKER or tooltipName[:1] == constants.LOAD_SAVE_MANUALLY_MARKER:
            tooltipName = tooltipName[1:]
        widget.setToolTip(getMessage(tooltipName))

    def loadValues(self, widget):
        valueName = str(widget.objectName())
        if valueName[:1] == constants.LOAD_SAVE_MANUALLY_MARKER:
            return

        if isinstance(widget, QCheckBox) and widget.objectName():
            if valueName[:1] == constants.INVERTED_STATE_MARKER:
                valueName = valueName[1:]
                inverted = True
            else:
                inverted = False
            widget.setChecked(self.config[valueName] != inverted)
        elif isinstance(widget, QRadioButton):
            radioName, radioValue  = valueName.split(constants.CONFIG_NAME_MARKER)[1].split(constants.CONFIG_VALUE_MARKER)
            if self.config[radioName] == radioValue:
                widget.setChecked(True)
        elif isinstance(widget, QLineEdit):
            widget.setText(self.config[valueName])

    def saveValues(self, widget):
        valueName = str(widget.objectName())
        if valueName[:1] == constants.LOAD_SAVE_MANUALLY_MARKER:
            return

        if isinstance(widget, QCheckBox) and widget.objectName():
            if valueName[:1] == constants.INVERTED_STATE_MARKER:
                valueName = valueName[1:]
                inverted = True
            else:
                inverted = False
            self.config[valueName] = widget.isChecked() != inverted
        elif isinstance(widget, QRadioButton):
            radioName, radioValue  = valueName.split(constants.CONFIG_NAME_MARKER)[1].split(constants.CONFIG_VALUE_MARKER)
            if widget.isChecked():
                self.config[radioName] = radioValue
        elif isinstance(widget, QLineEdit):
            self.config[valueName] = widget.text()

    def connectChildren(self, widget):
        widgetName = str(widget.objectName())
        if self.subitems.has_key(widgetName) and isinstance(widget, QCheckBox):
            widget.stateChanged.connect(lambda: self.updateSubwidgets(self, widget))
            self.updateSubwidgets(self, widget)

    def updateSubwidgets(self, container, parentwidget, subwidgets=None):
        widgetName = parentwidget.objectName()
        if not subwidgets:
            subwidgets = self.subitems[widgetName]
        for widget in container.children():
            self.updateSubwidgets(widget, parentwidget, subwidgets)
            if hasattr(widget, 'objectName') and widget.objectName() and widget.objectName() in subwidgets:
                widget.setDisabled(not parentwidget.isChecked())

    def addBasicTab(self):
        config = self.config
        playerpaths = self.playerpaths
        resourcespath = self.resourcespath
        error = self.error
        if self.datacleared == True:
            error = constants.ERROR_MESSAGE_MARKER + "{}".format(getMessage("gui-data-cleared-notification"))
        if config['host'] == None:
            host = ""
        elif ":" in config['host']:
            host = config['host']
        else:
            host = config['host'] + ":" + str(config['port'])

        self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title"))
        self.hostTextbox = QLineEdit(host, self)
        self.hostLabel = QLabel(getMessage("host-label"), self)
        self.usernameTextbox = QLineEdit(self)
        self.usernameTextbox.setObjectName("name")
        self.serverpassLabel = QLabel(getMessage("password-label"), self)
        self.defaultroomTextbox = QLineEdit(self)
        self.usernameLabel = QLabel(getMessage("name-label"), self)
        self.serverpassTextbox = QLineEdit(self)
        self.defaultroomLabel = QLabel(getMessage("room-label"), self)

        self.hostLabel.setObjectName("host")
        self.hostTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "host")
        self.usernameLabel.setObjectName("name")
        self.usernameTextbox.setObjectName("name")
        self.serverpassLabel.setObjectName("password")
        self.serverpassTextbox.setObjectName("password")
        self.defaultroomLabel.setObjectName("room")
        self.defaultroomTextbox.setObjectName("room")

        self.connectionSettingsLayout = QtGui.QGridLayout()
        self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0)
        self.connectionSettingsLayout.addWidget(self.hostTextbox, 0, 1)
        self.connectionSettingsLayout.addWidget(self.serverpassLabel, 1, 0)
        self.connectionSettingsLayout.addWidget(self.serverpassTextbox, 1, 1)
        self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0)
        self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1)
        self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0)
        self.connectionSettingsLayout.addWidget(self.defaultroomTextbox, 3, 1)
        self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)

        self.mediaplayerSettingsGroup = QtGui.QGroupBox(getMessage("media-setting-title"))
        self.executableiconImage = QtGui.QImage()
        self.executableiconLabel = QLabel(self)
        self.executableiconLabel.setMinimumWidth(16)
        self.executablepathCombobox = QtGui.QComboBox(self)
        self.executablepathCombobox.setEditable(True)
        self.executablepathCombobox.currentIndexChanged.connect(self.updateExecutableIcon)
        self.executablepathCombobox.setEditText(self._tryToFillPlayerPath(config['playerPath'], playerpaths))
        self.executablepathCombobox.setFixedWidth(165)
        self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon)

        self.executablepathLabel = QLabel(getMessage("executable-path-label"), self)
        self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("browse-label"))
        self.executablebrowseButton.clicked.connect(self.browsePlayerpath)
        self.mediapathTextbox = QLineEdit(config['file'], self)
        self.mediapathLabel = QLabel(getMessage("media-path-label"), self)
        self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("browse-label"))
        self.mediabrowseButton.clicked.connect(self.browseMediapath)

        self.executablepathLabel.setObjectName("executable-path")
        self.executablepathCombobox.setObjectName("executable-path")
        self.mediapathLabel.setObjectName("media-path")
        self.mediapathTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "media-path")

        self.mediaplayerSettingsLayout = QtGui.QGridLayout()
        self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0)
        self.mediaplayerSettingsLayout.addWidget(self.executableiconLabel, 0, 1)
        self.mediaplayerSettingsLayout.addWidget(self.executablepathCombobox, 0, 2)
        self.mediaplayerSettingsLayout.addWidget(self.executablebrowseButton, 0, 3)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 2)
        self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 3)
        self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout)

        self.showmoreCheckbox = QCheckBox(getMessage("more-title"))
        self.showmoreCheckbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "more")

        self.basicOptionsFrame = QtGui.QFrame()
        self.basicOptionsLayout = QtGui.QVBoxLayout()
        if error:
            self.errorLabel = QLabel(self)
            if error[:1] != constants.ERROR_MESSAGE_MARKER:
                self.errorLabel.setStyleSheet(constants.STYLE_ERRORLABEL)
            else:
                error = error[1:]
                self.errorLabel.setStyleSheet(constants.STYLE_SUCCESSLABEL)
            self.errorLabel.setText(error)
            self.errorLabel.setAlignment(Qt.AlignCenter)

            self.basicOptionsLayout.addWidget(self.errorLabel, 0, 0)
        self.basicOptionsLayout.addWidget(self.connectionSettingsGroup)
        self.basicOptionsLayout.addSpacing(12)
        self.basicOptionsLayout.addWidget(self.mediaplayerSettingsGroup)

        self.basicOptionsFrame.setLayout(self.basicOptionsLayout)
        self.stackedLayout.addWidget(self.basicOptionsFrame)

    def addSyncTab(self):
        self.syncSettingsFrame = QtGui.QFrame()
        self.syncSettingsLayout = QtGui.QVBoxLayout()

        self.desyncSettingsGroup = QtGui.QGroupBox("If others are lagging behind...")
        self.desyncOptionsFrame = QtGui.QFrame()
        self.desyncSettingsOptionsLayout = QtGui.QHBoxLayout()
        config = self.config

        self.slowdownCheckbox = QCheckBox(getMessage("slowondesync-label"))
        self.slowdownCheckbox.setObjectName("slowOnDesync")
        self.rewindCheckbox = QCheckBox(getMessage("rewindondesync-label"))
        self.rewindCheckbox.setObjectName("rewindOnDesync")

        self.spaceLabel = QLabel()
        self.spaceLabel.setFixedHeight(5)

        self.desyncSettingsLayout = QtGui.QGridLayout()
        self.desyncSettingsLayout.setSpacing(2)
        self.desyncFrame = QtGui.QFrame()
        self.desyncFrame.setLineWidth(0)
        self.desyncFrame.setMidLineWidth(0)

        self.slowdownThresholdLabel = QLabel(getMessage("slowdown-threshold-label"), self)
        self.slowdownThresholdLabel.setStyleSheet(constants.STYLE_SUBLABEL.format(self.posixresourcespath + "bullet_black.png"))

        self.slowdownThresholdSpinbox = QDoubleSpinBox()
        try:
            slowdownThreshold = float(config['slowdownThreshold'])
            self.slowdownThresholdSpinbox.setValue(slowdownThreshold)
            if slowdownThreshold < constants.MINIMUM_SLOWDOWN_THRESHOLD:
                constants.MINIMUM_SLOWDOWN_THRESHOLD = slowdownThreshold
        except ValueError:
            self.slowdownThresholdSpinbox.setValue(constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD)
        self.slowdownThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.slowdownThresholdSpinbox.setMinimum(constants.MINIMUM_SLOWDOWN_THRESHOLD)
        self.slowdownThresholdSpinbox.setSingleStep(0.1)
        self.slowdownThresholdSpinbox.setSuffix(getMessage("seconds-suffix"))
        self.slowdownThresholdSpinbox.adjustSize()

        self.rewindThresholdLabel = QLabel(getMessage("rewind-threshold-label"), self)
        self.rewindThresholdLabel.setStyleSheet(constants.STYLE_SUBLABEL.format(self.posixresourcespath + "bullet_black.png"))
        self.rewindThresholdSpinbox = QDoubleSpinBox()
        try:
            rewindThreshold = float(config['rewindThreshold'])
            self.rewindThresholdSpinbox.setValue(rewindThreshold)
            if rewindThreshold < constants.MINIMUM_REWIND_THRESHOLD:
                constants.MINIMUM_REWIND_THRESHOLD = rewindThreshold
        except ValueError:
            self.rewindThresholdSpinbox.setValue(constants.DEFAULT_REWIND_THRESHOLD)
        self.rewindThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.rewindThresholdSpinbox.setMinimum(constants.MINIMUM_REWIND_THRESHOLD)
        self.rewindThresholdSpinbox.setSingleStep(0.1)
        self.rewindThresholdSpinbox.setSuffix(getMessage("seconds-suffix"))
        self.rewindThresholdSpinbox.adjustSize()

        self.slowdownThresholdLabel.setObjectName("slowdown-threshold")
        self.slowdownThresholdSpinbox.setObjectName("slowdown-threshold")
        self.rewindThresholdLabel.setObjectName("rewind-threshold")
        self.rewindThresholdSpinbox.setObjectName("rewind-threshold")

        self.desyncSettingsLayout.addWidget(self.slowdownCheckbox, 0, 0, 1, 2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.slowdownThresholdLabel, 1, 0, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.slowdownThresholdSpinbox, 1, 1, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.spaceLabel, 2, 0,1,2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindCheckbox, 3, 0,1,2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindThresholdLabel, 4, 0, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindThresholdSpinbox, 4, 1, Qt.AlignLeft)

        self.subitems['slowOnDesync'] = ["slowdown-threshold"]
        self.subitems['rewindOnDesync'] = ["rewind-threshold"]

        self.desyncSettingsLayout.setAlignment(Qt.AlignLeft)
        self.desyncSettingsGroup.setLayout(self.desyncSettingsLayout)
        self.desyncSettingsOptionsLayout.addWidget(self.desyncFrame)
        self.syncSettingsLayout.addWidget(self.desyncSettingsGroup)
        self.desyncFrame.setLayout(self.syncSettingsLayout)

        self.othersyncSettingsGroup = QtGui.QGroupBox("Other sync options")
        self.othersyncOptionsFrame = QtGui.QFrame()
        self.othersyncSettingsLayout = QtGui.QGridLayout()


        self.dontslowwithmeCheckbox = QCheckBox(getMessage("dontslowdownwithme-label"))
        self.pauseonleaveCheckbox = QCheckBox(getMessage("pauseonleave-label"))
        self.othersyncSettingsLayout.addWidget(self.dontslowwithmeCheckbox)
        self.othersyncSettingsLayout.addWidget(self.pauseonleaveCheckbox)
        self.dontslowwithmeCheckbox.setObjectName("dontSlowDownWithMe")
        self.pauseonleaveCheckbox.setObjectName("pauseOnLeave")

        self.othersyncSettingsGroup.setLayout(self.othersyncSettingsLayout)
        self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup)

        self.syncSettingsFrame.setLayout(self.syncSettingsLayout)
        self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height())
        self.syncSettingsLayout.setAlignment(Qt.AlignTop)
        self.stackedLayout.addWidget(self.syncSettingsFrame)

    def addMessageTab(self):
        self.messageFrame = QtGui.QFrame()
        self.messageLayout = QtGui.QVBoxLayout()

        # OSD
        self.osdSettingsGroup = QtGui.QGroupBox("On-screen Display settings")
        self.osdSettingsLayout = QtGui.QVBoxLayout()
        self.osdSettingsFrame = QtGui.QFrame()

        self.showOSDCheckbox = QCheckBox(getMessage("showosd-label"))
        self.showOSDCheckbox.setObjectName("showOSD")
        self.osdSettingsLayout.addWidget(self.showOSDCheckbox)

        self.showSameRoomOSDCheckbox = QCheckBox(getMessage("showsameroomosd-label"))
        self.showSameRoomOSDCheckbox.setObjectName("showSameRoomOSD")
        self.showSameRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.showSameRoomOSDCheckbox)

        self.showDifferentRoomOSDCheckbox = QCheckBox(getMessage("showdifferentroomosd-label"))
        self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD")
        self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.showDifferentRoomOSDCheckbox)

        self.slowdownOSDCheckbox = QCheckBox(getMessage("showslowdownosd-label"))
        self.slowdownOSDCheckbox.setObjectName("showSlowdownOSD")
        self.slowdownOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.slowdownOSDCheckbox)

        self.showOSDWarningsCheckbox = QCheckBox(getMessage("showosdwarnings-label"))
        self.showOSDWarningsCheckbox.setObjectName("showOSDWarnings")
        self.showOSDWarningsCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.showOSDWarningsCheckbox)

        self.subitems['showOSD'] = ["showSameRoomOSD", "showDifferentRoomOSD", "showSlowdownOSD", "showOSDWarnings"]

        self.osdSettingsGroup.setLayout(self.osdSettingsLayout)
        self.osdSettingsLayout.setAlignment(Qt.AlignTop)
        self.messageLayout.addWidget(self.osdSettingsGroup)

        # Other display

        self.displaySettingsGroup = QtGui.QGroupBox("Other display settings")
        self.displaySettingsLayout = QtGui.QVBoxLayout()
        self.displaySettingsFrame = QtGui.QFrame()

        self.showDurationNotificationCheckbox = QCheckBox(getMessage("showdurationnotification-label"))
        self.showDurationNotificationCheckbox.setObjectName("showDurationNotification")
        self.displaySettingsLayout.addWidget(self.showDurationNotificationCheckbox)

        self.showcontactinfoCheckbox = QCheckBox(getMessage("showcontactinfo-label"))
        self.showcontactinfoCheckbox.setObjectName("showContactInfo")
        self.displaySettingsLayout.addWidget(self.showcontactinfoCheckbox)

        self.showButtonLabelsCheckbox = QCheckBox(getMessage("showbuttonlabels-label"))
        self.showButtonLabelsCheckbox.setObjectName("showButtonLabels")
        self.displaySettingsLayout.addWidget(self.showButtonLabelsCheckbox)

        self.showTooltipsCheckbox = QCheckBox(getMessage("showtooltips-label"))
        self.showTooltipsCheckbox.setObjectName("showTooltips")
        self.displaySettingsLayout.addWidget(self.showTooltipsCheckbox)


        self.displaySettingsGroup.setLayout(self.displaySettingsLayout)
        self.displaySettingsLayout.setAlignment(Qt.AlignTop)
        self.messageLayout.addWidget(self.displaySettingsGroup)

        # messageFrame
        self.messageFrame.setLayout(self.messageLayout)
        self.stackedLayout.addWidget(self.messageFrame)

    def addPrivacyTab(self):
        self.privacySettingsGroup = QtGui.QGroupBox("Privacy settings")
        self.privacySettingsLayout = QtGui.QVBoxLayout()
        self.privacySettingsFrame = QtGui.QFrame()
        self.privacyFrame = QtGui.QFrame()
        self.privacyLayout = QtGui.QGridLayout()

        self.filenameprivacyLabel = QLabel(getMessage("filename-privacy-label"), self)
        self.filenameprivacyButtonGroup = QButtonGroup()
        self.filenameprivacySendRawOption = QRadioButton(getMessage("privacy-sendraw-option"))
        self.filenameprivacySendHashedOption = QRadioButton(getMessage("privacy-sendhashed-option"))
        self.filenameprivacyDontSendOption = QRadioButton(getMessage("privacy-dontsend-option"))
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendRawOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendHashedOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacyDontSendOption)

        self.filesizeprivacyLabel = QLabel(getMessage("filesize-privacy-label"), self)
        self.filesizeprivacyButtonGroup = QButtonGroup()
        self.filesizeprivacySendRawOption = QRadioButton(getMessage("privacy-sendraw-option"))
        self.filesizeprivacySendHashedOption = QRadioButton(getMessage("privacy-sendhashed-option"))
        self.filesizeprivacyDontSendOption = QRadioButton(getMessage("privacy-dontsend-option"))
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendRawOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption)

        self.filenameprivacyLabel.setObjectName("filename-privacy")
        self.filenameprivacySendRawOption.setObjectName("privacy-sendraw" + constants.CONFIG_NAME_MARKER + "filenamePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDRAW_MODE)
        self.filenameprivacySendHashedOption.setObjectName("privacy-sendhashed" + constants.CONFIG_NAME_MARKER + "filenamePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDHASHED_MODE)
        self.filenameprivacyDontSendOption.setObjectName("privacy-dontsend" + constants.CONFIG_NAME_MARKER + "filenamePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_DONTSEND_MODE)
        self.filesizeprivacyLabel.setObjectName("filesize-privacy")
        self.filesizeprivacySendRawOption.setObjectName("privacy-sendraw" + constants.CONFIG_NAME_MARKER + "filesizePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDRAW_MODE)
        self.filesizeprivacySendHashedOption.setObjectName("privacy-sendhashed" + constants.CONFIG_NAME_MARKER + "filesizePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDHASHED_MODE)
        self.filesizeprivacyDontSendOption.setObjectName("privacy-dontsend" + constants.CONFIG_NAME_MARKER + "filesizePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_DONTSEND_MODE)

        self.privacyLayout.addWidget(self.filenameprivacyLabel, 1, 0)
        self.privacyLayout.addWidget(self.filenameprivacySendRawOption, 1, 1, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filenameprivacySendHashedOption, 1, 2, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filenameprivacyDontSendOption, 1, 3, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filesizeprivacyLabel, 2, 0)
        self.privacyLayout.addWidget(self.filesizeprivacySendRawOption, 2, 1, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filesizeprivacySendHashedOption, 2, 2, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filesizeprivacyDontSendOption, 2, 3, Qt.AlignLeft)

        self.privacyFrame.setLayout(self.privacyLayout)
        self.privacySettingsGroup.setLayout(self.privacyLayout)
        self.privacySettingsGroup.setMaximumHeight(self.privacySettingsGroup.minimumSizeHint().height())
        self.privacySettingsLayout.addWidget(self.privacySettingsGroup)
        self.privacySettingsLayout.setAlignment(Qt.AlignTop)
        self.privacyFrame.setLayout(self.privacySettingsLayout)
        self.stackedLayout.addWidget(self.privacyFrame)

    def addBottomLayout(self):
        config = self.config
        resourcespath = self.resourcespath

        self.bottomButtonFrame = QtGui.QFrame()
        self.bottomButtonLayout = QtGui.QHBoxLayout()
        self.helpButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'help.png'), getMessage("help-label"))
        self.helpButton.setObjectName("help")
        self.helpButton.setMaximumSize(self.helpButton.sizeHint())
        self.helpButton.pressed.connect(self.openHelp)

        self.resetButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'cog_delete.png'),getMessage("reset-label"))
        self.resetButton.setMaximumSize(self.resetButton.sizeHint())
        self.resetButton.setObjectName("reset")
        self.resetButton.pressed.connect(self.resetSettings)

        self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'), getMessage("storeandrun-label"))
        self.runButton.pressed.connect(self._saveDataAndLeave)
        self.bottomButtonLayout.addWidget(self.helpButton)
        self.bottomButtonLayout.addWidget(self.resetButton)
        self.bottomButtonLayout.addWidget(self.runButton)
        self.bottomButtonFrame.setLayout(self.bottomButtonLayout)
        if config['noStore'] == True:
            self.runButton.setText(getMessage("run-label"))
        self.bottomButtonLayout.setContentsMargins(5,0,5,0)
        self.mainLayout.addWidget(self.bottomButtonFrame, 1, 0, 1, 2)

        self.bottomCheckboxFrame = QtGui.QFrame()
        self.bottomCheckboxFrame.setContentsMargins(0,0,0,0)
        self.bottomCheckboxLayout = QtGui.QGridLayout()
        self.alwaysshowCheckbox = QCheckBox(getMessage("forceguiprompt-label"))

        self.nostoreCheckbox = QCheckBox(getMessage("nostore-label"))
        self.bottomCheckboxLayout.addWidget(self.showmoreCheckbox)
        self.bottomCheckboxLayout.addWidget(self.alwaysshowCheckbox, 0, 1, Qt.AlignLeft)
        self.bottomCheckboxLayout.addWidget(self.nostoreCheckbox, 0, 2, Qt.AlignRight)
        self.alwaysshowCheckbox.setObjectName(constants.INVERTED_STATE_MARKER + "forceGuiPrompt")
        self.nostoreCheckbox.setObjectName("noStore")
        self.nostoreCheckbox.toggled.connect(self.runButtonTextUpdate)
        self.bottomCheckboxFrame.setLayout(self.bottomCheckboxLayout)
        self.mainLayout.addWidget(self.bottomCheckboxFrame, 2, 0, 1, 2)

    def tabList(self):
        self.tabListLayout = QtGui.QHBoxLayout()
        self.tabListFrame = QtGui.QFrame()
        self.tabListWidget = QtGui.QListWidget()
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "house.png"),getMessage("basics-label")))
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "film_link.png"),getMessage("sync-label")))
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "comments.png"),getMessage("messages-label")))
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "eye.png"),getMessage("privacy-label")))
        self.tabListLayout.addWidget(self.tabListWidget)
        self.tabListFrame.setLayout(self.tabListLayout)
        self.tabListFrame.setFixedWidth(self.tabListFrame.minimumSizeHint().width())
        self.tabListWidget.setStyleSheet(constants.STYLE_TABLIST)

        self.tabListWidget.currentItemChanged.connect(self.tabChange)
        self.tabListWidget.itemClicked.connect(self.tabChange)
        self.tabListWidget.itemPressed.connect(self.tabChange)
        self.mainLayout.addWidget(self.tabListFrame, 0, 0, 1, 1)

    def ensureTabListIsVisible(self):
        self.stackedFrame.setFixedWidth(self.stackedFrame.width())
        while self.tabListWidget.horizontalScrollBar().isVisible() and self.tabListFrame.width() < 200:
            self.tabListFrame.setFixedWidth(self.tabListFrame.width()+1)

    def tabChange(self):
        self.setFocus()
        self.stackedLayout.setCurrentIndex(self.tabListWidget.currentRow())

    def resetSettings(self):
        self.clearGUIData(leaveMore=True)
        self.config['resetConfig'] = True
        self.pressedclosebutton = True
        self.close()

    def showEvent(self, *args, **kwargs):
        self.ensureTabListIsVisible()
        self.setFixedWidth(self.minimumSizeHint().width())
        self.executablepathCombobox.setFixedWidth(self.mediapathTextbox.width())

    def clearGUIData(self, leaveMore=False):
        settings = QSettings("Syncplay", "PlayerList")
        settings.clear()
        settings = QSettings("Syncplay", "MediaBrowseDialog")
        settings.clear()
        settings = QSettings("Syncplay", "MainWindow")
        settings.clear()
        if not leaveMore:
            settings = QSettings("Syncplay", "MoreSettings")
            settings.clear()
        self.datacleared = True

    def __init__(self, config, playerpaths, error, defaultConfig):

        from syncplay import utils
        self.config = config
        self.defaultConfig = defaultConfig
        self.playerpaths = playerpaths
        self.datacleared = False
        self.config['resetConfig'] = False
        self.subitems = {}

        if self.config['clearGUIData'] == True:
            self.config['clearGUIData'] = False
            self.clearGUIData()

        self.QtGui = QtGui
        self.error = error
        if sys.platform.startswith('win'):
            resourcespath = utils.findWorkingDir() + "\\resources\\"
        else:
            resourcespath = utils.findWorkingDir() + "/resources/"
        self.posixresourcespath = utils.findWorkingDir().replace("\\","/") + "/resources/"
        self.resourcespath = resourcespath

        super(ConfigDialog, self).__init__()

        self.setWindowTitle(getMessage("config-window-title"))
        self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png"))

        self.stackedLayout = QtGui.QStackedLayout()
        self.stackedFrame = QtGui.QFrame()
        self.stackedFrame.setLayout(self.stackedLayout)

        self.mainLayout = QtGui.QGridLayout()
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(0,0,0,0)

        self.addBasicTab()
        self.addSyncTab()
        self.addMessageTab()
        self.addPrivacyTab()
        self.tabList()

        self.mainLayout.addWidget(self.stackedFrame, 0, 1)
        self.addBottomLayout()


        if self.getMoreState() == False:
            self.tabListFrame.hide()
            self.nostoreCheckbox.hide()
            self.alwaysshowCheckbox.hide()
            self.resetButton.hide()
        else:
            self.showmoreCheckbox.setChecked(True)
            self.tabListWidget.setCurrentRow(0)

        self.showmoreCheckbox.toggled.connect(self.moreToggled)

        self.setLayout(self.mainLayout)
        self.runButton.setFocus()
        self.setFixedSize(self.sizeHint())
        self.setAcceptDrops(True)

        if constants.SHOW_TOOLTIPS:
            self.processWidget(self, lambda w: self.loadTooltips(w))
        self.processWidget(self, lambda w: self.loadValues(w))
        self.processWidget(self, lambda w: self.connectChildren(w))
    def addSyncTab(self):
        self.syncSettingsFrame = QtGui.QFrame()
        self.syncSettingsLayout = QtGui.QVBoxLayout()

        self.desyncSettingsGroup = QtGui.QGroupBox("If others are lagging behind...")
        self.desyncOptionsFrame = QtGui.QFrame()
        self.desyncSettingsOptionsLayout = QtGui.QHBoxLayout()
        config = self.config

        self.slowdownCheckbox = QCheckBox(getMessage("slowondesync-label"))
        self.slowdownCheckbox.setObjectName("slowOnDesync")
        self.rewindCheckbox = QCheckBox(getMessage("rewindondesync-label"))
        self.rewindCheckbox.setObjectName("rewindOnDesync")

        self.spaceLabel = QLabel()
        self.spaceLabel.setFixedHeight(5)

        self.desyncSettingsLayout = QtGui.QGridLayout()
        self.desyncSettingsLayout.setSpacing(2)
        self.desyncFrame = QtGui.QFrame()
        self.desyncFrame.setLineWidth(0)
        self.desyncFrame.setMidLineWidth(0)

        self.slowdownThresholdLabel = QLabel(getMessage("slowdown-threshold-label"), self)
        self.slowdownThresholdLabel.setStyleSheet(constants.STYLE_SUBLABEL.format(self.posixresourcespath + "bullet_black.png"))

        self.slowdownThresholdSpinbox = QDoubleSpinBox()
        try:
            slowdownThreshold = float(config['slowdownThreshold'])
            self.slowdownThresholdSpinbox.setValue(slowdownThreshold)
            if slowdownThreshold < constants.MINIMUM_SLOWDOWN_THRESHOLD:
                constants.MINIMUM_SLOWDOWN_THRESHOLD = slowdownThreshold
        except ValueError:
            self.slowdownThresholdSpinbox.setValue(constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD)
        self.slowdownThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.slowdownThresholdSpinbox.setMinimum(constants.MINIMUM_SLOWDOWN_THRESHOLD)
        self.slowdownThresholdSpinbox.setSingleStep(0.1)
        self.slowdownThresholdSpinbox.setSuffix(getMessage("seconds-suffix"))
        self.slowdownThresholdSpinbox.adjustSize()

        self.rewindThresholdLabel = QLabel(getMessage("rewind-threshold-label"), self)
        self.rewindThresholdLabel.setStyleSheet(constants.STYLE_SUBLABEL.format(self.posixresourcespath + "bullet_black.png"))
        self.rewindThresholdSpinbox = QDoubleSpinBox()
        try:
            rewindThreshold = float(config['rewindThreshold'])
            self.rewindThresholdSpinbox.setValue(rewindThreshold)
            if rewindThreshold < constants.MINIMUM_REWIND_THRESHOLD:
                constants.MINIMUM_REWIND_THRESHOLD = rewindThreshold
        except ValueError:
            self.rewindThresholdSpinbox.setValue(constants.DEFAULT_REWIND_THRESHOLD)
        self.rewindThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.rewindThresholdSpinbox.setMinimum(constants.MINIMUM_REWIND_THRESHOLD)
        self.rewindThresholdSpinbox.setSingleStep(0.1)
        self.rewindThresholdSpinbox.setSuffix(getMessage("seconds-suffix"))
        self.rewindThresholdSpinbox.adjustSize()

        self.slowdownThresholdLabel.setObjectName("slowdown-threshold")
        self.slowdownThresholdSpinbox.setObjectName("slowdown-threshold")
        self.rewindThresholdLabel.setObjectName("rewind-threshold")
        self.rewindThresholdSpinbox.setObjectName("rewind-threshold")

        self.desyncSettingsLayout.addWidget(self.slowdownCheckbox, 0, 0, 1, 2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.slowdownThresholdLabel, 1, 0, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.slowdownThresholdSpinbox, 1, 1, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.spaceLabel, 2, 0,1,2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindCheckbox, 3, 0,1,2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindThresholdLabel, 4, 0, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindThresholdSpinbox, 4, 1, Qt.AlignLeft)

        self.subitems['slowOnDesync'] = ["slowdown-threshold"]
        self.subitems['rewindOnDesync'] = ["rewind-threshold"]

        self.desyncSettingsLayout.setAlignment(Qt.AlignLeft)
        self.desyncSettingsGroup.setLayout(self.desyncSettingsLayout)
        self.desyncSettingsOptionsLayout.addWidget(self.desyncFrame)
        self.syncSettingsLayout.addWidget(self.desyncSettingsGroup)
        self.desyncFrame.setLayout(self.syncSettingsLayout)

        self.othersyncSettingsGroup = QtGui.QGroupBox("Other sync options")
        self.othersyncOptionsFrame = QtGui.QFrame()
        self.othersyncSettingsLayout = QtGui.QGridLayout()


        self.dontslowwithmeCheckbox = QCheckBox(getMessage("dontslowdownwithme-label"))
        self.pauseonleaveCheckbox = QCheckBox(getMessage("pauseonleave-label"))
        self.othersyncSettingsLayout.addWidget(self.dontslowwithmeCheckbox)
        self.othersyncSettingsLayout.addWidget(self.pauseonleaveCheckbox)
        self.dontslowwithmeCheckbox.setObjectName("dontSlowDownWithMe")
        self.pauseonleaveCheckbox.setObjectName("pauseOnLeave")

        self.othersyncSettingsGroup.setLayout(self.othersyncSettingsLayout)
        self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup)

        self.syncSettingsFrame.setLayout(self.syncSettingsLayout)
        self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height())
        self.syncSettingsLayout.setAlignment(Qt.AlignTop)
        self.stackedLayout.addWidget(self.syncSettingsFrame)
class SliderFloatWidget(QWidget):
	"""
	SliderFloatWidget
	"""
	valueChanged = Signal(int)

	def __init__(self):
		super(SliderFloatWidget, self).__init__()

		self.label = QLabel()
		self.slider = QSlider(Qt.Horizontal)
		self.spinbox = QDoubleSpinBox()

		self.slider.valueChanged.connect(self.changedValueFromSlider)
		self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(0)
		# layout.setHorizontalSpacing(0)
		layout.addWidget(self.label, 0, 0)
		layout.addWidget(self.slider, 0, 1)
		layout.addWidget(self.spinbox, 0, 2)
		self.setLayout(layout)

	def setName(self, name):
		"""
		Set the name for the slider
		"""
		self.label.setText(name)

	def setRange(self, range):
		"""
		Set the range for the value
		"""
		self.range = range
		self.slider.setMinimum(0)
		self.slider.setMaximum(100)
		self.spinbox.setRange(self.range[0], self.range[1])

		diff = self.range[1] - self.range[0]
		if diff <= 1:
			self.spinbox.setSingleStep(0.1)

	def setValue(self, value):
		"""
		Set the value for the slider and the spinbox
		"""
		ratio = (value - self.range[0]) / (self.range[1] - self.range[0])
		self.slider.setValue(ratio * 100)
		self.spinbox.setValue(value)

	def value(self):
		return self.spinbox.value()

	@Slot(int)
	def changedValueFromSlider(self, value):
		ratio = value / 100.0
		val = self.range[0] + ratio * (self.range[1] - self.range[0])
		self.spinbox.setValue(val)
		self.valueChanged.emit(val)

	@Slot(float)
	def changedValueFromSpinBox(self, value):
		ratio = (value - self.range[0]) / (self.range[1] - self.range[0])
		self.slider.setValue(ratio * 100)
		self.valueChanged.emit(value)
Exemple #40
0
class Layer(object):

    def __init__(self):
        super(Layer, self).__init__()
        self.orientation = Quaternion()
        self.picked = None
        self.show = QCheckBox()
        self.show.setChecked(True)
        self.alpha_slider = QSlider(QtCore.Qt.Orientation.Horizontal)
        self.alpha_slider.setRange(0, 1024)
        self.alpha_slider.setValue(1024)
        self.alpha_number = QDoubleSpinBox()
        self.alpha_number.setDecimals(3)
        self.alpha_number.setSingleStep(0.01)
        self.alpha_number.setRange(0, 1)
        self.alpha_number.setValue(1)
        self.alpha_slider.valueChanged.connect(self._alphaSliderChanged)
        self.alpha_number.valueChanged.connect(self._alphaNumberChanged)
        self.move = QCheckBox()
        self.move.setChecked(True)
        self.quat = QLineEdit()
        font = QFont('monospace')
        font.setStyleHint(QFont.TypeWriter)
        self.quat.setFont(font)
        default_quat = '+0.000, +1.000, +0.000, +0.000'
        margins = self.quat.textMargins()
        self.quat.setFixedWidth(
            # HACK -------------------------------------------v
            QFontMetrics(self.quat.font()).width(default_quat + '  ') +
            margins.left() + margins.right()
        )
        self.quat.setInputMask('#0.000, #0.000, #0.000, #0.000')
        self.quat.setMaxLength(30)
        self.quat.setText(default_quat)
        self.quat.editingFinished.connect(self._orientationChanged)
        self.nbytes = QLabel()
        self.nbytes.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.nbytes.setText('0')
        self.label = QLabel()
        self.label.setText('<empty>')

    def multiplyOrientation(self, quat):
        self.setOrientation(quat * self.orientation)

    def setOrientation(self, quat):
        self.orientation = quat
        self.quat.setText(
            '%+1.3f, %+1.3f, %+1.3f, %+1.3f' % (
                self.orientation.w,
                self.orientation.x,
                self.orientation.y,
                self.orientation.z,
            )
        )

    def _orientationChanged(self):
        text = self.quat.text()

    def alpha(self):
        return self.alpha_number.value() if self.show.isChecked() else 0.0

    def _alphaSliderChanged(self):
        self.alpha_number.setValue(self.alpha_slider.value() / 1024.0)

    def _alphaNumberChanged(self):
        self.alpha_slider.setValue(1024 * self.alpha_number.value())

    def setup_ui(self, table, row):
        widgets = [
            None,
            CenterH(self.show),
            self.alpha_slider,
            self.alpha_number,
            CenterH(self.move),
            self.quat,
            self.nbytes,
            self.label,
        ]
        for (column, widget) in enumerate(widgets):
            if widget is not None:
                table.setCellWidget(row, column, widget)

    def load_file(self, file_name, in_format):
        self.sphere = proj.load_sphere(file_name, projection=in_format)
        in_format = self.sphere.__class__
        print('Loaded input %s from %s.' % (in_format.__name__, file_name))
        self.texture_id = glGenTextures(1)
        self.sphere.to_gl(self.texture_id)
        self.shader = Shader(
            vert=VERTEX_SHADER,
            frag=FRAGMENT_SHADER + self.sphere.get_glsl_sampler(),
        )
        self.label.setText(file_name)
        self.nbytes.setText(read_bsize(self.sphere.array.nbytes))
Exemple #41
0
class SliderFloatWidget(QWidget):
    """
	SliderFloatWidget
	"""
    valueChanged = Signal(int)

    def __init__(self):
        super(SliderFloatWidget, self).__init__()

        self.label = QLabel()
        self.slider = QSlider(Qt.Horizontal)
        self.spinbox = QDoubleSpinBox()

        self.slider.valueChanged.connect(self.changedValueFromSlider)
        self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

        # Keep track of whether one of the values was changed
        # By setting the value of the slider and the spinbox, valueChanged
        # events are fired. These events have to be ignored
        self._changed = False

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setVerticalSpacing(0)
        layout.addWidget(self.label, 0, 0)
        layout.addWidget(self.slider, 0, 1)
        layout.addWidget(self.spinbox, 0, 2)
        self.setLayout(layout)

    def setName(self, name):
        """
		Set the name for the slider
		"""
        self.label.setText(name)

    def setRange(self, range):
        """
		Set the range for the value
		"""
        self.range = range
        self.slider.setMinimum(0.0)
        self.slider.setMaximum(100.0)
        self.spinbox.setRange(self.range[0], self.range[1])

        diff = self.range[1] - self.range[0]
        if diff <= 1:
            self.spinbox.setSingleStep(0.01)

    def setValue(self, value):
        """
		Set the value for the slider and the spinbox
		"""
        ratio = (value - self.range[0]) / (self.range[1] - self.range[0])
        self._changed = False
        self.slider.setValue(ratio * 100)
        self._changed = False
        self.spinbox.setValue(value)
        self._changed = False

    def value(self):
        return self.spinbox.value()

    @Slot(int)
    def changedValueFromSlider(self, value):
        if self._changed:
            self._changed = False
            return
        ratio = value / 100.0
        val = self.range[0] + ratio * (self.range[1] - self.range[0])
        self._changed = True
        self.spinbox.setValue(val)
        self.valueChanged.emit(val)

    @Slot(float)
    def changedValueFromSpinBox(self, value):
        if self._changed:
            self._changed = False
            return
        ratio = (value - self.range[0]) / (self.range[1] - self.range[0])
        self._changed = True
        self.slider.setValue(ratio * 100.0)
        self.valueChanged.emit(value)
class Form(QDialog):
    def __init__(self,parent=None):
        super(Form,self).__init__(parent)

        date = self.get_data()
        rates = sorted(self.rates.keys())

        dateLabel = QLabel(date)

        self.fromComboBox = QComboBox()
        self.toComboBox = QComboBox()

        self.fromComboBox.addItems(rates)
        self.toComboBox.addItems(rates)

        self.fromSpinBox = QDoubleSpinBox()
        self.fromSpinBox.setRange(0.01,1000)
        self.fromSpinBox.setValue(1.00)

        self.toLabel = QLabel("1.00")

        layout = QGridLayout();
        layout.addWidget(dateLabel,5,0)
        layout.addWidget(self.fromComboBox, 1,0)
        layout.addWidget(self.toComboBox,2,0)
        layout.addWidget(self.fromSpinBox,1,1)
        layout.addWidget(self.toLabel,2,1)

        self.setLayout(layout)

        #Connect Signal
        self.fromComboBox.currentIndexChanged.connect(self.update_ui)
        self.toComboBox.currentIndexChanged.connect(self.update_ui)
        self.fromSpinBox.valueChanged.connect(self.update_ui)

    def get_data(self):
        self.rates = {}

        try:
            date = "Unknown"
            # Thanks Mr Mark Summerfield
            fh = urllib.urlopen("http://www.bankofcanada.ca/valet/observations/group/FX_RATES_DAILY/csv?start_date=2017-01-03")

            for line in fh:
                line = line.rstrip()
                if not line or line.startswith(("#", "Closing")):
                    continue

                fields = line.split(",")
                if line.startswith("Date "):
                    date = fields[-1]

                else:
                    try:
                        value = float(fields[-1])
                        self.rates[fields[0]] = value
                    except ValueError:
                        pass

            return "Exchange rates date: " + date
        except Exception, e:
            return "Failued to download:\n%s" % e
class SimpleSpinOption(SimpleOption):
    def __init__(self, settingsName, labelText, defaultValue, integer=False, checkable=False):
        self.integer = integer
        super(SimpleSpinOption,self).__init__(settingsName, labelText, defaultValue, checkable)
    def editor(self, defaultValue):
        if self.integer:
            self.spinBox = QSpinBox()
        else:
            self.spinBox = QDoubleSpinBox()
        self.spinBox.setRange(0,10**5)
        self.spinBox.setValue(float(QSettings().value(self.settingsName, defaultValue)))
        self.spinBox.setToolTip('Default value: %s' % defaultValue)
        self.spinBox.setAlignment(Qt.AlignLeft|Qt.AlignTop)
        self.layout().addWidget(self.spinBox)
    def setEnabled(self, e):
        self.spinBox.setEnabled(e)
    def getValue(self):
        return self.spinBox.value()
    def setValue(self, newValue):
        self.spinBox.setValue(newValue)
    def setRange(self, min, max):
        self.spinBox.setRange(min, max)
    def initUI(self):
        grp = QGroupBox('Transform')
        grplay = QGridLayout()
        # Translation
        grplay.addWidget(QLabel('<b>Translation</b>'), 0, 0)

        trax = QDoubleSpinBox()
        trax.setMinimum(-10000)
        trax.setMaximum(10000)
        trax.setValue(self.tran.translation[0])
        self.controls['trax'] = trax
        grplay.addWidget(trax, 0, 1)

        tray = QDoubleSpinBox()
        tray.setMinimum(-10000)
        tray.setMaximum(10000)
        tray.setValue(self.tran.translation[1])
        self.controls['tray'] = tray
        grplay.addWidget(tray, 0, 2)

        traz = QDoubleSpinBox()
        traz.setMinimum(-10000)
        traz.setMaximum(10000)
        traz.setValue(self.tran.translation[2])
        self.controls['traz'] = traz
        grplay.addWidget(traz, 0, 3)

        # Rotation.
        grplay.addWidget(QLabel('<b>Rotation</b>'), 1, 0)

        rotx = QSpinBox()
        rotx.setMinimum(-10000)
        rotx.setMaximum(10000)
        #rotx.setText(str(self.tran.euler_angles()[0]))
        traz.setValue(self.tran.euler_angles()[0])
        self.controls['rotx'] = rotx
        grplay.addWidget(rotx, 1, 1)

        roty = QSpinBox()
        roty.setMinimum(-10000)
        roty.setMaximum(10000)
        #roty.setText(str(self.tran.euler_angles()[1]))
        traz.setValue(self.tran.euler_angles()[1])
        self.controls['roty'] = roty
        grplay.addWidget(roty, 1, 2)

        rotz = QSpinBox()
        rotz.setMinimum(-10000)
        rotz.setMaximum(10000)
        #rotz.setText(str(self.tran.euler_angles()[2]))
        traz.setValue(self.tran.euler_angles()[2])
        self.controls['rotz'] = rotz
        grplay.addWidget(rotz, 1, 3)

        # Scale.
        grplay.addWidget(QLabel('<b>Scale</b>'), 2, 0)

        sclx = QDoubleSpinBox()
        sclx.setMinimum(-10000)
        sclx.setMaximum(10000)
        sclx.setValue(self.tran.scale[0])
        self.controls['sclx'] = sclx
        grplay.addWidget(sclx, 2, 1)

        scly = QDoubleSpinBox()
        scly.setMinimum(-10000)
        scly.setMaximum(10000)
        scly.setValue(self.tran.scale[1])
        self.controls['scly'] = scly
        grplay.addWidget(scly, 2, 2)

        sclz = QDoubleSpinBox()
        sclz.setMinimum(-10000)
        sclz.setMaximum(10000)
        sclz.setValue(self.tran.scale[2])
        self.controls['sclz'] = sclz
        grplay.addWidget(sclz, 2, 3)

        grp.setLayout(grplay)
        # Buttons.
        save_btn = QPushButton('Save')
        save_btn.clicked.connect(self.save)
        cancel_btn = QPushButton('Cancel')
        cancel_btn.clicked.connect(self.close)
        btns = QHBoxLayout()
        btns.addStretch()
        btns.addWidget(save_btn)
        btns.addWidget(cancel_btn)

        # Main Layout.
        mainlay = QVBoxLayout()
        mainlay.addWidget(grp)
        mainlay.addLayout(btns)
        mainlay.addStretch()

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 400, 100)
        self.setWindowTitle('MSH Suite - Edit BBox')
        self.show()
class ProfileFormWidget(QWidget):
    '''
    classdocs
    '''
    
    def __init__(self):
        '''
        Constructor
        '''
        QWidget.__init__(self)
        self._initGUI()
        
    def _initGUI(self):
        self.layout = QVBoxLayout()
        self.form = QFormLayout()
        
        self.name = QLineEdit()
        self.surname = QLineEdit()
        
        self.birthdate = QCalendarWidget()
        self.birthdate.setGridVisible(True)
        self.birthdate.setMinimumDate(QDate(1850,1,1))
        self.birthdate.setMaximumDate(QDate.currentDate())
        
        self.male = QRadioButton("Male")
        self.male.setChecked(True)
        self.female = QRadioButton("Female")
        
        self.height = QDoubleSpinBox()
        self.height.setMaximum(250)
        self.height.setMinimum(50)
        self.height.setValue(165)
        self.height.setSuffix(" cm")
        
        self.mass = QDoubleSpinBox()
        self.mass.setMaximum(300)
        self.mass.setMinimum(20)
        self.mass.setValue(60)
        self.mass.setSuffix(" Kg")
        
        btnLayout = QVBoxLayout()
        
        self.form.addRow("Name", self.name)
        self.form.addRow("Surname", self.surname)
        self.form.addRow("Birth date",self.birthdate)
        
        sexLayout = QHBoxLayout()
        sexLayout.addWidget(self.male)
        sexLayout.addWidget(self.female)
        self.form.addRow("Sex", sexLayout)
        
        self.form.addRow("Height", self.height)
        self.form.addRow("Mass", self.mass)
                
        self.layout.addLayout(self.form)
        self.layout.addLayout(btnLayout)
        self.setLayout(self.layout)
        
    def getLayout(self):
        return self.layout
    
    def getWidget(self):
        widget = QWidget()
        widget.setLayout(self.layout)
    
        return widget
    
    def setProfile(self, athlete):
        self.name.setText(athlete._name)
        self.surname.setText(athlete._surname)
        self.birthdate.setSelectedDate(athlete._birthDate)
        
        if athlete._sex=="Male":
            self.male.setChecked(True)
        else:
            self.female.setChecked(True)
            
        self.height.setValue(athlete._height)
        self.mass.setValue(athlete._mass)
                
    def getProfile(self):        
        qDate = self.birthdate.selectedDate()
        birthDate = self.qDate_to_date(qDate)
        
        athleteProfile = Athlete(self.name.text(),
                                 self.surname.text(),
                                 self._getSex(),
                                 birthDate,
                                 self.height.value(),
                                 self.mass.value())
        return athleteProfile 
    
    def qDate_to_date(self, qDate):        
        return date(qDate.year(), qDate.month(),qDate.day())
     
    def _getSex(self):
        if (self.male.isChecked()):
            return "Male"
        elif (self.female.isChecked()):
            return "Female"
        else :
            print "Error: No sex selected"
            return False
    def add_color(self, name, color, layout, row):
        layout.addWidget(QLabel('<b>{0}</b>'.format(name)), row, 0)
        layout.addWidget(QLabel('R'), row, 1)
        r = QDoubleSpinBox()
        r.setValue(color.red)
        r.setMinimum(0.0)
        r.setMaximum(1.0)
        layout.addWidget(r, row, 2)
        self.controls['{0}r'.format(name)] = r

        layout.addWidget(QLabel('G'), row, 3)
        g = QDoubleSpinBox()
        g.setValue(color.green)
        g.setMinimum(0.0)
        g.setMaximum(1.0)
        layout.addWidget(g, row, 4)
        self.controls['{0}g'.format(name)] = g

        layout.addWidget(QLabel('B'), row, 5)
        b = QDoubleSpinBox()
        b.setValue(color.blue)
        b.setMinimum(0.0)
        b.setMaximum(1.0)
        layout.addWidget(b, row, 6)
        self.controls['{0}b'.format(name)] = b

        layout.addWidget(QLabel('A'), row, 7)
        a = QDoubleSpinBox()
        a.setValue(color.alpha)
        a.setMinimum(0.0)
        a.setMaximum(1.0)
        layout.addWidget(a, row, 8)
        self.controls['{0}a'.format(name)] = a