File: qt_double_spin_box.py

package info (click to toggle)
python-enamlx 0.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 388 kB
  • sloc: python: 3,338; makefile: 18
file content (38 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
"""
Copyright (c) 2015, Jairus Martin.
Distributed under the terms of the MIT License.
The full license is in the file COPYING.txt, distributed with this software.
Created on Aug 29, 2015
"""
from atom.api import Typed
from enaml.qt.qt_spin_box import QtSpinBox
from qtpy.QtWidgets import QDoubleSpinBox

from enamlx.widgets.double_spin_box import ProxyDoubleSpinBox


class QtDoubleSpinBox(QtSpinBox, ProxyDoubleSpinBox):
    """A Qt implementation of an Enaml SpinBox."""

    #: A reference to the widget created by the proxy.
    widget = Typed(QDoubleSpinBox)

    # -------------------------------------------------------------------------
    # Initialization API
    # -------------------------------------------------------------------------
    def create_widget(self):
        """Create the underlying QDoubleSpinBox widget."""
        widget = QDoubleSpinBox(self.parent_widget())
        widget.setKeyboardTracking(False)
        self.widget = widget

    def init_widget(self):
        self.set_decimals(self.declaration.decimals)
        super(QtDoubleSpinBox, self).init_widget()

    # -------------------------------------------------------------------------
    # ProxyDoubleSpinBox API
    # -------------------------------------------------------------------------
    def set_decimals(self, prec):
        self.widget.setDecimals(prec)