proxy.kv (2652B)
1 Popup: 2 id: nd 3 title: _('Proxy') 4 BoxLayout: 5 orientation: 'vertical' 6 padding: '10dp' 7 spacing: '10dp' 8 GridLayout: 9 cols: 2 10 Label: 11 text: _('Proxy mode') 12 Spinner: 13 id: mode 14 height: '48dp' 15 size_hint_y: None 16 text: app.proxy_config.get('mode', 'none') 17 values: ['none', 'socks4', 'socks5'] 18 Label: 19 text: _('Host') 20 TextInput: 21 id: host 22 multiline: False 23 height: '48dp' 24 size_hint_y: None 25 text: app.proxy_config.get('host', '') 26 disabled: mode.text == 'none' 27 Label: 28 text: _('Port') 29 TextInput: 30 id: port 31 multiline: False 32 input_type: 'number' 33 height: '48dp' 34 size_hint_y: None 35 text: app.proxy_config.get('port', '') 36 disabled: mode.text == 'none' 37 Label: 38 text: _('Username') 39 TextInput: 40 id: user 41 multiline: False 42 height: '48dp' 43 size_hint_y: None 44 text: app.proxy_config.get('user', '') 45 disabled: mode.text == 'none' 46 Label: 47 text: _('Password') 48 TextInput: 49 id: password 50 multiline: False 51 password: True 52 height: '48dp' 53 size_hint_y: None 54 text: app.proxy_config.get('password', '') 55 disabled: mode.text == 'none' 56 Widget: 57 size_hint: 1, 0.1 58 BoxLayout: 59 Widget: 60 size_hint: 0.5, None 61 Button: 62 size_hint: 0.5, None 63 height: '48dp' 64 text: _('OK') 65 on_release: 66 net_params = app.network.get_parameters() 67 proxy = {} 68 proxy['mode']=str(root.ids.mode.text).lower() 69 proxy['host']=str(root.ids.host.text) 70 proxy['port']=str(root.ids.port.text) 71 proxy['user']=str(root.ids.user.text) 72 proxy['password']=str(root.ids.password.text) 73 if proxy['mode']=='none': proxy = None 74 net_params = net_params._replace(proxy=proxy) 75 app.network.run_from_another_thread(app.network.set_parameters(net_params)) 76 nd.dismiss()