Skip to content

Instantly share code, notes, and snippets.

View Dirk-Sandberg's full-sized avatar

Erik Sandberg Dirk-Sandberg

  • 3M
  • Minneapolis
View GitHub Profile
@Dirk-Sandberg
Dirk-Sandberg / AdMob banner class for Kivy-ios
Last active March 6, 2023 12:34
Snippet to add to main.m in kivy-ios project
UIView *gView;
UIViewController *gViewColtroller;
@interface myBanner : NSObject <GADBannerViewDelegate>
@property (nonatomic) BOOL show_ads;
@property (strong, nonatomic) GADBannerView *gbanner;
@property (strong, nonatomic) GADRequest *request;
@end
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Makes a widget bounce around the screen
kv = """
<AnimatedMenu@GridLayout>:
cols: 2
spacing: 10,
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Loads an image from the web, changes it's color and angle.
kv = """
<AnimatedImage@AsyncImage>:
color: (1,1,1,1) # Setting color for images works best on white images
color2: (1,0,0,1)
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Expands an element in a grid and adds a widget to it/
kv = """
<AnimatedListTile@FloatLayout>:
canvas.before:
Color:
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
from kivy.garden.mapview import MapView
print("A")
# Animate moving around on a map
kv = """
FloatLayout:
@Dirk-Sandberg
Dirk-Sandberg / remove_so_o_files.py
Created June 24, 2019 18:23
Fixes errors shown in this image (https://ibb.co/3y4T1rL) when uploading an App to AppStoreConnect. INSTRUCTIONS: Put this in your kivy-ios folder, then run `python remove_so_o_files.py` to delete all files ending with .so.o from your project. They are not needed and only cause errors with kivy-ios.
from os.path import join, dirname, realpath, exists, isdir, basename, dirname, abspath
from os import listdir, unlink, makedirs, environ, chdir, getcwd, walk, remove
def remove_junk(d):
exts = [".so.o"]
for root, dirnames, filenames in walk(d):
for fn in filenames:
if any([fn.endswith(ext) for ext in exts]):
print("Removing", join(root,fn))
unlink(join(root, fn))
@Dirk-Sandberg
Dirk-Sandberg / Example of kivy-ios push notifications
Last active May 31, 2022 12:23
Most basic example of code needed for push notifications with kivy-ios
# Files are below, this is just to change the name of the gist
@Dirk-Sandberg
Dirk-Sandberg / main.kv
Created December 20, 2019 18:55
How to use a native image chooser in iOS - not perfected, just proof of concept.
BoxLayout:
Button:
text: "hello"
on_release:
app.pick_image()
Button:
text: "update"
on_release:
app.update()
@Dirk-Sandberg
Dirk-Sandberg / main.m snippet
Created December 23, 2019 03:18
How to determine if the top notch exists on iOS with python/kivy/pyobjus
@interface NotchDetector : UIViewController
@end
@implementation NotchDetector
-(id)init {
NSLog(@"initializing NotchDetector");
return self;
}
- (BOOL)hasTopNotch {
if (@available(iOS 13.0, *)) {