コード例 #1
0
ファイル: floor.py プロジェクト: OkayMusic/SprongleApp
    def __init__(self, **kwargs):
        super(Floor, self).__init__(**kwargs)
        self.size_hint = None, None
        self._is_collidable = True
        self.root = App.get_running_app().root

        self.width = self.root.width
        self.height = 30

        with self.canvas:
            Color(0, 1., 0.01)
            GroundRec = Rectangle()
            GroundRec.pos = (0, 0)
            GroundRec.size = [self.width, self.height]
コード例 #2
0
ファイル: transform.py プロジェクト: 2xR/legacy
    def __get_dbg_aabb_gfx(self):
        if self.__dbg_aabb is None:
            c = Color(0.8, 0.8, 0.8, 0.3)
            r = Rectangle()
            group = InstructionGroup()
            for instruction in (c, r):
                group.add(instruction)

            def update_r(_, ((left, bottom), (right, top))):
                r.pos = (left, bottom)
                r.size = (right - left, top - bottom)

            self.bind(aabb=update_r)
            update_r(None, self.aabb)
            self.__dbg_aabb = group
コード例 #3
0
ファイル: transform.py プロジェクト: 2xR/legacy
    def __get_dbg_origin_gfx(self):
        if self.__dbg_origin is None:
            c1 = Color(1, 0, 0, 0.5)
            r1 = Rectangle()
            c2 = Color(0, 1, 0, 0.5)
            r2 = Rectangle()
            c3 = Color(0, 0, 1, 0.5)
            e = Ellipse()
            group = InstructionGroup()
            for instruction in (c1, r1, c2, r2, c3, e):
                group.add(instruction)

            def update_geom(_, (w, h)):
                r1.size = (w, 0.1 * h)
                r2.size = (0.1 * w, h)
                e.size = (0.5 * w, 0.5 * h)
                e.pos = (0.25 * w, 0.25 * h)

            self.bind(viewport_size=update_geom)
            update_geom(None, self.size)
            self.__dbg_origin = group
コード例 #4
0
ファイル: grating.py プロジェクト: compmem/smile
    def _update(self, *pargs):
        '''Updates the drawling of the textures on screen

        The function mirror repeats the mask 3 times in the top left,
        top right and bottom left quadrant to increase
        efficiency. Also it repeats the sin wave, created in the
        _calc_color function to fill the rectangle with the sin wave
        based grating.

        '''
        # clear (or else we get gratings all over)
        self.canvas.clear()

        # set up the blending
        with self.canvas.before:
            Callback(self._set_blend_func)

        # Draw the two textures in rectangles
        with self.canvas:
            # draw the mask
            mask = Rectangle(size=self.size, pos=self.pos,
                             texture=self._mask_texture)

            # repeats 4 times to fill the created texture rectangle
            mask.tex_coords = 0, 0, 2, 0, 2, 2, 0, 2

            # draw the grating
            grating = Rectangle(size=self.size, pos=self.pos,
                                texture=self._texture)

            # repeats the grating to fill the texture rectangle
            grating.tex_coords = (0, 0, self.width / self._period,
                                  0, self.width / self._period,
                                  self.height, 0, self.height)

        # clean up the blending
        with self.canvas.after:
            Callback(self._reset_blend_func)
コード例 #5
0
	def draw_in(self, aMapViewer):
		'''implement the method to draw in the MapViewer
		'''
		radius = 150.0/aMapViewer.scale
		x = aMapViewer.cmin[0]
		y = aMapViewer.cmin[1]
		(display_width, display_height) = aMapViewer.parent.size
		
		for aPoi in self.pois:
			(poi_x,poi_y) = aMapViewer.get_local_xy_from_latlon(float(aPoi.poinulat), float(aPoi.poinulon), display_width, display_height)
			#with aMapViewer.canvas:
			#	Color(1, 0, 0, 0.8)
			#	Ellipse(pos=(x + poi_x/aMapViewer.scale - radius/2, y + poi_y/aMapViewer.scale - radius/2), size=(radius,radius))
			img_poi = Rectangle( pos=(x + poi_x/aMapViewer.scale - radius/2, y + poi_y/aMapViewer.scale ) )
			img_poi.source='images/location_%s.png' % self.categories[aPoi.poiidcat].catcdcode
			img_poi.size = (radius,radius)
			aMapViewer.canvas.add(img_poi)
		
		# draw the current position
		(curr_x, curr_y) = aMapViewer.get_local_xy_from_latlon(self.current_position[0], self.current_position[1], display_width, display_height)
		aMapViewer.canvas.add(Color(0, 1, 1, 0.8))
		aMapViewer.canvas.add(Ellipse(pos=(x + curr_x/aMapViewer.scale - radius/2, y + curr_y/aMapViewer.scale - radius/2), size=(radius/4,radius/4)) )
		
		return
コード例 #6
0
ファイル: BirdApp.py プロジェクト: JKangg/Flappy-Bird
    def __init__(self):
        super().__init__()

        self.birdy = Bird()
        self.add_widget(self.birdy)
        self.birdy.size_hint = (50 / Window.size[0], 50 / Window.size[1])
        self.birdy.pos_hint = {'x': 0.5, 'y': 0.5}
        self.birdy_windowpos = [
            self.birdy.pos_hint['x'] * Window.size[0],
            self.birdy.pos_hint['y'] * Window.size[1]
        ]

        self.resetbtn = ResetBtn()
        self.add_widget(self.resetbtn)
        self.resetbtn.size_hint = (0.15, 0.06)
        self.resetbtn.pos_hint = {'x': 0.8, 'y': 0.90}

        self.walls = []
        self.current_bottom_wall = None
        self.current_top_wall = None
        self.add_random_wall()

        self.score = 0
        self.score_label = CoreLabel(text="Score:" + str(self.score),
                                     font_size=30,
                                     color=(1, 0.7, 0, 0.8))
        self.score_label.refresh()
        with self.canvas:
            self.score_instruction = Rectangle(
                texture=self.score_label.texture,
                pos=(20, Window.size[1] - 50),
                size=self.score_label.texture.size)

        self.high_score = 0

        self.birdy_update = Clock.schedule_interval(self.birdy.update, 0.03)
        self.wall_update = Clock.schedule_interval(self.update, 0)
コード例 #7
0
    def __init__(self, **kwargs):
        # make sure we aren't overriding any important functionality
        #Window.size = (800 , 480)  #Sets window sixe to size of display
        #Window.fullscreen = True
        super(start, self).__init__(**kwargs)
        self.add_widget(
            AsyncImage(source="/home/pi/carbon.jpeg",
                       size_hint=(1.5, 1.5),
                       pos_hint={
                           'center_x': .5,
                           'center_y': .5
                       }))
        self.startbtn = Button(text="START",
                               background_color=(0, 1, 0, 1),
                               size_hint=(.3, .3),
                               pos_hint={
                                   'center_x': .5,
                                   'center_y': .7
                               })
        self.startbtn.bind(on_press=self.btn_pressedstart)
        self.add_widget(self.startbtn)

        self.quitbtn = Button(text="SAVE AND QUIT",
                              background_color=(1, 0, 0, 1),
                              size_hint=(.2, .2),
                              pos_hint={
                                  'center_x': .5,
                                  'center_y': .3
                              })
        self.quitbtn.bind(on_press=self.btn_pressedquit)
        self.add_widget(self.quitbtn)

        with self.canvas.before:
            Color(0, 0, 0, 0)  # green; colors range from 0-1 instead of 0-255
            self.rect = Rectangle(size=self.size, pos=self.pos)

        self.bind(size=self._update_rect, pos=self._update_rect)
コード例 #8
0
 def drawGrid(self, **kwargs):
     _gridSize = kwargs.get('_gridSize', GRIDSIZE)
     if (_gridSize):
         self._gridSize = _gridSize
     GRIDWIDTH = self.size[0]
     GRIDHEIGHT = self.size[1]
     offsetY = ((GRIDWIDTH - (GRIDHEIGHT -
                              (XMARGIN + YMARGIN))) / 2) - YMARGIN
     STEP = (GRIDHEIGHT - (XMARGIN + YMARGIN)) / _gridSize
     self.canvas.clear()
     with self.canvas:
         Color(0.1, 0.1, 0.1, mode='rgb')
         self.rect = Rectangle(pos=self.pos, size=self.size)
         Color(0.6, 0.6, 0.6, mode='rgb')
         for i in range(_gridSize):
             Line(points=[
                 XMARGIN + offsetY, YMARGIN + (i * STEP),
                 (GRIDHEIGHT - YMARGIN) + offsetY, XMARGIN + (i * STEP)
             ],
                  width=1)
             Line(points=[
                 XMARGIN + (i * STEP) + offsetY, YMARGIN,
                 YMARGIN + (i * STEP) + offsetY, GRIDHEIGHT - XMARGIN
             ],
                  width=1)
         if i == (_gridSize - 1):
             Line(points=[
                 XMARGIN + offsetY, YMARGIN + ((i + 1) * STEP),
                 (GRIDHEIGHT - YMARGIN) + offsetY,
                 XMARGIN + ((i + 1) * STEP)
             ],
                  width=1)
             Line(points=[
                 XMARGIN + ((i + 1) * STEP) + offsetY, YMARGIN,
                 YMARGIN + ((i + 1) * STEP) + offsetY, GRIDHEIGHT - XMARGIN
             ],
                  width=1)
コード例 #9
0
    def update_canvas(self, *args):
        ''' draw progress ring on the canvas of the widget '''
        diameter = min(self.size) * 1
        with self.canvas:
            # clear canvas
            self.canvas.clear()
            # draw background
            set_color(self.background)
            Rectangle(pos=self.pos, size=self.size)

            # draw the ring
            set_color(self.color_unoccupied)
            Ellipse(pos=self._center(diameter), size=(diameter, diameter))

            # only draw the occupied part when percentage is not 0
            if self.percentage > 0.001:
                set_color(self.color)
                Ellipse(pos=self._center(diameter),
                        size=(diameter, diameter),
                        angle_end=self.percentage * 360)

            set_color(self.background)
            d = diameter * 0.85
            Ellipse(pos=self._center(d), size=(d, d))

            # draw the smaller ring inside
            set_color(self.color_unoccupied)
            d = diameter * 0.8
            Ellipse(pos=self._center(d), size=(d, d))

            set_color(self.background)
            d -= 5
            Ellipse(pos=self._center(d), size=(d, d))

            # draw text in the middle
            set_color('#000000')
            draw_text(self.text, self._center(0), 40, y_offset=20)
コード例 #10
0
    def start(self):
        self.space = space = pymunk.Space()
        space.gravity = 0, -900
        space.sleep_time_threshold = 0.3
        space.steps = 0
        self.create_logo(self.logo_lines, space)
        with self.canvas:
            Rectangle(
                texture=self.logo_img.texture,
                pos=(0, 300 - self.logo_img.height),
                size=self.logo_img.size,
            )

        floor = pymunk.Segment(space.static_body, (-100, 0), (900, 62), 5)
        floor.friction = 1.0
        space.add(floor)
        with self.canvas:
            Color(0.2, 0.2, 0.2)
            floor.ky = Line(points=[-100, 0, 900, 62], width=5)

        # we use our own event scheduling to make sure a event happens exactly
        # after X amount of simulation steps
        self.events = []
        self.events.append((10, self.big_ball))
        for x in range(8):
            self.events.append((1 + 10 * x, self.small_ball))

        self.events.append((200, self.big_ball))
        self.events.append((350, self.boxfloor))
        self.box_y = 150
        for x in range(8):
            self.events.append((400 + x * 10, self.box))
        self.events.append((650, self.car))
        self.events.append((850, self.cannon))
        self.events.append((1200, self.reset))

        self.update_event = Clock.schedule_interval(self.update, 1.0 / 20.0)
コード例 #11
0
    def __init__(self,imageStr,*args,**kwargs):
        super(CropImage,self).__init__(**kwargs)
        #Optionally, user can specify 4 elements for args
        #args[0] is x_position of bottom left of portion to be cropped, as ratio of original image's x length
        #args[1] is y_position of bottom left of portion to be cropped, as ratio of original image's y length
        #args[2] is x_length of portion to be croped, as ratio of original image's x length
        #args[3] is y_length of portion to be croped, as ratio of original image's x length
        image=Image(source=imageStr)
        originalSize=image.texture_size
        if len(args)==0:
            subtexture=image.texture
            self.posx=0
            self.posy=0
            self.sizex=originalSize[0]
            self.sizey=originalSize[1]
        elif len(args)==4:
            orix=originalSize[0]
            oriy=originalSize[1]
            self.posx=round(orix*args[0])
            self.posy=round(oriy*args[1])
            self.sizex=round(orix*args[2])
            self.sizey=round(oriy*args[3])
            subtexture=image.texture.get_region(self.posx,self.posy,self.sizex,self.sizey)
        else:
            print('ERROR IN SIDE CROPIMAGE CLASS: args is not used properly!')

        node=Widget(pos=[self.posx,self.posy],size=[self.sizex,self.sizey])
        
        with node.canvas:
            self.rect_bg=Rectangle(size=node.size,texture=subtexture)
        self.add_widget(node)

        with self.canvas:
            self.size=node.size
            self.x=self.posx
            self.y=self.posy
            self.rect_bg.pos=[self.x,self.y]
コード例 #12
0
ファイル: messaging.py プロジェクト: firebitsbr/operator-1
    def send_message(self, user, event):
        """
		When the user hits the reply button, it sends the message back to the user (or group if it is
		a groupchat).

		:param str user: The username of whomever the user is chatting with.
		"""
        msg = self.reply.text

        if msg:
            if user == self.users['Operator Group']:
                self.main_app.send_muc(msg, user)
            else:
                self.main_app.send_message(msg, user)

            m = Message(None, msg)
            self.messages[user].append(m)

            lab = Label(text=msg,
                        size_hint_y=None,
                        color=(1, 1, 1, 1),
                        markup=True,
                        halign='right')
            lab.bind(width=lambda s, w: s.setter('text_size')(s, (w, None)))
            lab.bind(texture_size=lab.setter('size'))

            with lab.canvas.before:
                Color(.67, .82, 1, mode='hsv')
                lab.bg_rect = Rectangle(pos=self.pos, size=self.size)

            lab.bind(pos=self.redraw, size=self.redraw)
            self.sub_layout.add_widget(lab)
            self.reply.text = ""

            if self.new:
                self.sub_layout.remove_widget(self.new_lab)
                self.new = False
コード例 #13
0
 def build(self):
     self.layout = FloatLayout()
     self.inkc = inkc = StrokeCanvasFloat(size_hint=(1, .90))
     inkc.stroke_color = 'darkblue'
     inkc.stroke_width = 2.0
     inkc.stroke_visibility = True
     inkc.stroke_opacity = 0.8
     inkc.bind(size=self._update_rect, pos=self._update_rect)
     inkc.bind(on_stroke_added=self.stroke_collected)
     inkc.bind(on_stroke_removed=self.stroke_removed)
     inkc.bind(mode=self.mode_changed)
     btn_mode = Button(text='Draw Mode', size_hint=(1, .10),
                  pos_hint={'top': 1.0})
     btn_mode.bind(on_press=partial(self.callback, btn_mode))
     boxlayout = BoxLayout(orientation="horizontal", size_hint=(1, .10),
                         pos_hint={'bottom': 1.0})
     textinput = TextInput(text="")
     btn_train = Button(text='Train')
     btn_train.bind(on_press=partial(self.train_btn, textinput))
     btn_load = Button(text='Load')
     btn_load.bind(on_press=self.load_btn)
     btn_recognize = Button(text='Recognize')
     btn_recognize.bind(on_press=partial(self.recognize_btn, textinput))
     btn_clear = Button(text='Clear')
     btn_clear.bind(on_press=self.clear_btn)
     boxlayout.add_widget(textinput)
     boxlayout.add_widget(btn_train)
     boxlayout.add_widget(btn_load)
     boxlayout.add_widget(btn_recognize)
     boxlayout.add_widget(btn_clear)
     with inkc.canvas.before:
         Color(1.0, 1.0, 1.0, 1.0)
         self.rect = Rectangle(size=inkc.size, pos=inkc.pos)
     self.layout.add_widget(inkc)
     self.layout.add_widget(btn_mode)
     self.layout.add_widget(boxlayout)
     return self.layout
コード例 #14
0
    def __init__(self, domain, **kwargs):
        super().__init__(cols=2, **kwargs)
        self.problem = Problem(domain)
        self.domain = self.problem.domain
        self.model = CoactiveModel(self.domain)

        self._x = self.problem.context
        self._y = self.model.infer(self._x)
        self.phi = list(self.model.phi(self._x, self._y))

        n_cells = (self._x['SIDE'], ) * 2
        # TODO: move this somewhere else
        palette = {
            'Table 2x1': lambda pos: Object(pos, (2, 1), GridUI.TEX_TABLE_2_1),
            'Table 1x2': lambda pos: Object(pos, (1, 2), GridUI.TEX_TABLE_1_2),
            'Table 1x1': lambda pos: Object(pos, (1, 1), GridUI.TEX_TABLE_1_1)
        }

        self.grid_ui = GridUI(n_cells, palette)
        self.add_widget(self.grid_ui)
        self.grid_ui.update(self._x, self._y)

        self.side = GridLayout(cols=1, rows=2, size_hint=(.45, 1))
        with self.side.canvas.before:
            Color(.9, .9, .9)
            self.side_bg = Rectangle()
            self.side.bind(pos=self.track, size=self.track)
        self.add_widget(self.side)

        self.tree = FeatureTree(self.problem, size_hint=(.45, .8))
        self.side.add_widget(self.tree)
        self.tree.bind_sliders(self.on_slider_update)
        self.tree.set_sliders(self.phi)

        self.submit = Button(text='Submit', size_hint=(.2, .1))
        self.side.add_widget(self.submit)
        self.submit.bind(on_press=self.on_submit_press)
コード例 #15
0
    def __init__(self, **kwargs):
        super(InfoBar, self).__init__(**kwargs)
        print("[game] created " + str(self.__class__))

        with self.canvas:
            self.canvas.clear()

            Color(.1, .2, .7, .5)
            self.bg = Rectangle(pos=(0, 0), size=(self.size[0], self.size[1]))

            self.margin = self.size[0] / 7

            Color(1, 1, 1, 1)

            self.lbl1 = Label(text="Typ: ",
                              center=(1 * self.margin, self.size[1] / 2),
                              bold=True)

            self.lbl2 = Label(text="Hs. (immer): ",
                              center=(2 * self.margin, self.size[1] / 2),
                              bold=True)

            self.lbl3 = Label(text="Highscore: ",
                              center=(3 * self.margin, self.size[1] / 2),
                              bold=True)

            self.lbl4 = Label(text="Länge: ",
                              center=(4 * self.margin, self.size[1] / 2),
                              bold=True)

            self.lbl5 = Label(text="Runde/Generation: ",
                              center=(5 * self.margin, self.size[1] / 2),
                              bold=True)

            self.lbl6 = Label(text="Alive: ",
                              center=(6 * self.margin, self.size[1] / 2),
                              bold=True)
コード例 #16
0
ファイル: map.py プロジェクト: CodeWins/synoso
    def mapload(self, obj):
        global sand
        global img
        global png_file_path
        global npy_file_path
        png_file_path = ""
        npy_file_path = ""
        root = tkinter.Tk()
        root.withdraw()

        #open png file
        png_file_path = tkinter.filedialog.askopenfilename(
            title='Open PNG file',
            filetypes=(("PNG files", "*.png"), ("all files", "*.*")))
        if png_file_path == ():
            png_file_path = ""
        if os.path.isfile(png_file_path):
            parent.canvas.before.clear()
            parent.painter.canvas.clear()
            parent.painter.canvas.before.clear()
            with parent.canvas.before:
                Rectangle(source=png_file_path, size=Window.size)
            print("PNG file loaded: " + png_file_path)
        else:
            print("PNG File not found: " + png_file_path)

        #open npy file
        npy_file_path = tkinter.filedialog.askopenfilename(
            title='Open NPY file',
            filetypes=(("NPY files", "*.npy"), ("all files", "*.*")))
        if npy_file_path == ():
            npy_file_path = ""
        if os.path.isfile(npy_file_path):
            sand = np.load(npy_file_path)
            print("NPY file loaded: " + npy_file_path)
        else:
            print("NPY File not found: " + npy_file_path)
コード例 #17
0
ファイル: effectwidget.py プロジェクト: cchang888/kivy3dgui
    def refresh_fbo_setup(self, *args):
        # Add/remove fbos until there is one per effect
        while len(self.fbo_list) < len(self.effects):
            with self.canvas:
                new_fbo = EffectFbo(size=C_SIZE)
            with new_fbo:
                Color(1, 1, 1, 1)
                new_fbo.texture_rectangle = Rectangle(size=C_SIZE)

                new_fbo.texture_rectangle.size = C_SIZE
            self.fbo_list.append(new_fbo)
        while len(self.fbo_list) > len(self.effects):
            old_fbo = self.fbo_list.pop()
            self.canvas.remove(old_fbo)

        # Do resizing etc.
        self.fbo.size = C_SIZE
        self.fbo_rectangle.size = C_SIZE
        for i in range(len(self.fbo_list)):
            self.fbo_list[i].size = C_SIZE
            self.fbo_list[i].texture_rectangle.size = C_SIZE

        # If there are no effects, just draw our main fbo
        if len(self.fbo_list) == 0:
            self.texture = self.fbo.texture
            return

        for i in range(1, len(self.fbo_list)):
            fbo = self.fbo_list[i]
            fbo.texture_rectangle.texture = self.fbo_list[i - 1].texture

        for effect, fbo in zip(self.effects, self.fbo_list):
            fbo.set_fs(shader_header + shader_uniforms + effect +
                       shader_footer_effect)

        self.fbo_list[0].texture_rectangle.texture = self.fbo.texture
        self.texture = self.fbo_list[-1].texture
    def draw(self):

        with self.canvas:

            # Empty canvas instructions
            self.canvas.clear()

            # Draw no-progress circle
            Color(0.26, 0.26, 0.26)
            Ellipse(pos=self.pos, size=self.size)

            # Draw progress circle, small hack if there is no progress (angle_end = 0 results in full progress)
            Color(1, 0, 0)
            Ellipse(pos=self.pos,
                    size=self.size,
                    angle_end=(0.001 if self.value_normalized == 0 else
                               self.value_normalized * 360))

            # Draw the inner circle (colour should be equal to the background)
            Color(0, 0, 0)
            Ellipse(pos=(self.pos[0] + self.thickness / 2,
                         self.pos[1] + self.thickness / 2),
                    size=(self.size[0] - self.thickness,
                          self.size[1] - self.thickness))
            print('s', self.pos[0], self.thickness, self.pos[1],
                  self.thickness)
            # Center and draw the progress text
            Color(1, 0, 0)  # s 0 40 0 40

            # 200 73 200 48
            print('\n', self.size[0], self.texture_size[0], self.size[1],
                  self.texture_size[1])
            Rectangle(texture=self.label.texture,
                      size=self.texture_size,
                      pos=(self.size[0] / 2 - self.texture_size[0] / 2 +
                           self.pos[0], self.size[1] / 2 -
                           self.texture_size[1] / 2 + self.pos[1]))
コード例 #19
0
 def build(self):
     with self.canvas:
         Color(0.2, 0.2, 0.2)
         self.game_elements['background'] = Rectangle(pos=(0, 0))
         Color(1, 1, 1)
         self.game_elements['top_wall'] = Rectangle()
         self.game_elements['bottom_wall'] = Rectangle()
         self.game_elements['net'] = Rectangle()
         self.game_elements['ball'] = Rectangle(size=(10, 10))
         self.game_elements['left_paddle'] = Rectangle()
         self.game_elements['right_paddle'] = Rectangle()
         self.game_elements['left_score'] = Label(
             text='L',
             font_size='16pt',
             bold=True,
         )
         self.game_elements['right_score'] = Label(
             text='R',
             font_size='16pt',
             bold=True,
         )
     self.paint()
コード例 #20
0
ファイル: workoutbanner.py プロジェクト: HirushaR/ios-app-01-
    def __init__(self, **kwargs):
        self.rows =1
        super(WorkoutBanner, self).__init__()
        with self.canvas.before:
            Color(rgb=(kivy.utils.get_color_from_hex("#676970")))
            self.rect = Rectangle(size=self.size,pos=self.pos)
        self.bind(pos=self.update_rect,size=self.update_rect)

        # left float lay out
        left = FloatLayout()
        left_image = Image(source="icons/"+kwargs['workout_image'], size_hint=(1,0.8),pos_hint={"top":1,"right": 1})
        left_label = Label(text=kwargs['description'], size_hint=(1, .2), pos_hint={"top": .2, "right": 1})
        left.add_widget(left_image)
        left.add_widget(left_label)

        # middle float lay out
        middle = FloatLayout()
        middle_image = Image(source="icons/"+kwargs['type_image'], size_hint=(1, 0.8), pos_hint={"top": 1, "right": 1})
        middle_label = Label(text=str(kwargs['number'])+""+kwargs['units'], size_hint=(1, .2), pos_hint={"top": .2, "right": 1})
        middle.add_widget(middle_image)
        middle.add_widget(middle_label)

        # right float layouts
        right = FloatLayout()
        right_image = Image(source="icons/images.png" , size_hint=(1, 0.8),
                             pos_hint={"top": 1, "right": 1})
        right_label = Label(text=str(kwargs['likes']) + " likes", size_hint=(1, 0.2),
                             pos_hint={"top": .2, "right": 1})
        right.add_widget(right_image)
        right.add_widget(right_label)



        self.add_widget(left)
        self.add_widget(middle)
        self.add_widget(right)
コード例 #21
0
 def on_touch_down(self, touch):
     win = self.get_parent_window()
     self.timeline = App.get_running_app().calendar.dates.timeline
     self.pos_t0 = self.timeline.pos_of_time(self.timeline.get_time_0())
     self.pos_t1 = self.timeline.pos_of_time(self.timeline.get_time_1())
     self.time_t0 = self.timeline.get_time_0()
     self.time_t1 = self.timeline.get_time_1()
     self.time_interval = (self.time_t1 - self.time_t0).total_seconds()
     self.pos_interval = (self.pos_t1 - self.pos_t0)
     ud = touch.ud
     ud['group'] = g = str(touch.uid)
     ud['color'] = random()
     self.enable_selection(touch.y, touch.y)
     if self.enable == 1:
         with self.canvas:
             Color(0, 1, 0, .5, group=g)
             ud['lines'] = Rectangle(pos=(win.width * 0.07, touch.y),
                                     size=(win.width * 0.45, 1),
                                     group=g)
         self.y_start = touch.y
         touch.grab(self)
         return True
     else:
         return False
コード例 #22
0
ファイル: othello_beta.py プロジェクト: tsukasa19901012/myapp
 def update(self, *args):
     self.canvas.clear()
     self.canvas.add(Color(rgb=[0.281, 0.363, 0.246]))
     self.canvas.add(Rectangle(pos=self.pos, size=self.size))
     self.canvas.add(Color(rgb=[0, 0, 0]))
     self.canvas.add(
         Line(rectangle=[self.x, self.y, self.width, self.height], width=5))
     for i in range(1, 8):
         row = (self.height / 8 * i) + self.y
         rowLine = Line(points=[self.x, row, self.width + self.x, row],
                        width=3,
                        cap='none',
                        joint='none',
                        close=False)
         self.canvas.add(rowLine)
     for i in range(1, 8):
         col = (self.width / 8 * i) + self.x
         colLine = Line(points=[col, self.y, col, self.height + self.y],
                        width=3,
                        cap='none',
                        joint='none',
                        close=False)
         self.canvas.add(colLine)
     self.drawfield()
