コード例 #1
0
ファイル: forms.py プロジェクト: ulthiel/PicoScope
 def __init__(self, screen):
     super(DemoFrame, self).__init__(screen,
                                     int(screen.height * 2 // 3),
                                     int(screen.width * 2 // 3),
                                     data=form_data,
                                     has_shadow=True,
                                     name="My Form")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     self._reset_button = Button("Reset", self._reset)
     layout.add_widget(Label("Group 1:"), 1)
     layout.add_widget(TextBox(5,
                               label="My First Box:",
                               name="TA",
                               on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Alpha:",
              name="TB",
              on_change=self._on_change,
              validator="^[a-zA-Z]*$"), 1)
     layout.add_widget(
         Text(label="Number:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Email:",
              name="TD",
              on_change=self._on_change,
              validator=self._check_email), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(RadioButtons([("Option 1", 1),
                                     ("Option 2", 2),
                                     ("Option 3", 3)],
                                    label="A Longer Selection:",
                                    name="Things",
                                    on_change=self._on_change), 1)
     layout.add_widget(CheckBox("Field 1",
                                label="A very silly long name for fields:",
                                name="CA",
                                on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(DatePicker("Date",
                                  name="DATE",
                                  year_range=range(1999, 2100),
                                  on_change=self._on_change), 1)
     layout.add_widget(
         TimePicker("Time", name="TIME", on_change=self._on_change, seconds=True), 1)
     layout.add_widget(Text("Password", name="PWD", on_change=self._on_change, hide_char="*"), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
コード例 #2
0
    def __init__(self, screen, model):
        super(TodoView, self).__init__(screen,
                                       screen.height * 2 // 3,
                                       screen.width * 2 // 3,
                                       hover_focus=True,
                                       title="To-Do Details",
                                       reduce_cpu=True)
        self._model = model

        due_datetime = datetime.datetime.now()
        due_datetime = due_datetime.replace(microsecond=0)
        self.data["id"] = -1
        self.data["what"] = ""
        self.data["due_date"] = due_datetime.date()
        self.data["due_time"] = due_datetime.time()
        self.data["category"] = 0
        self.data["finished"] = False

        self._category_ddlist = DropdownList([("", -1)],
                                             label="Category:",
                                             name="category")
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Text("What:", "what"))
        layout.add_widget(
            DatePicker("Due Date:",
                       name="due_date",
                       year_range=range(1999, 2100)))
        layout.add_widget(
            TimePicker("Due Time:", name="due_time", seconds=True))
        layout.add_widget(self._category_ddlist)
        layout.add_widget(
            TextBox(Widget.FILL_FRAME, "Notes:", "notes", as_string=True))
        layout.add_widget(CheckBox("", label="Finished:", name="finished"))
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Apply", self._apply), 0)
        layout2.add_widget(Button("Back", self._back), 3)
        self.fix()
コード例 #3
0
ファイル: runlog.py プロジェクト: tuxtof/calm-dsl
    def __init__(self, name, screen, inputs, data):
        super(InputFrame, self).__init__(
            screen,
            int(len(inputs) * 2 + 8),
            int(screen.width * 4 // 5),
            has_shadow=True,
            data=data,
            name=name,
        )
        layout = Layout([1, len(inputs), 1])
        self.add_layout(layout)
        layout.add_widget(
            Label("Inputs for the input task '{}'".format(name), height=2), 1
        )
        for singleinput in inputs:
            if (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.TEXT
            ):
                layout.add_widget(
                    Text(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.DATE
            ):
                layout.add_widget(
                    DatePicker(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        year_range=range(1899, 2300),
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.TIME
            ):
                layout.add_widget(
                    TimePicker(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        seconds=True,
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT) in [
                SINGLE_INPUT.TYPE.SELECT,
                SINGLE_INPUT.TYPE.SELECTMULTIPLE,
            ]:
                layout.add_widget(
                    DropdownList(
                        [(option, option) for option in singleinput.get("options")],
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        on_change=self._on_change,
                    ),
                    1,
                )
            elif (
                singleinput.get("input_type", SINGLE_INPUT.TYPE.TEXT)
                == SINGLE_INPUT.TYPE.PASSWORD
            ):
                layout.add_widget(
                    Text(
                        label=singleinput.get("name") + ":",
                        name=singleinput.get("name"),
                        hide_char="*",
                        on_change=self._on_change,
                    ),
                    1,
                )

        layout.add_widget(Divider(height=3), 1)
        layout2 = Layout([1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Submit", self._submit), 1)
        self.fix()
コード例 #4
0
ファイル: ascii.py プロジェクト: rentcp/Heatwave
    def __init__(self, screen):
        super().__init__(screen,
                         screen.height,
                         80,
                         data=FormStateData.data,
                         title="Aqua AIRS HDF Processing",
                         reduce_cpu=False)

        self.palette = INTERFACE_PALETTE
        self.controller = MainController(self.status_callback)

        # supporting variables
        wavelengths = list(
            reversed([(str(w), c)
                      for c, w in CHANNELS_TO_WAVELENGTHS.items()]))
        year_range = range(2002, 2016 + 1)

        # declare controls
        self.username = Text('EarthData Login username: '******'username')
        self.password = Text('EarthData Login password: '******'password',
                             hide_char='*')
        self.output_directory = Text('Output directory: ', 'output_directory')
        self.data_directory = Text('HDF data directory: ', 'data_directory')
        self.before_date_range_start = DatePicker('"Before" date range start:',
                                                  'before_date_range_start',
                                                  year_range=year_range)
        self.before_date_range_end = DatePicker('"Before" date range end:',
                                                'before_date_range_end',
                                                year_range=year_range)
        self.after_date_range_start = DatePicker('"After" date range start:',
                                                 'after_date_range_start',
                                                 year_range=year_range)
        self.after_date_range_end = DatePicker('"After" date range end:',
                                               'after_date_range_end',
                                               year_range=year_range)
        self.time_range_start = TimePicker('Start time: ',
                                           name='time_range_start')
        self.time_range_end = TimePicker('End time : ', name='time_range_end')
        self.min_latitude = CustomText('Minimum latitude: ',
                                       name='min_latitude')
        self.max_latitude = CustomText('Maximum latitude: ',
                                       name='max_latitude')
        self.min_longitude = CustomText('Minimum longitude: ',
                                        name='min_longitude')
        self.max_longitude = CustomText('Maximum longitude: ',
                                        name='max_longitude')
        self.use_radiance_filters = CheckBox('Use radiance filter',
                                             'Radiance filter',
                                             name='use_radiance_filters')
        self.radiance = CustomText('Radiance: ', name='radiance')
        self.radiance_range = CustomText('Radiance range (mW): ±',
                                         name='radiance_range')
        self.channel = ListBox(
            1, wavelengths, label='Wavelength:',
            name='channel')  # value is channel, not wavelength
        self.max_landfrac = CustomText('Maximum landfrac (0-1): ',
                                       name='max_landfrac')
        self.dust_flag_no_dust = CustomCheckBox('No dust',
                                                'Dust presence',
                                                name='dust_flag_no_dust')
        self.dust_flag_single_fov = CustomCheckBox('Dust in a single FOV',
                                                   name='dust_flag_single_fov')
        self.dust_flag_detected = CustomCheckBox('Dust detected',
                                                 name='dust_flag_detected')
        self.data_quality_best = CustomCheckBox('Best',
                                                'Data quality level',
                                                name='data_quality_best')
        self.data_quality_enough = CustomCheckBox('Good enough',
                                                  name='data_quality_enough')
        self.data_quality_worst = CustomCheckBox('Worst',
                                                 name='data_quality_worst')
        self.center_scans_only = CheckBox('Use center IR scans only',
                                          'Other',
                                          name='center_scans_only')
        self.noise_amp = CheckBox('Consider noise amplification',
                                  name='noise_amp')
        self.progress_label = Label('')

        self.button_process = Button('Process', self._process)
        self.button_quit = Button('Quit', self._quit)

        # declare layouts
        top_layout = Layout([1])
        time_layout = Layout([1])
        radiance_layout = Layout([1])
        options_layout = Layout([1])
        buttons_layout = Layout([1, 1, 1, 1])
        status_layout = Layout([1])

        # attach layouts to self
        self.add_layout(top_layout)
        self.add_layout(time_layout)
        self.add_layout(radiance_layout)
        self.add_layout(options_layout)
        self.add_layout(buttons_layout)
        self.add_layout(status_layout)

        # attach controls to layouts
        top_layout.add_widget(self.username)
        top_layout.add_widget(self.password)
        top_layout.add_widget(Divider(False))
        top_layout.add_widget(self.data_directory)
        top_layout.add_widget(self.output_directory)
        top_layout.add_widget(Divider(False))
        top_layout.add_widget(self.before_date_range_start)
        top_layout.add_widget(self.before_date_range_end)
        top_layout.add_widget(self.after_date_range_start)
        top_layout.add_widget(self.after_date_range_end)

        time_layout.add_widget(self.time_range_start)
        time_layout.add_widget(self.time_range_end)
        time_layout.add_widget(Divider(False))
        time_layout.add_widget(self.min_latitude)
        time_layout.add_widget(self.max_latitude)
        time_layout.add_widget(self.min_longitude)
        time_layout.add_widget(self.max_longitude)
        time_layout.add_widget(Divider(False))

        radiance_layout.add_widget(self.use_radiance_filters)
        radiance_layout.add_widget(self.radiance)
        radiance_layout.add_widget(self.radiance_range)
        radiance_layout.add_widget(self.channel)
        radiance_layout.add_widget(Divider(False))

        options_layout.add_widget(self.max_landfrac)
        options_layout.add_widget(self.dust_flag_no_dust)
        options_layout.add_widget(self.dust_flag_single_fov)
        options_layout.add_widget(self.dust_flag_detected)
        options_layout.add_widget(Divider(False))
        options_layout.add_widget(self.data_quality_best)
        options_layout.add_widget(self.data_quality_enough)
        options_layout.add_widget(self.data_quality_worst)
        options_layout.add_widget(Divider(False))
        options_layout.add_widget(self.center_scans_only)
        options_layout.add_widget(self.noise_amp)

        options_layout.add_widget(Divider(False))
        options_layout.add_widget(Divider(False))
        buttons_layout.add_widget(self.button_process, 2)
        buttons_layout.add_widget(self.button_quit, 3)

        status_layout.add_widget(Divider(False))
        status_layout.add_widget(Divider(False))
        status_layout.add_widget(self.progress_label)

        # add validating regexes
        self.min_latitude.set_validator('^-?(?:\d+(?:\.\d+)?|\.\d+)$')
        self.max_latitude.set_validator('^-?(?:\d+(?:\.\d+)?|\.\d+)$')
        self.min_longitude.set_validator('^-?(?:\d+(?:\.\d+)?|\.\d+)$')
        self.max_longitude.set_validator('^-?(?:\d+(?:\.\d+)?|\.\d+)$')
        self.radiance.set_validator('^(?:\d+(?:\.\d+)?|\.\d+)$')
        self.radiance_range.set_validator('^(?:\d+(?:\.\d+)?|\.\d+)$')
        self.max_landfrac.set_validator('^(?:[01]+(?:\.\d+)?)|\.\d+$')

        # checkboxes groups with default values
        self.dust_flag_group = CheckBoxesGroup([
            self.dust_flag_no_dust, self.dust_flag_single_fov,
            self.dust_flag_detected
        ], self.dust_flag_no_dust)
        self.data_quality_group = CheckBoxesGroup([
            self.data_quality_best, self.data_quality_enough,
            self.data_quality_worst
        ], self.data_quality_enough)

        self.fix()