def on_touch_up(self, touch): if self.moving: Window.set_system_cursor('arrow') self.moving = False return False
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.core.window import Window from kivy.graphics import Color, Line, Ellipse, Rectangle Window.set_system_cursor('crosshair') class MousePosDemo(BoxLayout): def __init__(self, **kwargs): super(MousePosDemo, self).__init__(**kwargs) Window.bind(mouse_pos=self.mouse_pos) # Window.bind(on_motion=self.on_motion) self.bind(pos=self.draw) self.bind(size=self.draw) self.layout1 = BoxLayout(opacity=1) self.label = Label() self.add_widget(self.layout1) self.add_widget(self.label) def draw(self, *args): self.layout1.canvas.clear() with self.canvas.before: Color(0.6, 0.6, 0.6, 1) self.bg = Rectangle(pos=self.pos, size=self.size) def mouse_pos(self, window, pos):
def mouse_enter_css(self, *args): Window.set_system_cursor('hand') self.background_normal = 'res/btn_2.png'
from kivy.base import runTouchApp from kivy.lang import Builder from kivy.uix.label import Label from kivy.uix.widget import Widget from kivy.clock import Clock from kivy.core.window import Window import math Window.size = (640, 480) Window.set_title('My Space Game') Window.set_system_cursor(cursor_name='crosshair') Builder.load_string(''' <Root>: Earth: pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2 size: self.size Moon: pos: root.width / 2 - self.width / 2, root.height / 2 - self.height / 2 size: root.width / 16, root.width / 16 <Earth> canvas: Color: rgba: 1, 1, 1, 1 Ellipse: # Earth size: self.size pos: self.pos source: 'pexels-pixabay-87651-earth.png'
def on_leave(self): Window.set_system_cursor("arrow")
def mouse_leave_css(self, *args): # Reset background and mouse style self.background_normal = 'res/btn_1.png' Window.set_system_cursor('arrow')
def change_cursor(self, dt): pos = self.to_widget(*Window.mouse_pos) if self.box.collide_point(*pos): Window.set_system_cursor('size_all') else: Window.set_system_cursor('arrow')
def on_enter(self): Window.set_system_cursor("hand")
def on_touch_up(self, touch): self._allow_resize = False Window.set_system_cursor("arrow") return super().on_touch_up(touch)
def unschedule_cursor_change(self, *args, **kwargs): Clock.unschedule(self.cursor_change_event) Window.set_system_cursor('arrow')
from kivy.app import App from kivy.uix.widget import Widget from kivy.core.window import Window from kivy.properties import StringProperty from functools import partial import kivy.uix.button as kb import numpy as np from patterns import patterns from hopfield import Train, Correct Window.clearcolor = (.6, .6, .6, 1) Window.set_system_cursor('hand') class Grid(Widget): def __init__(self, **kwargs): super(Grid, self).__init__(**kwargs) self.weights = Train(patterns) self.Clear() self.InitNumbersGrid() def InitNumbersGrid(self): grid = self.children[0].children[1] for i in range(self.matrix.shape[0] * self.matrix.shape[1]): btn = kb.Button(background_normal='', background_color='white') btn.bind(on_press=partial(self.ButtonClicked, i)) grid.add_widget(btn) def AdjustGrid(self): buttons = self.children[0].children[1].children matrixFlatten = self.matrix.flatten()
def query(self): self.server_name = self.ids.txt_server1.text Window.set_system_cursor("arrow") App.get_running_app().root.ids.scr.current = "scrquery"
def on_enter(self, *args): Window.set_system_cursor("ibeam")
def on_leave(self, *args): Window.set_system_cursor("arrow") self.background_color = 0, 0, 0, 0
def on_enter(self, *args): Window.set_system_cursor("hand") self.background_color = 1, 1, 1, 1