Skip to content

Instantly share code, notes, and snippets.

View tito's full-sized avatar

Mathieu Virbel tito

View GitHub Profile
@tito
tito / visiblecontainer.py
Created March 24, 2023 23:08
Kivy Widget for showing/hidding content.
from kivy.uix.relativelayout import RelativeLayout
from kivy.properties import BooleanProperty, NumericProperty
from kivy.animation import Animation
class VisibleContainer(RelativeLayout):
visible = BooleanProperty(True)
animated = BooleanProperty(False)
duration = NumericProperty(0.2)
capture = BooleanProperty(False)
@tito
tito / refactor.py
Created March 8, 2023 16:51
Using OpenAI/ChatGPT as refactoring tool
"""
Refactoring tool using ChatGPT from Vue 2 to Vue 3
$ export OPENAPI_APIKEY=sk.........
$ python refactor.py MyView.vue
"""
import os
import re
import sys
openapi: 3.0.0
info:
title: Example API
version: 1.0.0
servers:
- url: https://example.com/
paths:
/example2:
get:
tags:
@tito
tito / transparent_video_test.py
Last active June 28, 2023 20:36
Kivy/ffpyplayer transparent/alpha background video
"""
Kivy/ffpyplayer example to read transparent video
=================================================
Right now, VP9/ffmpeg encoder supports alpha channel, under the yuva420p
pixel format. But for decoding, the default libvp9 used by ffmpeg doesn't
support it, so we need to ask for libvpx-vp9 instead.
I was using a set of png image as a source, and got a VP9+alpha video with::
@tito
tito / main3d-kaki-example.py
Last active March 1, 2020 19:50
Panda3D with Kivy WRAPPER (Windows and Linux)
from pandawrapper import PandaApp
from kivy.base import runTouchApp
try:
from kaki.app import App
with_kaki = True
except ImportError:
from kivy.app import App
with_kaki = False
from kivy.factory import Factory as F
@tito
tito / main.py.py
Last active February 21, 2020 21:35 — forked from Cheaterman/main.py.py
main.py
import os
os.environ['KIVY_WINDOW'] = '' # noqa
os.environ['KIVY_GL_BACKEND'] = 'gl'
from kivy.base import EventLoop, runTouchApp
from kivy.core.window import WindowBase
from kivy.graphics import Callback, opengl as gl
from kivy.lang import Builder
from kivy.properties import ObjectProperty
@tito
tito / buildozer.spec
Last active April 28, 2024 03:37
Python for android / buildozer / androidx (MAY NOT WORK)
# to add in the spcec:
android.api = 28
android.minapi = 26
android.ndk = 17c
p4a.hook = p4a_hook.py
# i have my own set of java tools, don't use it if you don't want it
android.add_src = java/src/
@tito
tito / imgscatter.py
Created November 8, 2019 16:33
Image scatter that collide on white color of (can be changed for opaque)
from kivy.lang import Builder
from kivy.factory import Factory as F
from kivy.properties import StringProperty, ObjectProperty, BooleanProperty
from kivy.core.image import Image as CoreImage
Builder.load_string("""
<ImgScatter>:
size_hint: None, None
canvas:
Color:
@tito
tito / infinite-lon-mapview.patch
Created April 11, 2019 20:03
Mapview without longitude restriction
diff --git a/mapview/downloader.py b/mapview/downloader.py
index f5b9509..c3b1d75 100644
--- a/mapview/downloader.py
+++ b/mapview/downloader.py
@@ -77,7 +77,8 @@ class Downloader(object):
print("Downloader: use cache {}".format(cache_fn))
return tile.set_source, (cache_fn, )
tile_y = tile.map_source.get_row_count(tile.zoom) - tile.tile_y - 1
- uri = tile.map_source.url.format(z=tile.zoom, x=tile.tile_x, y=tile_y,
+ tile_x = tile.tile_x % (tile.map_source.get_col_count(tile.zoom))
@tito
tito / README.md
Created February 8, 2019 10:41
Using P4A Hooks

P4A hook example with buildozer

  1. create a tools/hooks/
  2. put your hook.py + hook_something.py...
  3. in buildozer.spec, reference p4a.hook = tools/hooks/hook.py
  4. adjust