コード例 #23
0
    def __init__(self, *args, **kwargs):
        super().__init__()
        with self.canvas.before:
            Color(rgb=(kivy.utils.get_color_from_hex("#67697C")))
            self.rect = Rectangle(size=self.size, pos=self.pos)
        self.bind(pos=self.update_rect, size=self.update_rect)

        print("CHECKING BOOKING SLOTS FUNCTION CALL")

        picked = requests.get("https://nappyhour-6eb5d.firebaseio.com/" +
                              str(kwargs['shop_result']) + "/availability/" +
                              str(kwargs['date_result']) + ".json")
        #print(self.shopid)
        #print(self.date)
        print(str(kwargs['shop_result']))
        print(str(kwargs['date_result']))
        #print(str(kwargs['booking_result']))
        print("CHECKING BOOKING SLOTS")

        timeid = json.loads(picked.content.decode())
        if timeid[str(kwargs['booking_result'])]:
            # image = ImageButton(source="images/barber2.png", size_hint=(.3, 1), pos_hint={"top": 1, "right": .3})
            label = LabelButton(
                text=str(kwargs['booking_result']),
                size_hint=(.7, 1),
                pos_hint={
                    "top": 1,
                    "right": 1
                },
                on_release=partial(
                    App.get_running_app().load_confirmation_page,
                    kwargs['booking_result'], kwargs['date_result']))
            # self.add_widget(image)
            self.add_widget(label)

        print(timeid)
コード例 #24
0
    def __init__(self, data, color_mapping):
        super(GemDisplay, self).__init__()
        self.time = 0
        self.type = data[1]
        self.time_loc = data[0]
        self.color_data = color_mapping[self.type]
        self.color = Color(1, 1, 1)
        self.color.a = 1
        self.add(self.color)

        self.xpos = 110
        self.ypos = nowbar_height + (self.time_loc - self.time) * vel
        color = color_mapping[self.type]
        self.gem = Rectangle(texture=Image("pictures/" + color +
                                           "_gem.png").texture,
                             pos=(self.xpos, self.ypos),
                             size=(1 / 2 * Window.width - 20, 10))
        self.add(self.gem)

        self.vel = vel
        self.notes = []
        self.added = False
        self.removed = False
        self.a = 1
コード例 #25
0
    def __init__(self, screen, **kwargs):
        super(NumberTest, self).__init__(screen, **kwargs)
        self.desc = "Opakování číslic"
        self.instruction = "TENTO TEST ZPRACOVÁVÁ TESTUJÍCÍ!\nŘeknu Vám řadu číslic. Až skončím,\nopakujte je ve stejném pořadí, v jakém jste\nje slyšel/a."
        self.instruction_audio = "sounds/ins4-1.mp3"
        self.test_field = GridLayout(cols=1,
                                     pos_hint={
                                         "x": .1,
                                         "y": .3
                                     },
                                     size_hint=(.8, .25),
                                     row_default_height=70,
                                     row_force_default=True)
        self.normal_lb = Label(text="2 1 8 5 4", font_size="60px")
        self.normal_chb = CheckBox()
        self.reverse_lb = Label(text="7 4 2", font_size="60px")
        self.reverse_chb = CheckBox()

        self.normal_chb.bind(active=partial(self.checkbox_callback, self))
        self.reverse_chb.bind(active=partial(self.checkbox_callback, self))

        with self.canvas.before:
            Color(0, 0, 0, 1)
            self.rec = Rectangle(size=Window.size)
コード例 #26
0
    def __init__(self, screen, **kwargs):
        super(RememberTest, self).__init__(screen, **kwargs)
        self.instruction = "TENTO TEST ZPRACOVÁVÁ TESTUJÍCÍ! \nPřečtěte: Toto je test paměti. \nPřečtu Vám seznam slov, která si máte zapamatovat. \nPoslouchejte pozorně. Až skončím,\nsnažte si vybavit co nejvíce slov. \nNa pořadí nezáleží. -- \n DRUHÁ ČÁST\nPřečtěte: Přečtu Vám stejný seznam slov ještě jednou. \nSnažte si zapamatovat co nejvíce slov\n a poté mi je vyjmenujte, včetně těch, \nkterá jste jmenoval/a i poprvé. -- \n Na konci testu přečtěte: Na konci testu Vás požádám, \nabyste si tato slova znovu vybavil/a."
        self.instruction_audio = "sounds/ins3-1.mp3"
        self.test_field = GridLayout(rows=3,
                                     size_hint=(.9, .5),
                                     pos_hint={"y": .25},
                                     row_default_height=70,
                                     row_force_default=True)
        self.words = ["TVÁŘ", "SAMET", "KOSTEL", "KOPRETINA", "ČERVENÁ"]
        self.f_try = {}
        self.s_try = {}

        self.labels = []

        for word in self.words:
            label = Label(text=word)
            self.f_try[label] = CheckBox()
            self.s_try[label] = CheckBox()
            self.labels.append(label)

        with self.canvas.before:
            Color(0, 0, 0, 1)
            self.rec = Rectangle(size=Window.size)
コード例 #27
0
    def __init__(self,image, text1, text2, **kwargs):
        # make sure we aren't overriding any important functionality
        super(CustomLayout, self).__init__(**kwargs)

        self.image = image
        self.title = text1
        self.subtitle = text2

        # let's add a Widget to this layout
        self.add_widget(
            Button(
                size_hint=(1, 0.5),
                pos_hint={'top': 1},
                background_normal='',
                background_color=(1, .3, .4, .85),
                disabled=True))


        self.add_widget(AsyncImage(source=self.image,
                                   size_hint=(.3, .3),
                                   pos_hint={'center_x': .5, 'center_y': .8}))

        self.add_widget(Label(text=self.title,
                              size_hint=(.5, .5),
                              pos_hint={'center_x': .5, 'center_y': .6}))

        self.add_widget(Label(text=self.subtitle,
                              size_hint=(.5, .5),
                              pos_hint={'center_x': .5, 'center_y': .55}))

        with self.canvas.before:
            Color(1, 1, 1, 1)  # green; colors range from 0-1 instead of 0-255
            self.rect = Rectangle(size=self.size, pos=self.pos)


        self.bind(size=self._update_rect, pos=self._update_rect)
コード例 #28
0
 def clear_canvas(self, for_kivy):
     children = self.paint.canvas.children
     children.reverse()
     for col, child in enumerate(children):
         if type(child) == Color:
             break
     last_col = children[col]
     self.paint.canvas.clear()
     self.paint.canvas.add(
         Rectangle(pos=(0, 0), size=(Window.width, Window.height)))
     self.paint.canvas.add(last_col)
     self.btn_col = (uniform(0, 1), uniform(0, 1), uniform(0, 1), 1)
     self.clear_btn.background_color = self.btn_col
     self.save_btn_jpg.background_color = self.btn_col
     self.select_col_btn.background_color = self.btn_col
     self.erase_btn.background_color = self.btn_col
     self.pt_10.background_color = self.btn_col
     self.pt_20.background_color = self.btn_col
     self.pt_30.background_color = self.btn_col
     self.pt_40.background_color = self.btn_col
     self.pt_50.background_color = self.btn_col
     self.pt_60.background_color = self.btn_col
     self.rec_btn.background_color = self.btn_col
     self.cir_btn.background_color = self.btn_col
コード例 #29
0
    def drawWorkspace(self, *args):

        self.scatterObject.canvas.remove_group('workspace')
 
        with self.scatterObject.canvas:
            Color(.47, .47, .47)

            #create the bounding box
            height = float(self.data.config.get('Maslow Settings', 'bedHeight'))
            width  = float(self.data.config.get('Maslow Settings', 'bedWidth'))
            Line(points = ( -width/2 , -height/2 ,  width/2 , -height/2), group='workspace')
            Line(points = ( -width/2 ,  height/2 ,  width/2 ,  height/2), group='workspace')
            Line(points = ( -width/2 , -height/2 , -width/2 ,  height/2), group='workspace')
            Line(points = (  width/2 , -height/2 ,  width/2 ,  height/2), group='workspace')
            
            #create the axis lines
            Line(points = (-width/2,0,width/2,0), dash_offset = 5, group='workspace')
            Line(points = (0, -height/2,0,height/2), dash_offset = 5, group='workspace')
    
            texture = self.data.backgroundTexture
            if texture is not None:
                Rectangle(texture=texture, pos=(-width/2, -height/2), 
                          size=(width, height),
                          tex_coords=self.data.backgroundManualReg)
コード例 #30
0
    def __init__(self, **kwargs):
        self.win = kwargs.pop('win', None)
        super(Console, self).__init__(**kwargs)
        self.avoid_bring_to_top = False
        with self.canvas.before:
            self.gcolor = Color(1, 0, 0, .25)
            PushMatrix()
            self.gtransform = Transform(Matrix())
            self.grect = Rectangle(size=(0, 0))
            PopMatrix()
        Clock.schedule_interval(self.update_widget_graphics, 0)

        # instanciate all addons
        self._toolbar = {"left": [], "panels": [], "right": []}
        self._addons = []
        self._panel = None
        for addon in self.addons:
            instance = addon(self)
            self._addons.append(instance)
        self._init_toolbar()
        # select the first panel
        self._panel = self._toolbar["panels"][0]
        self._panel.state = "down"
        self._panel.cb_activate()
コード例 #31
0
ファイル: kivywaveform.py プロジェクト: syfenx/kivysequencer
    def on_touch_down(self, touch):
        with self.canvas:
            Color(1, 0, 0)
            d = 30.
            # SHOW WHERE MOUSE CLICK IS
            Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))

        self.w_width, self.w_height = self.width, self.height
        self.rect_size_x, self.rect_size_y = 150, 150

        amplitude = self.rect_size_y / 2
        points = []
        print("vals in sample list", len(t1_vals))
        for x in range(0, len(t1_vals)):
            waveform_height = 12.0
            zoom = 0.55  # 0.1 is taller peaks, 0.9 is squashed
            y = math.sin(t1_vals[x] * math.pi /
                         (zoom * 180)) * amplitude * waveform_height
            points.append(x + self.w_width)
            points.append(y + self.w_height)

        print(sum(points) / len(points))

        with self.canvas:
            # DRAW RECT
            Color(.3, .3, .3)
            b = Rectangle(pos=(self.w_width - self.rect_size_x / 2,
                               self.w_height - self.rect_size_y / 2),
                          size=(self.rect_size_x + self.w_width,
                                self.rect_size_y + self.w_height))
            #DRAW WAVEFORM
            c = get_color_from_hex("#AA8CC5")
            Color(*c)
            Line(points=points)

        print("vals in sample list", len(t1_vals))
コード例 #32
0
    def __init__(self, **kwargs):
        # Instead of using canvas, we will use a RenderContext,
        # and change the default shader used.
        self.canvas = RenderContext(use_parent_projection=True)

        # We create a framebuffer at the size of the window
        # FIXME: this should be created at the size of the widget
        with self.canvas:
            self.fbo = Fbo(size=Window.size, use_parent_projection=True)

        # Set the fbo background to black.
        with self.fbo:
            Color(0, 0, 0)
            Rectangle(size=Window.size)

        # call the constructor of parent
        # if they are any graphics object, they will be added on our new canvas
        super(ShaderWidget, self).__init__(**kwargs)

        # We'll update our glsl variables in a clock
        Clock.schedule_interval(self.update_glsl, 0)

        # Don't forget to set the texture property to the texture of framebuffer
        self.texture = self.fbo.texture
コード例 #33
0
    def __init__(self, **kwargs):
        # 父类构造方法
        super().__init__(**kwargs)

        # 设置背景颜色(可忽略)
        with self.canvas:
            # 背景颜色
            Color(1, 1, 1, 1)
            # 浮动布局矩形 = 矩形(位置=布局位置,大小=布局大小)
            self.rect = Rectangle(pos=self.pos, size=self.size)
            # 浮动布局绑定(位置=布局矩形位置,大小=设置背景尺寸)
            self.bind(pos=self.update_rect, size=self.update_rect)

        # 缩放布局
        scatter_layout = ScatterLayout()

        # 异步图片
        image = AsyncImage(source='http://sck.rjkflm.com/images/logo1.png')

        # 布局加组件(异步图片)
        scatter_layout.add_widget(image)

        # 布局加组件(缩放布局)
        self.add_widget(scatter_layout)
コード例 #34
0
ファイル: draggingblock.py プロジェクト: samlopes/Besourino
 def __init__(self, type, id, source_photo, **kwargs):
     super(DragBlock, self).__init__(**kwargs)
     self.selected = True
     self.left_block = None
     self.right_block = None
     self.id = id
     self.type = type
     self.command_list = [self.id]
     self.bind(pos=self.update)
     self.bind(size=self.update)
     self.bind()
     self.color = "[color="
     self.color += hex(randrange(20, 255, 10))[2:]
     self.color += hex(randrange(20, 255, 10))[2:]
     self.color += hex(randrange(20, 255, 10))[2:]
     self.color += "]"
     self.sign = Label(text=self.color + "#", markup=True)
     self.sign.font_size = str(self.size[0] * 0.65) + "sp"
     self.sign.texture_update()
     with self.canvas:
         self.rect = Rectangle(source=source_photo,
                               pos=self.pos,
                               size=self.size)
     self.add_widget(self.sign)
コード例 #35
0
ファイル: editor.py プロジェクト: reneklacan/kivybomber
    def update(self):
        self.to_space()

        if self.category == 'map':
            if self.item == SPAWNPOINT:
                texture = textures.player_up
            if self.item == SPACE:
                return
            elif self.item == BLOCK:
                texture = textures.block
            elif self.item == MAZE:
                texture = textures.maze
            elif self.item == VOID:
                self.canvas.clear()
                return
        elif self.category == 'monsters':
            texture = self.item.cls_texture

        self.rectangle = Rectangle(
            texture=texture,
            pos=(0, 0),
            size=self.size,
        )
        self.canvas.add(self.rectangle)
