Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
physics = systems['cymunk-physics']
asteroid_system = systems['asteroids']
physics.add_collision_handler(
1, 1, separate_func=asteroid_system.asteroids_collide)
def set_state(self):
self.gameworld.state = 'main'
def setup_map(self):
self.gameworld.currentmap = self.gameworld.systems['map']
def set_pause(self):
self.gameworld.state = 'pause'
class BasicApp(App):
def build(self):
pass
if __name__ == '__main__':
BasicApp().run()
if super(MDSlider, self).on_touch_down(touch):
self.active = True
def on_touch_up(self, touch):
if super(MDSlider, self).on_touch_up(touch):
self.active = False
# thumb = self.ids['thumb']
# if thumb.collide_point(*touch.pos):
# thumb.on_touch_down(touch)
# thumb.on_touch_up(touch)
if __name__ == '__main__':
from kivy.app import App
from kivymd.theming import ThemeManager
class SliderApp(App):
theme_cls = ThemeManager()
def build(self):
return Builder.load_string("""
BoxLayout:
orientation:'vertical'
BoxLayout:
size_hint_y:None
height: '48dp'
Label:
text:"Toggle disabled"
color: [0,0,0,1]
CheckBox:
on_press: slider.disabled = not slider.disabled
BoxLayout:
size_hint_y:None
def check_connection_settings():
"""Checks QuESt settings and returns configuration for connection settings """
app_config = App.get_running_app().config
proxy_settings = {}
# Proxy settings.
if int(app_config.get('connectivity', 'use_proxy')):
http_proxy = app_config.get('connectivity', 'http_proxy')
https_proxy = app_config.get('connectivity', 'https_proxy')
if http_proxy:
proxy_settings['http'] = http_proxy
if https_proxy:
proxy_settings['https'] = https_proxy
# SSL verification.
ssl_verify = True if int(app_config.get('connectivity', 'use_ssl_verify')) else False
return ssl_verify, proxy_settings
def _update_shadow(self, *args):
if self.elevation > 0:
ratio = self.width / (self.height if self.height != 0 else 1)
if ratio > -2 and ratio < 2:
self._shadow = App.get_running_app().theme_cls.quad_shadow
width = soft_width = self.width * 1.9
height = soft_height = self.height * 1.9
elif ratio <= -2:
self._shadow = App.get_running_app().theme_cls.rec_st_shadow
ratio = abs(ratio)
if ratio > 5:
ratio = ratio * 22
else:
ratio = ratio * 11.5
width = soft_width = self.width * 1.9
height = self.height + dp(ratio)
soft_height = self.height + dp(ratio) + dp(self.elevation) * .5
else:
self._shadow = App.get_running_app().theme_cls.quad_shadow
width = soft_width = self.width * 1.8
height = soft_height = self.height * 1.8
# self._shadow = App.get_running_app().theme_cls.rec_shadow
# ratio = abs(ratio)
# if ratio > 5:
from core.plugin_mgr import PluginManager
from core.widget_mgr import WidgetManager
from core.display_mgr import DisplayManager
from core.data_mgr import Data
from core.hotkey import Hotkey
from kivy.app import App
from kivy.properties import ObjectProperty,DictProperty
from threading import Thread
from test.debug import *
class MainWindow(App):
title='DeepDIY'
data=ObjectProperty(lambda: None,force_dispatch=True)
plugins=DictProperty()
def __init__(self,**kwargs):
super(MainWindow, self).__init__(**kwargs)
def load_plugins(self):
self.plugin_manager=PluginManager()
self.plugin_manager.load_plugins()
self.display_manager=DisplayManager()
self.data=Data()
debug()
def build(self):
# self.hotkey=Hotkey()
Rectangle:
size: self.size
Label:
size_hint: 1, 1
text_size: self.size
shorten: shorten.state == 'down'
max_lines: max_lines.value
valign: 'middle'
halign: 'center'
color: (1, 1, 1, 1)
font_size: 22
text: 'Michaelangelo Smith'
'''
class ShortenText(App):
def build(self):
return Builder.load_string(kv)
ShortenText().run()
def load_landing_page(self):
"""
Returns to the landing page.
"""
controller = App.get_running_app().root
screen_manager = controller.screen_manager
screen_manager.transition.direction = 'right'
screen_manager.current = 'roll_screen'
index = images.index(os.path.abspath(filename))
except ValueError:
pass
Window.remove_widget(self)
cw = MyCustomImageWidget(directory)
Window.add_widget(cw)
self.superparent.customwidget = cw # needed for the Window keybindings
self.superparent.topwidget = cw # now MyCustomImageWidget is on top
if len(self.images) >= 1:
cw.bg.source=self.images[0]
class MyImageApp(App):
def build(self):
self.index = 0
self.popup = Popup(title='Usage:', content=Label(
text='Press "f" on the keyboard to find a directory with images\n' + \
'Press "r" to rotate an image\n' + \
'Press the left and right arrows on keyboard to cycle images'),auto_dismiss=True)
self.popup.open()
Clock.schedule_once(self.popup.dismiss, 5)
Window.bind(on_key_down=self._on_keyboard_down)
self.topwidget = TopBuildWidget()
return self.topwidget
def _on_keyboard_down(self, keyboard, x, keycode, text, modifiers):
def instantiate(self):
if self.is_valid == False:
return
self.instance=self._class()
app=App.get_running_app()
if hasattr(self.instance,'data') and self.type == 'processing':
'''use and sync app's data property'''
self.instance.data=app.data
app.bind(data=self.instance.setter('data'))
self.instance.bind(data=app.setter('data'))
'[b][color=2980b9]{}:[/color][/b] {}\n'.format(nickname, esc_markup(msg))
)
Clipboard.copy(msg)
def connection_lost(self, exc):
print('The server closed the connection')
self.transport.close()
class RootWidget(ScreenManager):
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
class ChatApp(App):
def build(self):
self.base_folder =os.path.dirname(os.path.abspath('.'))
self.setting_file = os.path.join(self.base_folder, 'chat_setting.json')
self.read_config()
return RootWidget()
def read_config(self):
try:
with open(self.setting_file, 'r') as f:
text = f.read()
self.setting_dict = json.loads(text)
self.host = self.setting_dict['host']
self.nick = self.setting_dict['nick']
except: