File: owNumber.py

package info (click to toggle)
orange3 3.40.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,908 kB
  • sloc: python: 162,745; ansic: 622; makefile: 322; sh: 93; cpp: 77
file content (37 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (2)
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
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget, Output
from Orange.widgets.settings import Setting
from PyQt4.QtGui import QIntValidator


class OWWidgetNumber(OWWidget):
    name = "Number"
    description = "Lets the user input a number"
    icon = "icons/Unknown.svg"
    priority = 10
    category = ""

    class Outputs:
        number = Output("Number", int)

    want_main_area = False

    number = Setting(42)

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

        gui.lineEdit(
            self.controlArea,
            self,
            "number",
            "Enter a number",
            box="Number",
            callback=self.number_changed,
            valueType=int,
            validator=QIntValidator(),
        )
        self.number_changed()

    def number_changed(self):
        self.Outputs.number.send(self.number)