コード例 #36
0
ファイル: ns_widgets.py プロジェクト: tnason/NetSeq
    def __init__(self, title, body, options, **kwargs):
        """Construct NSPopup

        Arguments
        title: title of Popup
        body: text to comprise of Popup body
        options: dictionary of format {"option": callback, ...} -- options to
            be listed on buttons, and the function to call on option trigger

        """

        """Basic Widget constructor"""
        super(NSPopup, self).__init__(width=self.DEFAULT_WIDTH,
                                      height=self.DEFAULT_HEIGHT)

        """Store data"""
        self.options = options

        """Center popup relative to screen"""
        self.x = (Window.width - self.width) / 2
        self.y = (Window.height - self.height) / 2

        """Set formatting defaults"""
        self.size = [self.DEFAULT_WIDTH, self.DEFAULT_HEIGHT]

        """Selection is originally nothing"""
        self.selection = None

        """Layout constants"""
        num_buttons = len(options)
        BUTTON_MAX_WIDTH = 150
        PADDING = 10
        BUTTON_BALANCED_WIDTH = (self.width - (num_buttons + 1) * 
                                 PADDING) / num_buttons
        BUTTON_WIDTH = min(BUTTON_BALANCED_WIDTH, BUTTON_MAX_WIDTH)
        BUTTON_HEIGHT = 50
        BUTTON_PADDING = (self.width - (num_buttons * BUTTON_WIDTH)) /\
                         (num_buttons + 1)
        BUTTON_TEXT_SIZE = [BUTTON_WIDTH, BUTTON_HEIGHT]
        BUTTON_FONT_SIZE = 12
        BUTTON_Y = self.y + PADDING
    
        BACKGROUND_COLOR = Color(0.2, 0.2, 0.2)
        EDGE_COLOR = Color(0.6, 0.6, 0.6)
        EDGE_WIDTH = self.width
        EDGE_HEIGHT = self.height
        EDGE_SIZE = [EDGE_WIDTH, EDGE_HEIGHT]
        BORDER_SIZE = 5
        BACKGROUND_WIDTH = EDGE_WIDTH - BORDER_SIZE * 2
        BACKGROUND_HEIGHT = EDGE_HEIGHT - BORDER_SIZE * 2
        BACKGROUND_SIZE = [BACKGROUND_WIDTH, BACKGROUND_HEIGHT]

        TITLE_HEIGHT = 50
        TITLE_WIDTH = BACKGROUND_WIDTH - PADDING
        TITLE_FONT_SIZE = 18
        TITLE_PADDING_ABOVE = 50
        TITLE_TOP = self.top - BORDER_SIZE - TITLE_PADDING_ABOVE
        TITLE_TEXT_SIZE = [TITLE_WIDTH, TITLE_HEIGHT]

        BODY_HEIGHT = self.height - PADDING - BUTTON_HEIGHT - PADDING - \
                      PADDING - TITLE_HEIGHT - PADDING
        BODY_PADDING_SIDES = 30
        BODY_WIDTH = BACKGROUND_WIDTH - PADDING - BODY_PADDING_SIDES * 2
        BODY_TEXT_SIZE = [BODY_WIDTH, BODY_HEIGHT]
        BODY_FONT_SIZE = 14

        """Create background"""
        edge = Widget()
        edge.pos = self.pos
        edge.canvas = Canvas()
        edge.canvas.add(EDGE_COLOR)
        edge_rectangle = Rectangle(size=EDGE_SIZE)
        edge_rectangle.pos = edge.pos
        edge.canvas.add(edge_rectangle)
        self.add_widget(edge)

        background = Widget()
        background.x = edge.x + BORDER_SIZE
        background.y = edge.y + BORDER_SIZE
        background.canvas = Canvas()
        background.canvas.add(BACKGROUND_COLOR)
        background_rectangle = Rectangle(size=BACKGROUND_SIZE)
        background_rectangle.pos = background.pos
        background.canvas.add(background_rectangle)
        self.add_widget(background)

        """Make a button for each option"""
        option_button_x = self.x + BUTTON_PADDING
        for option in options.keys():
            option_button = Button(text=option, width=BUTTON_WIDTH,
                                   valign='middle', halign='center',
                                   height=BUTTON_HEIGHT,
                                   text_size=BUTTON_TEXT_SIZE,
                                   font_size=BUTTON_FONT_SIZE)
            option_button.x = option_button_x
            option_button.y = BUTTON_Y
            option_button.bind(on_release=self.select_option)
            self.add_widget(option_button)            

            """Increment x for the next button"""
            option_button_x += option_button.width + BUTTON_PADDING

        """Create title label"""
        title = Label(text=title, valign='middle', halign='center',
                      text_size=TITLE_TEXT_SIZE, font_size=TITLE_FONT_SIZE,
                      TITLE=TITLE_WIDTH, height=TITLE_HEIGHT)
        title.center_x = self.center_x
        title.top = TITLE_TOP
        self.add_widget(title)

        """Create main message label"""
        body = Label(text=body, valign='top', halign='center',
                      text_size=BODY_TEXT_SIZE, font_size=BODY_FONT_SIZE,
                      BODY=BODY_WIDTH, height=BODY_HEIGHT)
        body.center_x = self.center_x
        body.top = title.y - PADDING
        self.add_widget(body)
コード例 #37
0
ファイル: nonagents.py プロジェクト: oskanberg/kivy-juct
 def draw(self, canvas, offset_vector):
     updated_position = Vector(self._position) + offset_vector
     with canvas:
         r = Rectangle(pos=updated_position, size=self._size, texture=self.texture)
         r.tex_coords = [x * 32 for x in r.tex_coords]
