コード例 #1
0
ファイル: torrent_actions.py プロジェクト: Ashod/Deluge
            def create_popup(status):
                cb = lambda result, ids=ids: _do_set_torrent_options(ids, result)
                option_popup = InputPopup(mode,"Set torrent options (Esc to cancel)",close_cb=cb, height_req=22)

                for (field, field_type) in torrent_options:
                    caption = "{!info!}" + torrent_options_to_names[field]
                    value = options[field]
                    if   field_type == str:
                        if not isinstance(value, basestring):
                            value = str(value)
                        option_popup.add_text_input(caption, field, value)
                    elif field_type == bool:
                        if options[field] == "multiple":
                            choices = (
                                ["Yes", "No", "Mixed"],
                                [True, False, None],
                                2
                            )
                        else:
                            choices = (
                                ["Yes", "No"],
                                [True, False],
                                [True, False].index(options[field])
                            )
                        option_popup.add_select_input(caption, field, choices[0], choices[1], choices[2])
                    elif field_type == float:
                        option_popup.add_float_spin_input(caption, field, value, min_val = -1)
                    elif field_type == int:
                        option_popup.add_int_spin_input(caption, field, value, min_val = -1)

                mode.set_popup(option_popup)
                mode.refresh()
コード例 #2
0
            def create_popup(status):
                cb = lambda result, ids=ids: _do_set_torrent_options(
                    ids, result)
                option_popup = InputPopup(
                    mode,
                    "Set torrent options (Esc to cancel)",
                    close_cb=cb,
                    height_req=22)

                for (field, field_type) in torrent_options:
                    caption = "{!info!}" + torrent_options_to_names[field]
                    value = options[field]
                    if field_type == str:
                        if not isinstance(value, basestring):
                            value = str(value)
                        option_popup.add_text_input(caption, field, value)
                    elif field_type == bool:
                        if options[field] == "multiple":
                            choices = (["Yes", "No",
                                        "Mixed"], [True, False, None], 2)
                        else:
                            choices = (["Yes", "No"], [True, False],
                                       [True, False].index(options[field]))
                        option_popup.add_select_input(caption, field,
                                                      choices[0], choices[1],
                                                      choices[2])
                    elif field_type == float:
                        option_popup.add_float_spin_input(caption,
                                                          field,
                                                          value,
                                                          min_val=-1)
                    elif field_type == int:
                        option_popup.add_int_spin_input(caption,
                                                        field,
                                                        value,
                                                        min_val=-1)

                mode.set_popup(option_popup)
                mode.refresh()