mirror of https://github.com/kivy/kivy.git
Page:
Scaler for Retina screen
Pages
A draggable scrollbar using a slider
AdBuddiz Android advertisements integration for Kivy apps
Advanced Graphics: In Progress
An example of background Twisted server running on Android
Android Background Services
Android SDK NDK Information
Android SDK NDK Informations
Android native embedded browser
Android style menu app skeleton
Background Service using P4A android.service
Batch installer for windows(KivyInstaller)
Breaking changes in Kivy
Building Portable Package
Button(s) in settings panel
Buttons in Settings panel
Community Guidelines
Connecting Kivy with Anaconda (OSX)
Contextual Menus
Contextual menus
Control alpha of all the children
Create source distribution release on PyPI
Creating a Release APK
Data driven variables with kivy properties
Debugging widget sizes
Deep Linking with iOS and Android
Delayed Work using Clock
Drag and Drop Widgets
Dragable Widget
Draggable Scalable Button
Editable ComboBox
Editable Label
Embedding a Carousel inside a TabbedPanel
GestureBox
Home
Implementing Android Adaptive Icons
KEP001: Instantiate things other than widgets from kv
Kivy 2.0 api breaks
Kivy Blogs and Blog Posts
Kivy Python 2 Support Timeline
Kivy Technical FAQ
Kv language preprocessing
Linking ScreenManager to a different Widget
List of Kivy Projects
Markup Summary
Menu on long touch
Migration guide from legacy garden packages
Moving kivy.garden.xxx to kivy_garden.xxx and kivy.deps.xxx to kivy_deps.xxx
On touch current widget
On touch on current widget
Packaging Kivy apps written in Python 3, targeting Windows using Nuitka
Pyjnius Vibrator Example
Release Checklist
Release notes for 1.10.0
Release notes for 1.11.0
Sample Gestures
Scaler for Retina screen
Scollable Options in Settings panel
Scrollable Label
Setting Up Kivy with various popular IDE's
Setting up Pycharm on OSX (older versions)
Setting up garden with Mac Ports
Setting up kivy with various popular IDE
Simple slider with value in label
Snippet template
Snippets awaiting moderation
Snippets
Starting Kivy App and Service on bootup on Android
Styling a Spinner and SpinnerOption in KV
Talks and tutorials
Theming Kivy
Tiled Maps & Tile Based Movement
Tiling the background of a widget with an image, pixel perfect
Ubuntu Touch
Updating widget content from a items list
User Snippets
Using Asynchronous programming inside a Kivy application
Using Buildozer on windows 10 using WSL
Viewport with fixed resolution autofit to window
Windows RT
Working with Python threads inside a Kivy application
rand0m app
wiki_proposed
2
Scaler for Retina screen
winstonwolff edited this page 2013-10-18 17:14:51 -07:00
Summary
- author: Mathieu Virbel
- kivy: >= 1.3.0
On Retina screen (iOS / iPad 3), the resolution is high (> 2000px) with an high DPI. Kivy currently don't support DPI, and then, all the text will look very tiny etc. We don't have anything for properly handling DPI and the moment, so you could use that Scaler class. You might do some change in order to use it.
Usage
#!python
# Put in your App.build() method
from kivy.utils import platform
from scaler import Scaler
class MyApp(App):
def build(self):
# construct your app here
self.root = MyRootWidget()
# special case for retina display, high dpi is not well handled
# in kivy. use scatter to "zoom in"
from kivy.core.window import Window
self._scaler = None
if platform() == 'ios' and (
Window.width > 2000 or Window.height > 2000):
self._scaler = Scaler(
size=Window.size, scale=2)
Window.add_widget(self._scaler)
# add the widget to Window or scaler
parent = self._scaler or Window
parent.add_widget(self.root)
Files
scaler.py
#!python
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ObjectProperty
from kivy.base import EventLoop
from kivy.lang import Builder
class Scaler(Widget):
scale = NumericProperty(2)
container = ObjectProperty(None)
def __init__(self, **kwargs):
from kivy.base import EventLoop
from kivy.lang import Builder
Builder.load_string('''
<Scaler>:
container: container
canvas.before:
PushMatrix
Scale:
scale: root.scale
canvas.after:
PopMatrix
FloatLayout:
id: container
size: root.width / root.scale, root.height / root.scale
''')
super(Scaler, self).__init__(**kwargs)
EventLoop.add_postproc_module(self)
def get_parent_window(self):
return self.container
def add_widget(self, widget):
if self.container is not None:
return self.container.add_widget(widget)
return super(Scaler, self).add_widget(widget)
def remove_widget(self, widget):
if self.container is not None:
return self.container.remove_widget(widget)
return super(Scaler, self).remove_widget(widget)
def process_to_local(self, x, y, relative=False):
if x is None:
return None, None
s = float(self.scale)
return x / s, y / s
def process(self, events):
transform = self.process_to_local
transformed = []
for etype, event in events:
# you might have a move and up event in the same process
# then avoid the double-transformation
if event in transformed:
continue
transformed.append(event)
event.sx, event.sy = transform(event.sx, event.sy)
if etype == 'begin':
event.osx, event.osy = transform(event.osx, event.osy)
else:
# update the delta
event.dsx = event.sx - event.psx
event.dsy = event.sy - event.psy
return events
##Comments Add your comments here ...
Is this relevant anymore now that kivy includes kivy.metrics? - Winston Oct 2013