Created
December 5, 2012 16:20
-
-
Save DaniZz/4217078 to your computer and use it in GitHub Desktop.
this doesn't work
This file contains 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.app import App | |
from kivy.uix.widget import Widget | |
from kivy.uix.label import Label | |
from kivy.graphics import Color, Ellipse, Line | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.core.window import Window | |
from kivy.interactive import InteractiveLauncher | |
framePoints = [150, 250, 750, 250, 750, 600, 150, 600, 150, 250] | |
CIRCLEPOSITIONS = ([200,300],[350,300],[500,300],[650,300],[200,400],[350,400],[500,400],[650,400],[200,500],[350,500],[500,500],[650,500]) | |
CIRCLESIZE = 80 | |
RED = (0.3,0.3,0.3) | |
BLUE = (.6, .8, .6) | |
WHITE = (1,1,1) | |
class Circles: | |
def __init__(self, posx, posy, color): | |
self.x = posx | |
self.y = posy | |
self.col = color | |
class Configuration: | |
def __init__(self, nred = 6, nblue = 6): | |
self.nred = nred | |
self.nblue = nblue | |
self.circles = [] | |
self.setupConf() | |
def setupConf(self): | |
circlePosz = list(CIRCLEPOSITIONS) | |
for i in range(0,self.nred): | |
coord = circlePosz.pop(0) | |
self.circles.append(Circles(coord[0],coord[1],RED)) | |
for i in range(0,self.nblue): | |
coord = circlePosz.pop(0) | |
self.circles.append(Circles(coord[0],coord[1],BLUE)) | |
class DisplayWidget(Widget): | |
def __init__(self, frame, circles, **kwargs): | |
super(DisplayWidget, self).__init__(**kwargs) | |
# Window.clearcolor = (0.1, 0.1, 0.1, 1.) | |
with self.canvas: | |
Color(*WHITE) | |
Line(points=frame, width=2.5) | |
for circle in setup.circles: | |
Color(*circle.col) | |
d = CIRCLESIZE | |
Ellipse(pos=(circle.x , circle.y), size=(d, d)) | |
## here works | |
#setup = Configuration(4,8) | |
class TiktokApp(App): | |
def build(self): | |
## here it makes it crash | |
setup = Configuration(4,8) | |
layout = BoxLayout(orientation='vertical') | |
display = DisplayWidget(framePoints, setup.circles) | |
text = Label(text='Les circles sont TICK rouge') | |
layout.add_widget(display) | |
layout.add_widget(text) | |
return layout | |
def build_config(self, config): | |
config.setdefaults('graphics', { | |
'width': '1280', | |
'height': '1024' | |
}) | |
if __name__ == '__main__': | |
TiktokApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment