Skip to content

Instantly share code, notes, and snippets.

View gottadiveintopython's full-sized avatar

水戸う納豆齋(Nattōsai Mitō) gottadiveintopython

View GitHub Profile
@gottadiveintopython
gottadiveintopython / wobblywidget.py
Created May 14, 2020 17:27 — forked from salt-die/wobblywidget.py
Make any widget wobble with wobbly widget!
"""For this to work, WobblyEffect should be parent to WobblyScatter.
Try setting WobblyScatter `size_hint = (None, None)` or `size = self.parent.size`
if having size issues.
"""
from kivy.clock import Clock
from kivy.uix.effectwidget import AdvancedEffectBase, EffectWidget
from kivy.uix.scatter import Scatter
from kivy.uix.widget import Widget
from itertools import product
"""TODO: ctrl + left/right (move past word), ctrl + backspace/del (del word), shift + del (del line)
...: Smart movement through leading indentation.
...: Except for first line, up/down to work normally on multi-line console input.
"""
from code import InteractiveConsole
from collections import deque
from dataclasses import dataclass
from io import StringIO
from itertools import chain, takewhile
import sys
@gottadiveintopython
gottadiveintopython / manual_test_recyclegridlayout.py
Last active May 31, 2020 03:33
manually tests RecycleGridLayout
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.factory import Factory
from kivy.app import runTouchApp
from kivy.uix.recyclegridlayout import RecycleGridLayout
internal_attr_names = (
'_has_hint_bound_x',
'_has_hint_bound_y',
from kivy.app import App
from kivy.lang import Builder
from kivy.factory import Factory
KV = '''
#:import A kivy.animation.Animation
<AutoScaleLabel@Label>:
scale: 1
@gottadiveintopython
gottadiveintopython / mdfastfilechooser.py
Last active October 23, 2019 05:48
Fast FileChooser (KivyMD)
import typing
from pathlib import Path
from dataclasses import dataclass
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.factory import Factory
from kivy.properties import ObjectProperty, BooleanProperty
try:
from kivymd.uix.dialog import MDDialog
@gottadiveintopython
gottadiveintopython / fastfilechooser.py
Last active October 20, 2019 14:56
simple and fast FileChooser
import typing
from pathlib import Path
from dataclasses import dataclass
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.factory import Factory
from kivy.properties import ObjectProperty, BooleanProperty
@dataclass
@gottadiveintopython
gottadiveintopython / Animation._instances keeps getting fat.py
Created September 29, 2019 11:46
"Animation._instances" keeps getting fat
'''
https://youtu.be/P2WtjZAWc8I
'''
from kivy.app import App
from kivy.factory import Factory
from kivy.animation import Animation
from kivy.clock import Clock
import itertools
anim_id_iter = itertools.count()
@gottadiveintopython
gottadiveintopython / main.py
Last active September 28, 2019 09:03
(Kivy) magnet + drag_n_drop = awesome
'''
https://youtu.be/fP0Pxy_3cSI
'''
from kivy.app import runTouchApp
from kivy.lang import Builder
from kivy.uix.label import Label
import rich_drag_n_drop
KV_CODE = '''
@gottadiveintopython
gottadiveintopython / inverse_numpy_bincount.py
Created September 16, 2019 12:16
inverse numpy's bincount()
import numpy as np
import itertools
from timeit import timeit
arr = np.random.randint(3, size=100, dtype='uint8')
def method_me(arr):
return np.array(
tuple(itertools.chain.from_iterable(
itertools.repeat(index, value)
@gottadiveintopython
gottadiveintopython / example1.py
Last active July 29, 2019 00:44
listing the children that will be added by Builder
__all__ = ('get_tree_from_widget', 'get_tree_from_root_rule', 'get_tree_from_cls', )
from kivy.lang import Parser, Builder, BuilderBase
from kivy.factory import Factory
def _get_children(rule):
return [{crule.name: _get_children(crule)} for crule in rule.children]