This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| KivyのLabelはpaddingを設定するとその分だけtextureを大きくしてしまうのでそれへの対策。 | |
| ''' | |
| __all__ = ("EcoLabel", ) | |
| from kivy.properties import NumericProperty, ReferenceListProperty, OptionProperty | |
| from kivy.lang import Builder | |
| from kivy.clock import Clock | |
| from kivy.uix.label import Label |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| A very naive implementation of reactive values and computed values, inspired by | |
| https://github.com/tc39/proposal-signals | |
| https://github.com/buiapp/reaktiv | |
| Most of the features described in the proposal are NOT implemented. | |
| .. code-block:: | |
| from signal import State, computed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from kivy.graphics.texture import Texture | |
| from kivy.core.text import Label as CoreLabel | |
| from kivy.core.text.markup import MarkupLabel as CoreMarkupLabel | |
| def create_texture_from_text(*, markup=False, **label_kwargs) -> Texture: | |
| ''' | |
| .. code-block:: | |
| from kivy.metrics import sp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # CPython3.8.12 上で測ったところclass-basedの方が17倍近く速かった | |
| from functools import partial | |
| from contextlib import contextmanager | |
| from timeit import timeit | |
| class class_based: | |
| __slots__ = tuple() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| CPython 3.8.12 | |
| pip install kivy[base]==2.1.0 | |
| pip install "asynckivy>=0.5,<0.6" | |
| pip install git+https://github.com/gottadiveintopython/kivyx.uix.magnet#egg=kivyx.uix.magnet | |
| ''' | |
| from kivy.config import Config | |
| Config.set('graphics', 'width', 1280) | |
| Config.set('graphics', 'height', 720) | |
| # Config.set('graphics', 'maxfps', 30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from kivy.clock import Clock | |
| from kivy.app import App | |
| from kivy.animation import Animation | |
| from kivy.uix.widget import Widget | |
| from kivy.uix.floatlayout import FloatLayout | |
| from kivy.lang import Builder | |
| from kivy.core.window import Window | |
| from kivy.graphics import RenderContext | |
| from kivy.uix.modalview import ModalView | |
| from kivy.properties import ListProperty, NumericProperty, ObjectProperty, ColorProperty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $HEADER$ | |
| float PI = 3.1415926535; | |
| uniform vec2 resolution; | |
| uniform float time; | |
| vec2 rotate(vec2 pos, float angle, vec2 center){ | |
| pos -= center; | |
| pos *= mat2(cos(angle), sin(-angle), sin(angle), cos(angle)); | |
| pos += center; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqlite3 | |
| from kivy.app import App | |
| from kivy.lang import Builder | |
| def init_db(): | |
| import itertools | |
| from string import ascii_uppercase | |
| conn = sqlite3.connect(":memory:") | |
| cur = conn.cursor() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from array import array | |
| from kivy.uix.widget import Widget | |
| from kivy.clock import Clock | |
| from kivy import properties as P | |
| from kivy.graphics import ( | |
| RenderContext, BindTexture, Rectangle, Color | |
| ) | |
| from kivy.graphics.texture import Texture | |
| from kivy.core.window import Window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| from string import Template | |
| from collections import defaultdict | |
| from kivy.config import Config | |
| Config.set('graphics', 'width', 400) | |
| Config.set('graphics', 'height', 800) | |
| from kivy.uix.boxlayout import BoxLayout | |
| from kivy.lang import Builder | |
| from kivy.utils import escape_markup | |
| from kivy.clock import Clock |
NewerOlder