Run a Twisted reactor inside IPython.
- Copy
twist.py
to~/.ipython/twist.py
- Copy
tpython
to~/bin/tpython
- Make
tpython
executable:chmod +x ~/bin/tpython
You may need to add $HOME/bin
to your path.
Run a Twisted reactor inside IPython.
twist.py
to ~/.ipython/twist.py
tpython
to ~/bin/tpython
tpython
executable: chmod +x ~/bin/tpython
You may need to add $HOME/bin
to your path.
from kivy.app import App | |
from kivy.uix.button import Button | |
from kivy.clock import Clock | |
from kivy.core.audio import SoundLoader | |
import time | |
import os | |
from subprocess import Popen, PIPE | |
class TestApp(App): | |
def __init__(self, **kwargs): |
from kivy.uix.widget import Widget | |
from kivy.graphics import Callback | |
from kivy.graphics.opengl import glBlendFunc, GL_ONE_MINUS_DST_COLOR, GL_ZERO | |
class InverseColor(Widget): | |
def __init__(self, **kwargs): | |
super(InverseColor, self).__init__(**kwargs) | |
from Xlib import display, error | |
import pygame.display | |
def get_current_window(): | |
wminfo = pygame.display.get_wm_info() | |
return wminfo.get('window', None) | |
def swallow(wid, x, y): | |
handler = error.CatchError() | |
from android.runnable import run_on_ui_thread | |
from jnius import autoclass | |
mActivity = autoclass('org.renpy.android.PythonActivity').mActivity | |
View = autoclass('android.view.View') | |
@run_on_ui_thread | |
def make_immersive(): | |
view = mActivity.getWindow().getDecorView() | |
view.setSystemUiVisibility( | |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
<category android:name="android.intent.category.HOME" /> | |
</intent-filter> |
Window.bind(on_touch_down=self._on_window_touch_down) | |
def _on_window_touch_down(self, win, touch): | |
if self.collide_point(*touch.pos): | |
return | |
if any(child.collide_point(*touch.pos) for child in self.children): | |
return | |
self._hide_handles() |
import kivy | |
kivy.require('1.8.0') | |
from kivy.app import App | |
from kivy.lang import Builder | |
root = Builder.load_string(''' | |
BoxLayout: | |
orientation: 'vertical' | |
Label: |
import os, sys | |
sys.stdin.close() | |
sys.stdout.close() | |
sys.stderr.close() | |
os.close(0) | |
os.close(1) | |
os.close(2) | |
import kivy | |
kivy.require('1.8.1') |
import os, sys | |
sys.stdin.close() | |
sys.stdout.close() | |
sys.stderr.close() | |
os.close(0) | |
os.close(1) | |
os.close(2) | |
sys.stdin = open('/dev/null', 'r') | |
sys.stdout = open('/dev/null', 'w') |