-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtranslator.kv
77 lines (71 loc) · 2.7 KB
/
translator.kv
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!text
#:kivy 1.7.2
#:import Factory kivy.factory.Factory
#:set color_button (0, 0, .7, .99) # brown
#:set color_button_pressed (0, 0, .4, .99) # darker brown
#:set color_font (1, 1, 1, 1) # off white
<MySpinnerOption@SpinnerOption>:
background_color: color_button if self.state == 'down' else color_button_pressed
color: color_font
spacing: 10
<MainLayout>
spacing: 10
orientation: 'vertical'
padding: 10
# on_key_up: root._key_up(*args)
Spinner:
id: head_spinner
text: 'Google Translate'
values: 'Google Translate', 'My Memory', 'Pons', 'Linguee'
size_hint: 1., .20
background_color: color_button if self.state == 'normal' else color_button_pressed
color: color_font
font_size: dp(30)
option_cls: Factory.get("MySpinnerOption")
TextInput:
id: payload
hint_text: "Tap to enter text..."
focus: True
use_bubble: True
size_hint: 1., .20
font_size: dp(30)
background_color: 0, 0, 0, 1
foreground_color: (1, 1, 1, 1)
BoxLayout:
spacing: 5
size_hint: 1., .15
Spinner:
id: from_spinner
text: 'auto' if head_spinner.text in ['Google Translate', 'My Memory'] else 'french'
values: root.get_supported_languages(translator=head_spinner.text, auto_included=True)
# background_color: 0, 0, 1, .7
background_color: color_button if self.state == 'normal' else color_button_pressed
color: color_font
font_size: dp(20)
option_cls: Factory.get("MySpinnerOption")
Spinner:
id: to_spinner
text: 'english'
values: root.get_supported_languages(translator=head_spinner.text)
# background_color: 0, 0, 1, .7
background_color: color_button if self.state == 'normal' else color_button_pressed
color: color_font
font_size: dp(20)
option_cls: Factory.get("MySpinnerOption")
Button:
id: translate_btn
text: 'translate'
# background_color: 0, 0, 1, .7
background_color: color_button if self.state == 'normal' else color_button_pressed
color: color_font
font_size: dp(20)
on_release: result_label.text = root.translate(translator=head_spinner.text, source=from_spinner.text, target=to_spinner.text, text=payload.text)
ScrollView:
Label:
id: result_label
font_size: dp(50)
pos_hint_x: 0.3
size_hint_y: None
height: self.texture_size[1]
text_size: self.width, None
font_name: 'arial-unicode-ms.ttf' # 'arial'