Пример #1
0
 def test_Platform_linux2(self):
     with patch('kivy.utils._sys_platform') as m:
         m.__str__.return_value = 'linux2'
         m.__getitem__.return_value = 'linux'
         m.__eq__ = lambda x, y: str(x) == y
         pf = Platform()
         self.assertTrue(pf == 'linux')
Пример #2
0
 def test_Platform(self):
     strPlat = str(Platform())
     self.assertTrue(
         strPlat in ['android', 'ios', 'win', 'macosx', 'linux', 'unknown'])
Пример #3
0
 def test_Platform_unknown(self):
     with patch('kivy.utils._sys_platform') as m:
         m.__str__.return_value = 'unknown'
         m.__eq__ = lambda x, y: str(x) == y
         pf = Platform()
         self.assertTrue(pf == 'unknown')
Пример #4
0
 def test_Platform_ios(self):
     with patch.dict('os.environ', {'KIVY_BUILD': 'ios'}):
         pf = Platform()
         self.assertEqual(str(pf), 'ios')
     self.assertNotIn('KIVY_BUILD', os.environ)
Пример #5
0
 def test_Platform_android(self):
     with patch.dict('os.environ', {'ANDROID_ARGUMENT': ''}):
         pf = Platform()
         self.assertTrue(pf == 'android')
     self.assertNotIn('ANDROID_ARGUMENT', os.environ)
Пример #6
0
 def test_Platform(self):
     # Those calls do not have specific intent, no assertions
     pf = Platform()
     pf()  # __call__ deprecated
     hash(pf)
     repr(pf)
Пример #7
0
 def _test_platforms(self, input, testval):
     utils._sys_platform = input
     pf = Platform()
     self.assertTrue(pf == testval)
Пример #8
0
from kivy.core.text import LabelBase
from kivy.logger import Logger
from kivy.metrics import sp
from kivy.network.urlrequest import UrlRequest
from kivy.properties import ObjectProperty
from kivy.uix.button import Button
from kivy.uix.listview import ListItemButton
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import Screen, ScreenManager, RiseInTransition
from kivy.utils import get_color_from_hex as c, Platform
from string import Formatter
import database

LabelBase.register('symbols', fn_regular='assets/weathersymbols.ttf')
COLOURS = ['FF3B30', '2ECC71', '3498DB', '1ABC9C', '27AE60', 'E74C3C']
mobile_platform = Platform() in ('ios', 'android')
if not mobile_platform:
    # This must be here because a mobile screen is high density
    Config.set('graphics', 'height', int(1280 * 0.5))  # 50% of screen size
    Config.set('graphics', 'width', int(720 * 0.5))  # 50% of screen size
Config.set('kivy', 'log_level', 'warning')


def find_location(location, on_success):
    url = Formatter().format(database.URLS['find_location'],
                             location=location,
                             appid=database.OPENWEATHERKEY)
    UrlRequest(url, on_success=on_success)


class LargeButton(Button):