Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
halign: 'center'
Widget:
size_hint_y: None
height: 1000
on_touch_down: print 'touched at', args[-1].pos
:
title: 'Error'
size_hint: 0.75, 0.75
Label:
text: root.error_text
'''
class ErrorPopup(Popup):
error_text = StringProperty('')
def raise_error(error):
print('ERROR:', error)
ErrorPopup(error_text=error).open()
class TestApp(App):
def build(self):
root = Builder.load_string(kv)
Clock.schedule_interval(self.print_something, 2)
# Clock.schedule_interval(self.test_pyjnius, 5)
print('testing metrics')
from kivy.metrics import Metrics
print('dpi is', Metrics.dpi)
print('density is', Metrics.density)
print('fontscale is', Metrics.fontscale)
return root
def on_touch_down(self, touch):
"""
To understand the image movement, to left or to right;
previous position must be kept and keep updating.
"""
super(MyScatterLayout, self).on_touch_down(touch)
self.pre_posx = touch.pos[0]
self.grab_posx = self.pos[0]
class Pomodoro(BoxLayout):
time_period = NumericProperty()
rotation = NumericProperty(0)
sprint_count = NumericProperty(0)
time_display = StringProperty()
time_minute = StringProperty()
time_second = StringProperty()
state = StringProperty()
start = StringProperty()
stop = StringProperty()
logs = ListProperty([])
server_url = StringProperty()
#"http://172.18.140.79:8000/api/v1.0/put/pomodoro"
server_user = StringProperty("barbaros")
server_send = BooleanProperty(False)
count_start = BooleanProperty(False)
connect_server = BooleanProperty(False)
def __init__(self, **kwargs):
self.transition = NoTransition()
super(Main, self).__init__()
if str(platform) == 'linux':
app.config.set('accessibility', 'tts', 0)
class MainApp(App):
pixel = 'assets/img/pixel.png'
use_kivy_settings = False
backgrounds = ListProperty()
current_background = StringProperty()
current_search = StringProperty()
selected_id = NumericProperty()
folder = StringProperty()
data_folder = StringProperty()
notifications_queue = []
def on_selected_id(self, *args):
"""Used to store the currently viewed/chosen aphorism id"""
id = int(self.selected_id)
if id > 0:
actions = app.root.ids.FormList.ids.form_list_actions
actions.clear_widgets()
actions.add_widget(FormListActions())
def __init__(self):
self.title = 'Pocket Philosopher'
self.icon = 'assets/img/icon.png'
self.folder = os.path.dirname(os.path.abspath(__file__))
# make sure android uses the /sdcard folder instead of data/
if platform == 'android':
import global_variables
class FrontPage(Screen, MakesmithInitFuncs):
textconsole = ObjectProperty(None)
connectmenu = ObjectProperty(None) #make ConnectMenu object accessible at this scope
gcodecanvas = ObjectProperty(None)
screenControls = ObjectProperty(None)
connectionStatus = StringProperty("Not Connected")
xReadoutPos = StringProperty("0 mm")
yReadoutPos = StringProperty("0 mm")
zReadoutPos = StringProperty("0 mm")
ReadoutVel = StringProperty(" 0 mm/m")
gcodeVel = StringProperty(" 0 mm/m")
percentComplete = StringProperty("0.0%")
numericalPosX = 0.0
numericalPosY = 0.0
previousPosX = 0.0
previousPosY = 0.0
lastpos=(0,0,0)
lasttime=0.0
tick=0
stepsizeval = 0
consoleText = StringProperty(" ")
units = StringProperty("MM")
Builder.load_string('''
:
auto_dismiss: True
size_hint: None, None
size: 400, 200
on_open: root.dismiss_trigger()
title: root.title
Label:
text: root.text
''')
class InformationPopup(Popup):
title = StringProperty('Information')
text = StringProperty('')
def __init__(self, time=1.5, **kwargs):
super(InformationPopup, self).__init__(**kwargs)
self.dismiss_trigger = Clock.create_trigger(self.dismiss, time)
Factory.register('InformationPopup', cls=InformationPopup)
text: '1, 1, 1, 1'
state: 'down'
on_release: win.shape_color_key = [1, 1, 1, 1]
ToggleButton:
group: 'colorkey'
text: '0, 0, 0, 1'
on_release: win.shape_color_key = [0, 0, 0, 1]
''')
class Root(BoxLayout):
pass
class ShapedWindow(App):
shape_image = StringProperty('', force_dispatch=True)
def on_shape_image(self, instance, value):
if 'kivy-icon' in value:
Window.size = (512, 512)
Window.shape_image = self.alpha_shape
else:
Window.size = (800, 600)
Window.shape_image = self.default_shape
def build(self):
self.default_shape = default_shape
self.alpha_shape = alpha_shape
return Root()
# when the label changes size or position
if self.state == "down":
self.tab_bar.update_indicator(self.x, self.width)
class MDTabsBase(Widget):
"""
MDTabsBase allow you to create a tab.
You must create a new class that inherits from MDTabsBase.
In this way you have total control over the views of your tabbed panel.
"""
text = StringProperty()
"""It will be the label text of the tab."""
icon = StringProperty()
"""It will be the icon of the tab."""
tab_label = ObjectProperty()
"""It is the label object reference of the tab."""
def __init__(self, **kwargs):
self.tab_label = MDTabsLabel(tab=self)
super().__init__(**kwargs)
def on_text(self, widget, text):
# Set the icon
if text in md_icons:
self.tab_label.font_name = fonts_path + "materialdesignicons-webfont.ttf"
self.tab_label.text = md_icons[self.text]
self.tab_label.font_size = "24sp"
# Set the label text
class ObjectRenderer(Widget):
scene = StringProperty('')
obj_id = StringProperty('')
obj_translation = ListProperty([0, 0, 0])
obj_rotation = ListProperty([0, 0, 0])
obj_scale = NumericProperty(1)
obj_texture = StringProperty('')
texture = ObjectProperty(None, allownone=True)
cam_translation = ListProperty([0, 0, 0])
cam_rotation = ListProperty([0, 0, 0])
display_all = BooleanProperty(False)
light_sources = DictProperty()
ambiant = NumericProperty(.5)
diffuse = NumericProperty(.5)
specular = NumericProperty(.5)
mode = StringProperty('triangles')
def __init__(self, **kwargs):
self.canvas = Canvas()
with self.canvas:
self.fbo = Fbo(size=self.size,
with_depthbuffer=True,
compute_normal_mat=True,
clear_color=(0., 0., 0., 0.))
self.viewport = Rectangle(size=self.size, pos=self.pos)
self.fbo.shader.source = resource_find(
join(dirname(__file__), 'simple.glsl'))
super(ObjectRenderer, self).__init__(**kwargs)
def on_obj_rotation(self, *args):
def checkCurrent(self, current):
"""Sets the 'current' property to True if the current player is the
same as the instance reference.
"""
self.current = self.ref == current
def on_press(self, *args):
"""Tells the main screen that we want to control the selected
player.
"""
self.basescreen.changePlayer(self.ref)
class SqueezePlaylistItem(ButtonBehavior, BoxLayout):
"""Class object for displaying playlist items."""
artwork = StringProperty("images/10x10_transparent.png")
artist = StringProperty("Loding playlist")
trackname = StringProperty("Loding playlist")
posnum = StringProperty("")
current = BooleanProperty(False)
def __init__(self, **kwargs):
super(SqueezePlaylistItem, self).__init__(**kwargs)
# Create references to underlying objects
self.player = kwargs["player"]
self.np = kwargs["np"]
# Set the display properties
try:
self.artwork = kwargs["track"]["art"]
self.artist = kwargs["track"]["artist"]
self.trackname = kwargs["track"]["title"]