def create_window(self, *largs): # ensure the mouse is still not up after window creation, otherwise, we # have some weird bugs self.dispatch('on_mouse_up', 0, 0, 'all', []) # force display to show (available only for fullscreen) displayidx = Config.getint('graphics', 'display') if not 'SDL_VIDEO_FULLSCREEN_HEAD' in environ and displayidx != -1: environ['SDL_VIDEO_FULLSCREEN_HEAD'] = '%d' % displayidx # init some opengl, same as before. self.flags = pygame.HWSURFACE | pygame.OPENGL | \ pygame.DOUBLEBUF # right now, activate resizable window only on linux. # on window / macosx, the opengl context is lost, and we need to # reconstruct everything. Check #168 for a state of the work. if platform() in ('linux', 'macosx', 'win') and \ Config.getint('graphics', 'resizable'): self.flags |= pygame.RESIZABLE try: pygame.display.init() except pygame.error, e: raise CoreCriticalException(e.message)
def on_key_down(self, win, key, scancode, string, modifiers): print( win.size, key) if key == 102: # 'f' normalsize = [ Config.getint('graphics', 'width'), Config.getint('graphics', 'height') ] if (win._size == normalsize): win._size = [1440, 900] else: win._size = normalsize win.toggle_fullscreen() win.update_viewport() return True
def animointi_4(self): """ Maaritetaan points4 listan luvut. Naiden ukujen perusteella piirretaan monitorin viiva. """ dt = 0.5 cy = Config.getint('graphics', 'height') * .5625 cx = 0.00 w = Config.getint('graphics', 'width') * .748 step = 10 points = [] self.dt += dt for i in xrange(int(w / step)): x = i * step points.append(cx + x) points.append(cy + sin(x / w * 8. + self.dt) * 120.00 * 0.2) self.points4 = points
def animointi(self): """ Maaritetaan points listan luvut. Naiden lukujen perusteella piirretaan monitorin viiva. """ # Tee kaikista animoitni metodeista yksi dt = 0.5 cy = Config.getint('graphics', 'height') * .6875 cx = 0.00 w = Config.getint('graphics', 'width') * .748 step = 10 points = [] self.dt += dt for i in xrange(int(w / step)): x = i * step points.append(cx + x) points.append(cy + cos(x / w * 8. + self.dt) * 240.00 * 0.2) self.points = points
def __init__(self, content, **kwargs): self.container = kwargs.get('container', None) self.content = content self.unit = kwargs.get('unit', '%') self.percent_scale = kwargs.get('percent_scale', True) self.color = kwargs.get('color', [1, 0, 1]) self.history = kwargs.get( 'history', Config.getint('settings', 'perfgraph_default_history') ) # Initial load is all zeroes self.load = [0] * self.history self.label = Label(text=("%s: 0%s" % (self.content, self.unit))) self.mainline = None self.lines = dict() self.loads = dict() self.colors = dict() self.axes_lines = [] super(PerfGraph, self).__init__(**kwargs) self.add_widget(self.label) self.bind(pos=self.update_graphics_pos, size=self.update_graphics_size)
def __init__(self, content, **kwargs): self.container = kwargs.get('container', None) self.content = content self.extra_content = kwargs.get('extra_content', None) self.unit = kwargs.get('unit', '%') self.percent_scale = kwargs.get('percent_scale', True) self.color = kwargs.get('color', [1, 0, 1]) self.history = kwargs.get( 'history', Config.getint('settings', 'perfgraph_default_history') ) self.colors_hex = dict() self.colors_hex['A15'] = "#00FFFF" self.colors_hex['A7'] = "#3300FF" # Initial load is all zeroes self.load = [0] * self.history self.label = Label(text=("%s: 0%s" % (self.content, self.unit)), markup=True) if self.extra_content != None: for cont in self.extra_content: self.label.text = self.label.text + "\n[color=%s]%s: 0%s[/color]" % (self.colors_hex[cont], cont, self.unit) self.mainline = None self.lines = dict() self.loads = dict() self.colors = dict() self.axes_lines = [] super(PerfGraph, self).__init__(**kwargs) self.add_widget(self.label) self.bind(pos=self.update_graphics_pos, size=self.update_graphics_size)
def animointi_3(self, pulssi): """ Maaritetaan points3 listan luvut. Naiden ukujen perusteella piirretaan monitorin viiva. """ dt = 0.5 cy = Config.getint('graphics', 'height') * .9375 cx = 0.00 w = Config.getint('graphics', 'width') * .748 step = 10 points = [] self.dt += dt intervalli = (float(pulssi) / 100.0) * 1.5 print intervalli for i in xrange(int(w / step)): x = i * step points.append(cx + x) points.append(cy + cos(x / w * (intervalli*10.) + self.dt) * 240.00 * 0.2) self.points3 = points
def build(self): size=(Config.getint("graphics", "width"), Config.getint("graphics", "height")) main=MainWidget() cursor=Image(source="cursor.png"); main.cursor=cursor; cursor.visible=False; #background=Page(source="images/background.png", size=size) print size cat=Catalog(pos=(0,0), size=size); cat.addPage("marker.png"); cat.update() #main.add_widget(background); main.add_widget(cat); main.add_widget(cursor); return main
def __init__(self): self._dt = 0.0001 self._last_tick = time() self._fps = 0 self._rfps = 0 self._fps_counter = 0 self._rfps_counter = 0 self._last_fps_tick = None self._events = [] self._max_fps = float(Config.getint('graphics', 'maxfps'))
def build(self): game = TheGame() game.launch_moves() game.pio = Pio() game.add_widget(game.pio) game.pio.build() game.pio.paysage = game.paysage Paysage.screenWidth = Config.getint('graphics','width') Clock.schedule_interval(game.update, 1.0/60.0) return game
def __init__(self, texture,sx,sy,positionx,positiony,offsetx,offsety,screenw = Config.getint('graphics', 'width'),screenh=Config.getint('graphics', 'height')): self.texture = texture self.tilex = sx self.tiley = sy self.positionx = positionx self.positiony = positiony self.offsetx = offsetx self.offsety = offsety self.currentoffsetx = 0 self.currentoffsety = 0 self.screenh = screenh self.screenw = screenw
def build(self): Config.set('kivy','keyboard_mode','') Config.write() print "window:" self.width = Config.getint('graphics','width') self.height= Config.getint('graphics','height') self.general_screen = GeneralScreen(name="General") self.home_screen = HomeScreen(name="Home") self.login_screen = LogInScreen(name="LogIn") self.singup_screen = SignUpScreen(name="SignUp") self.profile_screen = ProfileScreen(name="Profile") self.map_screen=MapScreen(name="Map") sm.add_widget(self.map_screen) sm.add_widget(self.home_screen) sm.add_widget(self.login_screen) sm.add_widget(self.singup_screen) sm.add_widget(self.profile_screen) sm.add_widget(self.general_screen) sm.current = "LogIn" return sm
def setupWorld(self,filename): self.world.reset() domLevel = parse(filename) worldNodes = domLevel.getElementsByTagName("world") for node in worldNodes[0].childNodes: if node.localName == "gravity": values = node.getAttribute('value').split(',') self.world.setGravity(float(values[0]),float(values[1])) if node.localName == "landingzone": values = node.getAttribute('value').split(',') self.world.setLandingzone(Landingzone(float(values[0]),float(values[1]),float(values[2]),float(values[3]),TextureHelper.loadTextureFromFile('checker.png'))) h = Config.getint('graphics', 'height') w = Config.getint('graphics', 'width') p0 = Plane(1,0,-10) p1 = Plane(0,-1,h-10) p2 = Plane(-1,0,w-10) p3 = Plane(0,1,-64) self.world.addPlane(p0) self.world.addPlane(p1) self.world.addPlane(p2) self.world.addPlane(p3)
def __init__(self): self._dt = 0.0001 self._start_tick = self._last_tick = time() self._fps = 0 self._rfps = 0 self._fps_counter = 0 self._rfps_counter = 0 self._last_fps_tick = None self._events = {} self._max_fps = float(Config.getint('graphics', 'maxfps')) #: .. versionadded:: 1.0.5 #: When a schedule_once is used with -1, you can add a limit on how much #: iteration will be allowed. That is here to prevent too much relayout. # XXX Adjust this value. self.max_iteration = 10
def __init__(self): super(ClockBase, self).__init__() self._dt = 0.0001 self._start_tick = self._last_tick = _default_time() self._fps = 0 self._rfps = 0 self._fps_counter = 0 self._rfps_counter = 0 self._last_fps_tick = None self._events = {} self._max_fps = float(Config.getint('graphics', 'maxfps')) #: .. versionadded:: 1.0.5 #: When a schedule_once is used with -1, you can add a limit on #: how iteration will be allowed. That is here to prevent too much #: relayout. self.max_iteration = 10
def purge_logs(self, directory): '''Purge log is called randomly to prevent the log directory from being filled by lots and lots of log files. You've a chance of 1 in 20 that purge log will be fired. ''' if randint(0, 20) != 0: return from kivy.config import Config maxfiles = Config.getint('kivy', 'log_maxfiles') if maxfiles < 0: return print('Purge log fired. Analysing...') join = os.path.join unlink = os.unlink # search all log files lst = [join(directory, x) for x in os.listdir(directory)] if len(lst) > maxfiles: # get creation time on every files lst = [{'fn': x, 'ctime': os.path.getctime(x)} for x in lst] # sort by date lst = sorted(lst, key=lambda x: x['ctime']) # get the oldest (keep last maxfiles) lst = lst[:-maxfiles] if maxfiles else lst print('Purge %d log files' % len(lst)) # now, unlink every file in the list for filename in lst: try: unlink(filename['fn']) except PermissionError as e: print('Skipped file {0}, {1}'.format(filename['fn'], e)) print('Purge finished!')
def create_window(self): params = self.params # force display to show (available only for fullscreen) displayidx = Config.getint('graphics', 'display') if not 'SDL_VIDEO_FULLSCREEN_HEAD' in os.environ and displayidx != -1: os.environ['SDL_VIDEO_FULLSCREEN_HEAD'] = '%d' % displayidx # init some opengl, same as before. self.flags = pygame.HWSURFACE | pygame.OPENGL | \ pygame.DOUBLEBUF # right now, activate resizable window only on linux. # on window / macosx, the opengl context is lost, and we need to # reconstruct everything. Check #168 for a state of the work. if sys.platform == 'linux2': self.flags |= pygame.RESIZABLE try: pygame.display.init() except pygame.error, e: raise CoreCriticalException(e.message)
def __init__(self): dist = Config.getint('postproc', 'double_tap_distance') self.double_tap_distance = dist / 1000.0 time = Config.getint('postproc', 'double_tap_time') self.double_tap_time = time / 1000.0 self.touches = {}
from kivy.config import Config from kivy.clock import Clock from kivy.factory import Factory from kivy.uix.stencilview import StencilView from kivy.metrics import dp from kivy.effects.dampedscroll import DampedScrollEffect from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \ ObjectProperty, ListProperty, ReferenceListProperty, OptionProperty, \ ColorProperty from kivy.uix.behaviors import FocusBehavior # When we are generating documentation, Config doesn't exist _scroll_timeout = _scroll_distance = 0 if Config: _scroll_timeout = Config.getint('widgets', 'scroll_timeout') _scroll_distance = '{}sp'.format(Config.getint('widgets', 'scroll_distance')) class ScrollView(StencilView): '''ScrollView class. See module documentation for more information. :Events: `on_scroll_start` Generic event fired when scrolling starts from touch. `on_scroll_move` Generic event fired when scrolling move from touch. `on_scroll_stop` Generic event fired when scrolling stops from touch.
def __init__(self, **kwargs): kwargs.setdefault('force', False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get('force'): return self.initialized = False self._is_desktop = Config.getboolean('kivy', 'desktop') # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger( self.create_window, -1) # Create a trigger for updating the keyboard height self.trigger_keyboard_height = Clock.create_trigger( self._upd_kbd_height, .5) # set the default window parameter according to the configuration if 'borderless' not in kwargs: kwargs['borderless'] = Config.getboolean('graphics', 'borderless') if 'fullscreen' not in kwargs: fullscreen = Config.get('graphics', 'fullscreen') if fullscreen not in ('auto', 'fake'): fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup') kwargs['fullscreen'] = fullscreen if 'width' not in kwargs: kwargs['width'] = Config.getint('graphics', 'width') if 'height' not in kwargs: kwargs['height'] = Config.getint('graphics', 'height') if 'rotation' not in kwargs: kwargs['rotation'] = Config.getint('graphics', 'rotation') if 'position' not in kwargs: kwargs['position'] = Config.getdefault('graphics', 'position', 'auto') if 'top' in kwargs: kwargs['position'] = 'custom' kwargs['top'] = kwargs['top'] else: kwargs['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: kwargs['position'] = 'custom' kwargs['left'] = kwargs['left'] else: kwargs['left'] = Config.getint('graphics', 'left') kwargs['_size'] = (kwargs.pop('width'), kwargs.pop('height')) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window self._bind_create_window() self.bind(size=self.trigger_keyboard_height, rotation=self.trigger_keyboard_height) self.bind(softinput_mode=lambda *dt: self.update_viewport(), keyboard_height=lambda *dt: self.update_viewport()) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {'system': self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # NOQA # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # assign the default context of the widget creation if not hasattr(self, '_context'): self._context = get_current_context() # mark as initialized self.initialized = True
from os.path import dirname, expanduser, join from kivy.config import Config from kivy.metrics import dp, sp screen_width = Config.getint('graphics', 'width') screen_height = Config.getint('graphics', 'height') # the real dp() and sp() functions somehow dont work here def dp(val): return int(val * screen_width / 600) sp = dp kgui_dir = dirname(__file__) klipper_dir = dirname(dirname(dirname(kgui_dir))) sdcard_path = expanduser('~/Files') usb_mount_dir = 'USB-Device' history_file = join(sdcard_path, ".history.json") #never assume pixels are square :} disp_vertical_stretch = 1.05 large_font = sp(32) normal_font = sp(23) small_font = sp(17) extra_small_font = sp(14) mars = 1.1 * screen_height radius = dp(10) icon_radius = dp(4.5) popup_radius = dp(15) status_bar_height = dp(29)
def __init__(self, **kwargs): super(ClockBaseBehavior, self).__init__(**kwargs) self._duration_ts0 = self._start_tick = self._last_tick = self.time() self._max_fps = float(Config.getint('graphics', 'maxfps'))
class Kpritz(App): bookname = StringProperty(Config.get('Kpritz', 'lastbook')) speed = NumericProperty(Config.getint('Kpritz', 'speed')) bg_color = ListProperty( map(float, Config.get('Kpritz', 'bg_color').split())) fg_color = ListProperty( map(float, Config.get('Kpritz', 'fg_color').split())) hl_color = ListProperty( map(float, Config.get('Kpritz', 'hl_color').split())) text_size = NumericProperty(Config.getfloat('Kpritz', 'text_size')) default_path = StringProperty(Config.get('Kpritz', 'default_path')) text = ListProperty([]) position = NumericProperty(0) def build(self): root = Builder.load_string(KV) if self.bookname: try: self.open('', self.bookname) except IOError: self.bookname = '' return root def save_position(self): Config.set('Kpritz', self.bookname, self.position) def open(self, path, filename): if self.position: self.save_position() f = join(path, filename) Config.set('Kpritz', 'lastbook', f) self.bookname = f try: if f.endswith('.epub'): self.text = dump(f).split() elif f.endswith('.html'): h = html2text.HTML2Text() h.ignore_links = True h.unicode_snob = True h.ignore_images = True h.ignore_emphasis = True h.skip_internal_links = True with open(f) as fd: self.text = h.handle(fd.read()).split() else: with open(f) as fd: self.text = [ unicode(w, 'utf-8') for w in fd.read().split() ] except Exception, e: p = Factory.ErrorPopup().open() p.message = str(e) try: self.position = Config.getint('Kpritz', f) except NoOptionError: self.position = 0
def setUp(self): self.maxfps = Config.getint('graphics', 'maxfps') super(AsyncImageTestCase, self).setUp()
from kivy.factory import Factory from kivy.event import EventDispatcher from kivy.uix.widget import Widget from kivy.graphics import Fbo, ClearBuffers, ClearColor, Scale, Translate from kivy.graphics.texture import Texture from kivy.lang.builder import Builder from kivy.core.window import Window from kivy.config import Config __all__ = ('DraggableObjectBehavior', 'DraggableLayoutBehavior', 'DraggableController', 'PreviewWidget', 'SpacerWidget', 'DraggableBoxLayoutBehavior', 'DraggableGridLayoutBehavior') _drag_distance = 0 if Config: _drag_distance = '{}sp'.format(Config.getint('widgets', 'scroll_distance')) def collide_parent_tree(widget, x, y): """Returns whether (x, y) collide with the widget and all its parents. """ if not widget.collide_point(x, y): return False parent = widget.parent while parent and hasattr(parent, 'to_parent'): x, y = parent.to_parent(x, y) # transform to parent's parent's if not parent.collide_point(x, y): return False parent = parent.parent
def __init__(self, **kwargs): kwargs.setdefault('force', False) kwargs.setdefault('config', None) # don't init window 2 times, # except if force is specified if self.__initialized and not kwargs.get('force'): return super(WindowBase, self).__init__() # init privates self._keyboard_callback = None self._modifiers = [] self._size = (0, 0) self._rotation = 0 self._clearcolor = [0, 0, 0, 0] # event subsystem self.register_event_type('on_draw') self.register_event_type('on_flip') self.register_event_type('on_rotate') self.register_event_type('on_resize') self.register_event_type('on_close') self.register_event_type('on_motion') self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') self.register_event_type('on_mouse_down') self.register_event_type('on_mouse_move') self.register_event_type('on_mouse_up') self.register_event_type('on_keyboard') self.register_event_type('on_key_down') self.register_event_type('on_key_up') self.children = [] self.parent = self #self.visible = True # add view if 'view' in kwargs: self.add_widget(kwargs.get('view')) # get window params, user options before config option params = {} if 'fullscreen' in kwargs: params['fullscreen'] = kwargs.get('fullscreen') else: params['fullscreen'] = Config.get('graphics', 'fullscreen') if params['fullscreen'] not in ('auto', 'fake'): params['fullscreen'] = params['fullscreen'].lower() in \ ('true', '1', 'yes', 'yup') if 'width' in kwargs: params['width'] = kwargs.get('width') else: params['width'] = Config.getint('graphics', 'width') if 'height' in kwargs: params['height'] = kwargs.get('height') else: params['height'] = Config.getint('graphics', 'height') if 'rotation' in kwargs: params['rotation'] = kwargs.get('rotation') else: params['rotation'] = Config.getint('graphics', 'rotation') params['position'] = Config.get('graphics', 'position', 'auto') if 'top' in kwargs: params['position'] = 'custom' params['top'] = kwargs.get('top') else: params['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: params['position'] = 'custom' params['left'] = kwargs.get('left') else: params['left'] = Config.getint('graphics', 'left') # before creating the window import kivy.core.gl # configure the window self.params = params self.create_window() # attach modules + listener event Modules.register_window(self) EventLoop.set_window(self) EventLoop.add_event_listener(self) # mark as initialized self.__initialized = True
def initialize_settings(): Config.read('config.ini') Stage.player_count = Config.getint('user_settings', 'player_count') Stage.agent_number = Config.getint('user_settings', 'agent_number')
class WindowPygame(WindowBase): def create_window(self, *largs): # ensure the mouse is still not up after window creation, otherwise, we # have some weird bugs self.dispatch('on_mouse_up', 0, 0, 'all', []) # force display to show (available only for fullscreen) displayidx = Config.getint('graphics', 'display') if not 'SDL_VIDEO_FULLSCREEN_HEAD' in environ and displayidx != -1: environ['SDL_VIDEO_FULLSCREEN_HEAD'] = '%d' % displayidx # init some opengl, same as before. self.flags = pygame.HWSURFACE | pygame.OPENGL | \ pygame.DOUBLEBUF # right now, activate resizable window only on linux. # on window / macosx, the opengl context is lost, and we need to # reconstruct everything. Check #168 for a state of the work. if platform() in ('linux', 'macosx', 'win') and \ Config.getint('graphics', 'resizable'): self.flags |= pygame.RESIZABLE try: pygame.display.init() except pygame.error, e: raise CoreCriticalException(e.message) multisamples = Config.getint('graphics', 'multisamples') if multisamples > 0: pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, multisamples) pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 16) pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, 1) pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8) pygame.display.set_caption(self.title) if self.position == 'auto': self._pos = None elif self.position == 'custom': self._pos = self.left, self.top else: raise ValueError('position token in configuration accept only ' '"auto" or "custom"') if self.fullscreen == 'fake': Logger.debug('WinPygame: Set window to fake fullscreen mode') self.flags |= pygame.NOFRAME # if no position set, in fake mode, we always need to set the # position. so replace 0, 0. if self._pos is None: self._pos = (0, 0) environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos elif self.fullscreen is True: Logger.debug('WinPygame: Set window to fullscreen mode') self.flags |= pygame.FULLSCREEN elif self._pos is not None: environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos # never stay with a None pos, application using w.center will be fired. self._pos = (0, 0) # prepare keyboard repeat_delay = int(Config.get('kivy', 'keyboard_repeat_delay')) repeat_rate = float(Config.get('kivy', 'keyboard_repeat_rate')) pygame.key.set_repeat(repeat_delay, int(1000. / repeat_rate)) # set window icon before calling set_mode try: filename_icon = Config.get('kivy', 'window_icon') if filename_icon == '': logo_size = 512 if platform() == 'darwin' else 32 filename_icon = join(kivy_home_dir, 'icon', 'kivy-icon-%d.png' % logo_size) self.set_icon(filename_icon) except: Logger.exception('Window: cannot set icon') # try to use mode with multisamples try: self._pygame_set_mode() except pygame.error, e: if multisamples: Logger.warning('WinPygame: Video: failed (multisamples=%d)' % multisamples) Logger.warning('WinPygame: trying without antialiasing') pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 0) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, 0) multisamples = 0 try: self._pygame_set_mode() except pygame.error, e: raise CoreCriticalException(e.message)
from copy import copy from functools import partial from kivy.animation import Animation from kivy.config import Config from kivy.clock import Clock from kivy.uix.stencilview import StencilView from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \ ObjectProperty, ListProperty # When we are generating documentation, Config doesn't exist _scroll_moves = _scroll_timeout = _scroll_stoptime = \ _scroll_distance = _scroll_friction = 0 if Config: _scroll_timeout = Config.getint('widgets', 'scroll_timeout') _scroll_stoptime = Config.getint('widgets', 'scroll_stoptime') _scroll_distance = Config.getint('widgets', 'scroll_distance') _scroll_moves = Config.getint('widgets', 'scroll_moves') _scroll_friction = Config.getfloat('widgets', 'scroll_friction') class FixedList(list): '''A list. In addition, you can specify the maximum length. This will save memory. ''' def __init__(self, maxlength=0, *args, **kwargs): super(FixedList, self).__init__(*args, **kwargs) self.maxlength = maxlength def append(self, x):
def __init__(self): self.timeout = Config.getint('postproc', 'retain_time') / 1000.0 self.distance = Config.getint('postproc', 'retain_distance') / 1000.0 self._available = [] self._links = {}
def setupBackground(self,filename): self.background = Background() domLevel = parse(filename) backgroundNodes = domLevel.getElementsByTagName("background") backgroundNode = backgroundNodes[0] for node in backgroundNode.childNodes: if node.localName == "layer": texturename = 0 tilesizex = 0 tilesizey = 0 positionx = 0 positiony = 0 layersizex = 0 layersizey = 0 offsetx = 0 offsety = 0 for childnode in node.childNodes: if childnode.localName == "texture": texturename = childnode.getAttribute('value') if childnode.localName == "tilesize": values = childnode.getAttribute('value').split(',') if values[0] == 'screenw': tilesizex = Config.getint('graphics', 'width') else: tilesizex = float(values[0]) if values[1] == 'screenh': tilesizey = Config.getint('graphics', 'height') else: tilesizey = float(values[1]) if childnode.localName == "position": values = childnode.getAttribute('value').split(',') if values[0] == 'screenw': positionx = Config.getint('graphics', 'width') else: positionx = float(values[0]) if values[1] == 'screenh': positiony = Config.getint('graphics', 'height') else: positiony = float(values[1]) if childnode.localName == "offset": values = childnode.getAttribute('value').split(',') if values[0] == 'screenw': offsetx = Config.getint('graphics', 'width') else: offsetx = float(values[0]) if values[1] == 'screenh': offsety = Config.getint('graphics', 'height') else: offsety = float(values[1]) if childnode.localName == "layersize": values = childnode.getAttribute('value').split(',') if values[0] == 'screenw': layersizex = Config.getint('graphics', 'width') else: layersizex = float(values[0]) if values[1] == 'screenh': layersizey = Config.getint('graphics', 'height') else: layersizey = float(values[1]) layer = Layer(TextureHelper.loadTextureFromFile(texturename),tilesizex,tilesizey,positionx,positiony,offsetx,offsety,layersizex,layersizey) self.background.addLayer(layer)
def __init__(self, *args, **kwargs): super(SettingsMenu, self).__init__(*args, **kwargs) # setting switch in good position self.rotation_prop = 'down' if Config.getint( "graphics", "rotation") == 0 else 'normal' self.ids.rotation_checkbox.bind(state=self.rotate)
from kivy.compat import string_types from kivy.config import Config from kivy.clock import Clock from kivy.factory import Factory from kivy.uix.stencilview import StencilView from kivy.metrics import sp, dp from kivy.effects.dampedscroll import DampedScrollEffect from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \ ObjectProperty, ListProperty, ReferenceListProperty, OptionProperty from kivy.uix.behaviors import FocusBehavior # When we are generating documentation, Config doesn't exist _scroll_timeout = _scroll_distance = 0 if Config: _scroll_timeout = Config.getint('widgets', 'scroll_timeout') _scroll_distance = '{}sp'.format(Config.getint('widgets', 'scroll_distance')) class ScrollView(StencilView): '''ScrollView class. See module documentation for more information. :Events: `on_scroll_start` Generic event fired when scrolling starts from touch. `on_scroll_move` Generic event fired when scrolling move from touch. `on_scroll_stop` Generic event fired when scrolling stops from touch. .. versionchanged:: 1.9.0
def __init__(self, **kwargs): kwargs.setdefault("force", False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get("force"): return self.initialized = False # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger(self.create_window, -1) # Create a trigger for updating the keyboard height self.trigger_keyboard_height = Clock.create_trigger(self._upd_kbd_height, 0.5) # set the default window parameter according to the configuration if "fullscreen" not in kwargs: fullscreen = Config.get("graphics", "fullscreen") if fullscreen not in ("auto", "fake"): fullscreen = fullscreen.lower() in ("true", "1", "yes", "yup") kwargs["fullscreen"] = fullscreen if "width" not in kwargs: kwargs["width"] = Config.getint("graphics", "width") if "height" not in kwargs: kwargs["height"] = Config.getint("graphics", "height") if "rotation" not in kwargs: kwargs["rotation"] = Config.getint("graphics", "rotation") if "position" not in kwargs: kwargs["position"] = Config.getdefault("graphics", "position", "auto") if "top" in kwargs: kwargs["position"] = "custom" kwargs["top"] = kwargs["top"] else: kwargs["top"] = Config.getint("graphics", "top") if "left" in kwargs: kwargs["position"] = "custom" kwargs["left"] = kwargs["left"] else: kwargs["left"] = Config.getint("graphics", "left") kwargs["_size"] = (kwargs.pop("width"), kwargs.pop("height")) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window for prop in ("fullscreen", "position", "top", "left", "_size", "system_size"): self.bind(**{prop: self.trigger_create_window}) self.bind(size=self.trigger_keyboard_height, rotation=self.trigger_keyboard_height) self.bind(softinput_mode=lambda *dt: self.update_viewport(), keyboard_height=lambda *dt: self.update_viewport()) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {"system": self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # NOQA # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # assign the default context of the widget creation if not hasattr(self, "_context"): self._context = get_current_context() # mark as initialized self.initialized = True
def create_window(self, *largs): # ensure the mouse is still not up after window creation, otherwise, we # have some weird bugs self.dispatch('on_mouse_up', 0, 0, 'all', []) # force display to show (available only for fullscreen) displayidx = Config.getint('graphics', 'display') if not 'SDL_VIDEO_FULLSCREEN_HEAD' in environ and displayidx != -1: environ['SDL_VIDEO_FULLSCREEN_HEAD'] = '%d' % displayidx # init some opengl, same as before. self.flags = pygame.HWSURFACE | pygame.OPENGL | pygame.DOUBLEBUF # right now, activate resizable window only on linux. # on window / macosx, the opengl context is lost, and we need to # reconstruct everything. Check #168 for a state of the work. if platform in ('linux', 'macosx', 'win') and \ Config.getint('graphics', 'resizable'): self.flags |= pygame.RESIZABLE try: pygame.display.init() except pygame.error as e: raise CoreCriticalException(e.message) multisamples = Config.getint('graphics', 'multisamples') if multisamples > 0: pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, multisamples) pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 16) pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, 1) pygame.display.set_caption(self.title) if self.position == 'auto': self._pos = None elif self.position == 'custom': self._pos = self.left, self.top else: raise ValueError('position token in configuration accept only ' '"auto" or "custom"') if self.fullscreen == 'fake': Logger.debug('WinPygame: Set window to fake fullscreen mode') self.flags |= pygame.NOFRAME # if no position set, in fake mode, we always need to set the # position. so replace 0, 0. if self._pos is None: self._pos = (0, 0) environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos elif self.fullscreen in ('auto', True): Logger.debug('WinPygame: Set window to fullscreen mode') self.flags |= pygame.FULLSCREEN elif self._pos is not None: environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos # never stay with a None pos, application using w.center will be fired. self._pos = (0, 0) # prepare keyboard repeat_delay = int(Config.get('kivy', 'keyboard_repeat_delay')) repeat_rate = float(Config.get('kivy', 'keyboard_repeat_rate')) pygame.key.set_repeat(repeat_delay, int(1000. / repeat_rate)) # set window icon before calling set_mode try: filename_icon = self.icon or Config.get('kivy', 'window_icon') if filename_icon == '': logo_size = 32 if platform == 'macosx': logo_size = 512 elif platform == 'win': logo_size = 64 filename_icon = 'kivy-icon-{}.png'.format(logo_size) filename_icon = resource_find( join(kivy_data_dir, 'logo', filename_icon)) self.set_icon(filename_icon) except: Logger.exception('Window: cannot set icon') # try to use mode with multisamples try: self._pygame_set_mode() except pygame.error as e: if multisamples: Logger.warning('WinPygame: Video: failed (multisamples=%d)' % multisamples) Logger.warning('WinPygame: trying without antialiasing') pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 0) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, 0) multisamples = 0 try: self._pygame_set_mode() except pygame.error as e: raise CoreCriticalException(e.message) else: raise CoreCriticalException(e.message) info = pygame.display.Info() self._size = (info.current_w, info.current_h) #self.dispatch('on_resize', *self._size) # in order to debug futur issue with pygame/display, let's show # more debug output. Logger.debug('Window: Display driver ' + pygame.display.get_driver()) Logger.debug('Window: Actual window size: %dx%d', info.current_w, info.current_h) if platform != 'android': # unsupported platform, such as android that doesn't support # gl_get_attribute. Logger.debug('Window: Actual color bits r%d g%d b%d a%d', pygame.display.gl_get_attribute(pygame.GL_RED_SIZE), pygame.display.gl_get_attribute(pygame.GL_GREEN_SIZE), pygame.display.gl_get_attribute(pygame.GL_BLUE_SIZE), pygame.display.gl_get_attribute(pygame.GL_ALPHA_SIZE)) Logger.debug('Window: Actual depth bits: %d', pygame.display.gl_get_attribute(pygame.GL_DEPTH_SIZE)) Logger.debug( 'Window: Actual stencil bits: %d', pygame.display.gl_get_attribute(pygame.GL_STENCIL_SIZE)) Logger.debug( 'Window: Actual multisampling samples: %d', pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLESAMPLES)) super(WindowPygame, self).create_window() # set mouse visibility pygame.mouse.set_visible(Config.getboolean('graphics', 'show_cursor')) # if we are on android platform, automaticly create hooks if android: from kivy.support import install_android install_android()
def __init__(self, **kwargs): kwargs.setdefault('force', False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get('force'): return self.initialized = False # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger( self.create_window, -1) # set the default window parameter according to the configuration if 'fullscreen' not in kwargs: fullscreen = Config.get('graphics', 'fullscreen') if fullscreen not in ('auto', 'fake'): fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup') kwargs['fullscreen'] = fullscreen if 'width' not in kwargs: kwargs['width'] = Config.getint('graphics', 'width') if 'height' not in kwargs: kwargs['height'] = Config.getint('graphics', 'height') if 'rotation' not in kwargs: kwargs['rotation'] = Config.getint('graphics', 'rotation') if 'position' not in kwargs: kwargs['position'] = Config.getdefault('graphics', 'position', 'auto') if 'top' in kwargs: kwargs['position'] = 'custom' kwargs['top'] = kwargs['top'] else: kwargs['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: kwargs['position'] = 'custom' kwargs['left'] = kwargs['left'] else: kwargs['left'] = Config.getint('graphics', 'left') kwargs['_size'] = (kwargs.pop('width'), kwargs.pop('height')) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window for prop in ( 'fullscreen', 'position', 'top', 'left', '_size', 'system_size'): self.bind(**{prop: self.trigger_create_window}) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {'system': self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window import kivy.core.gl # configure the window self.create_window() # attach modules + listener event EventLoop.set_window(self) Modules.register_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # mark as initialized self.initialized = True
__all__ = ('ScrollView', ) from functools import partial from kivy.animation import Animation from kivy.config import Config from kivy.clock import Clock from kivy.uix.stencilview import StencilView from kivy.metrics import sp from kivy.effects.dampedscroll import DampedScrollEffect from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \ ObjectProperty, ListProperty # When we are generating documentation, Config doesn't exist _scroll_timeout = _scroll_distance = 0 if Config: _scroll_timeout = Config.getint('widgets', 'scroll_timeout') _scroll_distance = sp(Config.getint('widgets', 'scroll_distance')) class ScrollView(StencilView): '''ScrollView class. See module documentation for more information. .. versionchanged:: 1.7.0 `auto_scroll`, `scroll_friction`, `scroll_moves`, `scroll_stoptime' has been deprecated, use :data:`effect_cls` instead. ''' scroll_distance = NumericProperty(_scroll_distance) '''Distance to move before scrolling the :class:`ScrollView`, in pixels. As soon as the distance has been traveled, the :class:`ScrollView` will start
def create_clock(self, touch, *args): callback = partial(self.single_tap, touch) Clock.schedule_once(callback, Config.getint('postproc', 'double_tap_time') / 1000) touch.ud['event'] = callback
def create_window(self): params = self.params # force display to show (available only for fullscreen) displayidx = Config.getint('graphics', 'display') if not 'SDL_VIDEO_FULLSCREEN_HEAD' in os.environ and displayidx != -1: os.environ['SDL_VIDEO_FULLSCREEN_HEAD'] = '%d' % displayidx # init some opengl, same as before. self.flags = pygame.HWSURFACE | pygame.OPENGL | \ pygame.DOUBLEBUF # right now, activate resizable window only on linux. # on window / macosx, the opengl context is lost, and we need to # reconstruct everything. Check #168 for a state of the work. if sys.platform == 'linux2': self.flags |= pygame.RESIZABLE pygame.display.init() multisamples = Config.getint('graphics', 'multisamples') if multisamples > 0: pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, multisamples) pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 16) pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, 1) pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8) pygame.display.set_caption('kivy') if params['position'] == 'auto': self._pos = None elif params['position'] == 'custom': self._pos = params['left'], params['top'] else: raise ValueError('position token in configuration accept only ' '"auto" or "custom"') self._fullscreenmode = params['fullscreen'] if self._fullscreenmode == 'fake': Logger.debug('WinPygame: Set window to fake fullscreen mode') self.flags |= pygame.NOFRAME # if no position set, in fake mode, we always need to set the # position. so replace 0, 0. if self._pos is None: self._pos = (0, 0) os.environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos elif self._fullscreenmode: Logger.debug('WinPygame: Set window to fullscreen mode') self.flags |= pygame.FULLSCREEN elif self._pos is not None: os.environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos # never stay with a None pos, application using w.center will be fired. self._pos = (0, 0) # prepare keyboard repeat_delay = int(Config.get('kivy', 'keyboard_repeat_delay')) repeat_rate = float(Config.get('kivy', 'keyboard_repeat_rate')) pygame.key.set_repeat(repeat_delay, int(1000. / repeat_rate)) # set window icon before calling set_mode try: filename_icon = Config.get('kivy', 'window_icon') self.set_icon(filename_icon) except: Logger.exception('Window: cannot set icon') # init ourself size + setmode # before calling on_resize self._size = params['width'], params['height'] # try to use mode with multisamples try: self._pygame_set_mode() except pygame.error: if multisamples: Logger.warning('WinPygame: Video: failed (multisamples=%d)' % multisamples) Logger.warning('WinPygame: trying without antialiasing') pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 0) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, 0) multisamples = 0 self._pygame_set_mode() else: Logger.warning('WinPygame: Video setup failed :-(') raise super(WindowPygame, self).create_window() # set mouse visibility pygame.mouse.set_visible(Config.getboolean('graphics', 'show_cursor')) # set rotation self.rotation = params['rotation']
def create_window(self, *largs): # ensure the mouse is still not up after window creation, otherwise, we # have some weird bugs self.dispatch('on_mouse_up', 0, 0, 'all', []) # force display to show (available only for fullscreen) displayidx = Config.getint('graphics', 'display') if not 'SDL_VIDEO_FULLSCREEN_HEAD' in environ and displayidx != -1: environ['SDL_VIDEO_FULLSCREEN_HEAD'] = '%d' % displayidx # init some opengl, same as before. self.flags = pygame.HWSURFACE | pygame.OPENGL | pygame.DOUBLEBUF # right now, activate resizable window only on linux. # on window / macosx, the opengl context is lost, and we need to # reconstruct everything. Check #168 for a state of the work. if platform in ('linux', 'macosx', 'win') and \ Config.getint('graphics', 'resizable'): self.flags |= pygame.RESIZABLE try: pygame.display.init() except pygame.error as e: raise CoreCriticalException(e.message) multisamples = Config.getint('graphics', 'multisamples') if multisamples > 0: pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1) pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, multisamples) pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 16) pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, 1) pygame.display.set_caption(self.title) if self.position == 'auto': self._pos = None elif self.position == 'custom': self._pos = self.left, self.top else: raise ValueError('position token in configuration accept only ' '"auto" or "custom"') if self.fullscreen == 'fake': Logger.debug('WinPygame: Set window to fake fullscreen mode') self.flags |= pygame.NOFRAME # if no position set, in fake mode, we always need to set the # position. so replace 0, 0. if self._pos is None: self._pos = (0, 0) environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos elif self.fullscreen in ('auto', True): Logger.debug('WinPygame: Set window to fullscreen mode') self.flags |= pygame.FULLSCREEN elif self._pos is not None: environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % self._pos # never stay with a None pos, application using w.center will be fired. self._pos = (0, 0) # prepare keyboard repeat_delay = int(Config.get('kivy', 'keyboard_repeat_delay')) repeat_rate = float(Config.get('kivy', 'keyboard_repeat_rate')) pygame.key.set_repeat(repeat_delay, int(1000. / repeat_rate)) # set window icon before calling set_mode try: filename_icon = self.icon or Config.get('kivy', 'window_icon') if filename_icon == '': logo_size = 32 if platform == 'macosx': logo_size = 512 elif platform == 'win': logo_size = 64 filename_icon = 'kivy-icon-{}.png'.format(logo_size) filename_icon = resource_find( join(kivy_data_dir, 'logo', filename_icon)) self.set_icon(filename_icon) except: Logger.exception('Window: cannot set icon') # try to use mode with multisamples try: self._pygame_set_mode() except pygame.error as e: if multisamples: Logger.warning('WinPygame: Video: failed (multisamples=%d)' % multisamples) Logger.warning('WinPygame: trying without antialiasing') pygame.display.gl_set_attribute( pygame.GL_MULTISAMPLEBUFFERS, 0) pygame.display.gl_set_attribute( pygame.GL_MULTISAMPLESAMPLES, 0) multisamples = 0 try: self._pygame_set_mode() except pygame.error as e: raise CoreCriticalException(e.message) else: raise CoreCriticalException(e.message) info = pygame.display.Info() self._size = (info.current_w, info.current_h) #self.dispatch('on_resize', *self._size) # in order to debug futur issue with pygame/display, let's show # more debug output. Logger.debug('Window: Display driver ' + pygame.display.get_driver()) Logger.debug('Window: Actual window size: %dx%d', info.current_w, info.current_h) if platform != 'android': # unsupported platform, such as android that doesn't support # gl_get_attribute. Logger.debug( 'Window: Actual color bits r%d g%d b%d a%d', pygame.display.gl_get_attribute(pygame.GL_RED_SIZE), pygame.display.gl_get_attribute(pygame.GL_GREEN_SIZE), pygame.display.gl_get_attribute(pygame.GL_BLUE_SIZE), pygame.display.gl_get_attribute(pygame.GL_ALPHA_SIZE)) Logger.debug( 'Window: Actual depth bits: %d', pygame.display.gl_get_attribute(pygame.GL_DEPTH_SIZE)) Logger.debug( 'Window: Actual stencil bits: %d', pygame.display.gl_get_attribute(pygame.GL_STENCIL_SIZE)) Logger.debug( 'Window: Actual multisampling samples: %d', pygame.display.gl_get_attribute(pygame.GL_MULTISAMPLESAMPLES)) super(WindowPygame, self).create_window() # set mouse visibility pygame.mouse.set_visible( Config.getboolean('graphics', 'show_cursor')) # if we are on android platform, automaticly create hooks if android: from kivy.support import install_android install_android()
def __init__(self, **kwargs): kwargs.setdefault('force', False) # don't init window 2 times, # except if force is specified if WindowBase.__instance is not None and not kwargs.get('force'): return self.initialized = False # event subsystem self.register_event_type('on_draw') self.register_event_type('on_flip') self.register_event_type('on_rotate') self.register_event_type('on_resize') self.register_event_type('on_close') self.register_event_type('on_motion') self.register_event_type('on_touch_down') self.register_event_type('on_touch_move') self.register_event_type('on_touch_up') self.register_event_type('on_mouse_down') self.register_event_type('on_mouse_move') self.register_event_type('on_mouse_up') self.register_event_type('on_keyboard') self.register_event_type('on_key_down') self.register_event_type('on_key_up') self.register_event_type('on_dropfile') # create a trigger for update/create the window when one of window # property changes self.trigger_create_window = Clock.create_trigger( self.create_window, -1) # set the default window parameter according to the configuration if 'fullscreen' not in kwargs: fullscreen = Config.get('graphics', 'fullscreen') if fullscreen not in ('auto', 'fake'): fullscreen = fullscreen.lower() in ('true', '1', 'yes', 'yup') kwargs['fullscreen'] = fullscreen if 'width' not in kwargs: kwargs['width'] = Config.getint('graphics', 'width') if 'height' not in kwargs: kwargs['height'] = Config.getint('graphics', 'height') if 'rotation' not in kwargs: kwargs['rotation'] = Config.getint('graphics', 'rotation') if 'position' not in kwargs: kwargs['position'] = Config.get('graphics', 'position', 'auto') if 'top' in kwargs: kwargs['position'] = 'custom' kwargs['top'] = kwargs['top'] else: kwargs['top'] = Config.getint('graphics', 'top') if 'left' in kwargs: kwargs['position'] = 'custom' kwargs['left'] = kwargs['left'] else: kwargs['left'] = Config.getint('graphics', 'left') kwargs['_size'] = (kwargs.pop('width'), kwargs.pop('height')) super(WindowBase, self).__init__(**kwargs) # bind all the properties that need to recreate the window for prop in ('fullscreen', 'position', 'top', 'left', '_size', 'system_size'): self.bind(**{prop: self.trigger_create_window}) # init privates self._system_keyboard = Keyboard(window=self) self._keyboards = {'system': self._system_keyboard} self._vkeyboard_cls = None self.children = [] self.parent = self # before creating the window __import__('kivy.core.gl') # configure the window self.create_window() # attach modules + listener event Modules.register_window(self) EventLoop.set_window(self) EventLoop.add_event_listener(self) # manage keyboard(s) self.configure_keyboards() # mark as initialized self.initialized = True
from kivy.animation import Animation from kivy.compat import string_types from kivy.config import Config from kivy.clock import Clock from kivy.factory import Factory from kivy.uix.stencilview import StencilView from kivy.metrics import sp from kivy.effects.dampedscroll import DampedScrollEffect from kivy.properties import NumericProperty, BooleanProperty, AliasProperty, \ ObjectProperty, ListProperty, ReferenceListProperty, OptionProperty # When we are generating documentation, Config doesn't exist _scroll_timeout = _scroll_distance = 0 if Config: _scroll_timeout = Config.getint('widgets', 'scroll_timeout') _scroll_distance = sp(Config.getint('widgets', 'scroll_distance')) class ScrollView(StencilView): '''ScrollView class. See module documentation for more information. .. versionchanged:: 1.7.0 `auto_scroll`, `scroll_friction`, `scroll_moves`, `scroll_stoptime' has been deprecated, use :attr:`effect_cls` instead. ''' scroll_distance = NumericProperty(_scroll_distance) '''Distance to move before scrolling the :class:`ScrollView`, in pixels. As soon as the distance has been traveled, the :class:`ScrollView` will start to scroll, and no touch event will go to children.
from kivy.graphics import * from kivy.uix.togglebutton import ToggleButton from kivy.uix.gridlayout import GridLayout from kivy.uix.screenmanager import Screen, ScreenManager from kivy.uix.screenmanager import FadeTransition from kivy.utils import platform txr_size = 33 if platform != 'android': from screeninfo import get_monitors for m in get_monitors(): print(str(m.width), str(m.height)) the_small = m.width if m.width <= m.height else m.height the_small = int(the_small * 0.9) Config.set('graphics', 'width', the_small) Config.set('graphics', 'height', the_small) window_height = Config.getint('graphics', "height") window_width = Config.getint('graphics', "width") # size_fixer = window_width / window_height size_fixer = 1 else: from kivy.core.window import Window Window.fullscreen = True window_height = Config.getint('graphics', "height") window_width = Config.getint('graphics', "width") size_fixer = window_width / window_height inbox_posx = (0.255 * window_width, 0.745 * window_width) inbox_posy = ((0.1 * size_fixer + 0.15 * size_fixer) * window_width, (0.1 * size_fixer + 0.64 * size_fixer) * window_width) Config.set('graphics', 'resizable', False) # 0:Orange 1:White 2:Blue 3:Green 4:Yellow