Skip to content

Commit 2b3e34b

Browse files
authored
Merge pull request #899 from inclement/softinput_mode
Addded textinput scatter testapp
2 parents aacc461 + 4a7947e commit 2b3e34b

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
print('main.py was successfully called')
2+
3+
import os
4+
print('imported os')
5+
6+
from kivy import platform
7+
8+
if platform == 'android':
9+
print('contents of ./lib/python2.7/site-packages/ etc.')
10+
print(os.listdir('./lib'))
11+
print(os.listdir('./lib/python2.7'))
12+
print(os.listdir('./lib/python2.7/site-packages'))
13+
14+
print('this dir is', os.path.abspath(os.curdir))
15+
16+
print('contents of this dir', os.listdir('./'))
17+
18+
with open('./lib/python2.7/site-packages/kivy/app.pyo', 'rb') as fileh:
19+
print('app.pyo size is', len(fileh.read()))
20+
21+
import sys
22+
print('pythonpath is', sys.path)
23+
24+
import kivy
25+
print('imported kivy')
26+
print('file is', kivy.__file__)
27+
28+
from kivy.app import App
29+
30+
from kivy.lang import Builder
31+
from kivy.properties import StringProperty
32+
33+
from kivy.uix.popup import Popup
34+
from kivy.clock import Clock
35+
36+
print('Imported kivy')
37+
from kivy.utils import platform
38+
print('platform is', platform)
39+
40+
41+
kv = '''
42+
#:import Metrics kivy.metrics.Metrics
43+
#:import Window kivy.core.window.Window
44+
45+
<FixedSizeButton@Button>:
46+
size_hint_y: None
47+
height: dp(60)
48+
49+
50+
BoxLayout:
51+
orientation: 'vertical'
52+
BoxLayout:
53+
size_hint_y: None
54+
height: dp(50)
55+
orientation: 'horizontal'
56+
Button:
57+
text: 'None'
58+
on_press: Window.softinput_mode = ''
59+
Button:
60+
text: 'pan'
61+
on_press: Window.softinput_mode = 'pan'
62+
Button:
63+
text: 'below_target'
64+
on_press: Window.softinput_mode = 'below_target'
65+
Button:
66+
text: 'resize'
67+
on_press: Window.softinput_mode = 'resize'
68+
Widget:
69+
Scatter:
70+
id: scatter
71+
size_hint: None, None
72+
size: dp(300), dp(80)
73+
on_parent: self.pos = (300, 100)
74+
BoxLayout:
75+
size: scatter.size
76+
orientation: 'horizontal'
77+
canvas:
78+
Color:
79+
rgba: 1, 0, 0, 1
80+
Rectangle:
81+
pos: 0, 0
82+
size: self.size
83+
Widget:
84+
size_hint_x: None
85+
width: dp(30)
86+
TextInput:
87+
text: 'type in me'
88+
'''
89+
90+
91+
class ErrorPopup(Popup):
92+
error_text = StringProperty('')
93+
94+
def raise_error(error):
95+
print('ERROR:', error)
96+
ErrorPopup(error_text=error).open()
97+
98+
class TestApp(App):
99+
def build(self):
100+
root = Builder.load_string(kv)
101+
Clock.schedule_interval(self.print_something, 2)
102+
# Clock.schedule_interval(self.test_pyjnius, 5)
103+
print('testing metrics')
104+
from kivy.metrics import Metrics
105+
print('dpi is', Metrics.dpi)
106+
print('density is', Metrics.density)
107+
print('fontscale is', Metrics.fontscale)
108+
return root
109+
110+
def print_something(self, *args):
111+
print('App print tick', Clock.get_boottime())
112+
113+
def on_pause(self):
114+
return True
115+
116+
def test_pyjnius(self, *args):
117+
try:
118+
from jnius import autoclass
119+
except ImportError:
120+
raise_error('Could not import pyjnius')
121+
return
122+
123+
print('Attempting to vibrate with pyjnius')
124+
# PythonActivity = autoclass('org.renpy.android.PythonActivity')
125+
# activity = PythonActivity.mActivity
126+
PythonActivity = autoclass('org.kivy.android.PythonActivity')
127+
activity = PythonActivity.mActivity
128+
Intent = autoclass('android.content.Intent')
129+
Context = autoclass('android.content.Context')
130+
vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE)
131+
132+
vibrator.vibrate(1000)
133+
134+
def test_ctypes(self, *args):
135+
import ctypes
136+
137+
def test_numpy(self, *args):
138+
import numpy
139+
140+
print(numpy.zeros(5))
141+
print(numpy.arange(5))
142+
print(numpy.random.random((3, 3)))
143+
144+
TestApp().run()

0 commit comments

Comments
 (0)