コード例 #38
0
ファイル: __init__.py プロジェクト: matham/Ceed
    def _show_mea_outline(self, config, transform_matrix=None):
        from kivy.graphics import (
            Line, StencilPush, StencilUse, StencilUnUse, StencilPop, Rectangle,
            Color)
        from kivy.graphics.context_instructions import (
            PushMatrix, PopMatrix, Rotate, Translate, Scale, MatrixInstruction,
            BindTexture)
        from kivy.graphics.transformation import Matrix
        from kivy.base import EventLoop
        EventLoop.ensure_window()
        from kivy.core.text import Label
        from kivy.metrics import dp, sp

        size = config['orig_size']
        pos = config['pos']
        canvas = config['canvas']
        mea_w = max(self.view_controller.mea_num_cols - 1, 0) * \
            self.view_controller.mea_pitch
        mea_h = max(self.view_controller.mea_num_rows - 1, 0) * \
            self.view_controller.mea_pitch
        last_col = "ABCDEFGHJKLMNOPQRSTUVWXYZ"[
            self.view_controller.mea_num_cols - 1]

        with canvas:
            StencilPush()
            Rectangle(pos=pos, size=size)
            StencilUse()

            PushMatrix()
            if transform_matrix is not None:
                mat = Matrix()
                mat.set(array=transform_matrix)
                m = MatrixInstruction()
                m.matrix = mat
            Color(1, 215 / 255, 0, .2)
            Line(points=[0, 0, mea_w, 0, mea_w, mea_h, 0, mea_h], close=True)

            label = Label(text='A1', font_size=sp(12))
            label.refresh()
            _w, _h = label.texture.size
            rect = Rectangle(
                pos=(mea_w, mea_h - _h / 2.), size=label.texture.size)
            rect.texture = label.texture

            label = Label(
                text='A{}'.format(self.view_controller.mea_num_rows),
                font_size=sp(12))
            label.refresh()
            _w, _h = label.texture.size
            rect = Rectangle(
                pos=(-_w, mea_h - _h / 2.), size=label.texture.size)
            rect.texture = label.texture

            label = Label(text='{}1'.format(last_col), font_size=sp(12))
            label.refresh()
            _w, _h = label.texture.size
            rect = Rectangle(pos=(mea_w, -_h / 2.), size=label.texture.size)
            rect.texture = label.texture

            label = Label(
                text='{}{}'.format(last_col, self.view_controller.mea_num_rows),
                font_size=sp(12))
            label.refresh()
            _w, _h = label.texture.size
            rect = Rectangle(pos=(-_w, -_h / 2.), size=label.texture.size)
            rect.texture = label.texture
            PopMatrix()

            StencilUnUse()
            Rectangle(pos=pos, size=size)
            StencilPop()
コード例 #39
0
ファイル: __init__.py プロジェクト: matham/Ceed
    def _paint_electrodes_data_setup(
            self, config, electrode_names,
            spacing=2, draw_size=(0, 0), draw_size_hint=(1, 1),
            draw_pos=(0, 0), draw_pos_hint=(None, None), volt_scale=1e-6,
            time_axis_s=1, volt_axis=100, transform_matrix=None,
            label_width=70):
        from kivy.graphics import (
            Mesh, StencilPush, StencilUse, StencilUnUse, StencilPop, Rectangle,
            Color)
        from kivy.graphics.context_instructions import (
            PushMatrix, PopMatrix, Scale, MatrixInstruction)
        from kivy.graphics.transformation import Matrix
        from kivy.base import EventLoop
        EventLoop.ensure_window()
        from kivy.core.text import Label
        from kivy.metrics import dp, sp

        n_rows = len(electrode_names)
        if not n_rows:
            raise ValueError("There must be at least one electrode specified")
        n_cols = len(electrode_names[0])
        if not n_cols:
            raise ValueError("There must be at least one electrode specified")
        if not all((len(row) == n_cols for row in electrode_names)):
            raise ValueError(
                "The number of electrodes in all rows must be the same")
        n_electrodes = sum(map(len, electrode_names))

        orig_w, orig_h = config['orig_size']
        fbo = config['canvas']

        label_height = 45 if label_width else 0
        draw_w, draw_h = draw_size
        draw_hint_w, draw_hint_h = draw_size_hint
        w = int(draw_w if draw_hint_w is None else orig_w * draw_hint_w)
        h = int(draw_h if draw_hint_h is None else orig_h * draw_hint_h)

        draw_x, draw_y = draw_pos
        draw_hint_x, draw_hint_y = draw_pos_hint
        x = int(draw_x if draw_hint_x is None else orig_w * draw_hint_x)
        y = int(draw_y if draw_hint_y is None else orig_h * draw_hint_y)

        ew = int((w - label_width - max(0, n_cols - 1) * spacing) / n_cols)
        eh = int((h - label_height - max(0, n_rows - 1) * spacing) / n_rows)

        with fbo:
            PushMatrix()
            # center = x + w / 2., y + h / 2.
            # if scale:
            #     Scale(scale, scale, 1, origin=center)
            if transform_matrix is not None:
                mat = Matrix()
                mat.set(array=transform_matrix)
                m = MatrixInstruction()
                m.matrix = mat

        positions = [(0, 0), ] * n_electrodes
        graphics = [None, ] * n_electrodes
        i = 0

        electrode_color = 1, 215 / 255, 0, 1
        for row, row_names in enumerate(reversed(electrode_names)):
            ey = y + label_height
            if row:
                ey += (eh + spacing) * row

            for col, name in enumerate(row_names):
                if name is None:
                    i += 1
                    continue

                ex = x + label_width
                if col:
                    ex += (ew + spacing) * col

                positions[i] = ex, ey
                fbo.add(Color(*electrode_color))
                fbo.add(StencilPush())
                fbo.add(Rectangle(pos=(ex, ey), size=(ew, eh)))
                fbo.add(StencilUse())
                graphics[i] = Mesh(mode='line_strip')
                fbo.add(graphics[i])
                fbo.add(StencilUnUse())
                fbo.add(Rectangle(pos=(ex, ey), size=(ew, eh)))
                fbo.add(StencilPop())

                i += 1

                if label_width:
                    if not col:
                        fbo.add(Color(1, 1, 1, 1))
                        label = Label(text=name, font_size=sp(40))
                        label.refresh()
                        _w, _h = label.texture.size
                        rect = Rectangle(
                            pos=(x, ey + (eh - _h) / 2.),
                            size=label.texture.size)
                        rect.texture = label.texture
                        fbo.add(rect)

                    if not row:
                        fbo.add(Color(1, 1, 1, 1))
                        label = Label(text=name, font_size=sp(40))
                        label.refresh()
                        _w, _h = label.texture.size
                        rect = Rectangle(
                            pos=(ex + (ew - _w) / 2., y),
                            size=label.texture.size)
                        rect.texture = label.texture
                        fbo.add(rect)

        with fbo:
            Color(1, 1, 1, 1)
            PopMatrix()

        electrodes_data = [None, ] * n_electrodes
        # y_min, y_max = float('inf'), float('-inf')
        alignment = np.array(self.electrode_intensity_alignment)

        # get the frequency from any channel
        name = None
        for row_names in electrode_names:
            for name in row_names:
                if name is not None:
                    break
            if name is not None:
                break
        freq = self.electrodes_metadata[name]['sampling_frequency']

        frame_n = int(1 / config['rate'] * freq)
        n_t = int(time_axis_s * freq)
        t_vals = np.arange(n_t) / (n_t - 1) * ew
        y_scale = (eh / 2) / volt_axis

        for i, name in enumerate(itertools.chain(*electrode_names)):
            if name is None:
                continue
            offset, scale = self.get_electrode_offset_scale(name)
            electrodes_data[i] = \
                self.electrodes_data[name], offset, scale / volt_scale
            # y_min = min(np.min(data), y_min)
            # y_max = max(np.max(data), y_max)

        new_config = {
            'alignment': alignment, 'frame_n': frame_n, 't_vals': t_vals,
            'y_scale': y_scale, 'electrodes_data': electrodes_data, 'n_t': n_t,
            'positions': positions, 'graphics': graphics, 'eh': eh}
        return CallableGen(self._paint_electrodes_data(new_config))