Kivy variable background widget

I recently started using kivy, and I have a question about the change of the background. I need to create multiple widgets with different backgrounds. I'm doing it wrong, but I did not get:

Kv file: <[email protected]>: canvas.before: Color: rgb: self.rgb Rectangle: pos: self.pos size: self.size widget = Widget() myWidget1 = Factory.MyWidget(rgb=[1,0,0]) myWidget2 = Factory.MyWidget(rgb=[0,1,0]) myWidget3 = Factory.MyWidget(rgb=[0,0,1]) widget.add_widget(myWidget1) widget.add_widget(myWidget2) widget.add_widget(myWidget3)

How can I make it better?

-------------Problems Reply------------

As the comments above say, the problem is that MyWidget doesn't have an 'rgb' attribute (nor does a BoxLayout).

In the python file, you need to create the class with that attribute. Specifically, you should create a ListProperty attribute so that all the automatic binding on the kv side happens.

from import ListProperty
from kivy.uix.boxlayout import BoxLayout

class MyWidget(Boxlayout):
rgb = ListProperty([0,0,0])

Category:android Views:3 Time:2018-08-09

Related post

  • How can I make a variable background image in my iOS APP 2011-01-08

    I am making an iPhone app, and I want know how make a variable background image a background that the user can choose one of the options ? --------------Solutions------------- I don't know what you want in the foreground, but anything based on the UI

  • Variable Backgrounds via Mixing PHP/CSS 2010-08-13

    I'm working on a pretty simple page for my "internship." I can't go into much detail, but I can say that it involves sheep, lasers, and everything you've ever wanted. Anyways, I'm trying to get it so that the background changes depending on whether t

  • Pass variable as reference to jqueryui widget 2011-10-05

    I have widgetA with data structure - d. widgetA initializes widgetB and passes data to widgetB, like $('<div>').widgetB({d:d}); But, when data in widgetA changes, in widgetB they dont, thats because when passing variables as options, jquery wid

  • Using C++ Macros To Check For Variable Existence 2010-07-06

    I am creating a logging facility for my library, and have made some nice macros such as: #define DEBUG myDebuggingClass(__FILE__, __FUNCTION__, __LINE__) #define WARING myWarningClass(__FILE__, __FUNCTION__, __LINE__) where myDebuggingClass and myWar

  • On-value-change type of event for widgets or use .trace_variable() technique? 2010-11-12

    Is there an on-value-change type of event for data input widgets like Entry, Text, Spinner, Checkbutton, Radiobutton? By on-value-change, I mean the ability to detect when the value of a widget has changed due to keyboard input or cut/delete/paste (a

  • fixed center div, surrounded by variable width divs, surrounded by fixed corner divs 2011-05-26

    I want to position, in a page, a bar like this: [corner-l][variable][ornament][variable][corner-r] the "variable" spacer parts should be resizable, but ultimately, the surrounding container (containing all of this) should dictate the maximum width, a

  • How to Layer independent widgets in Qt? 2012-02-07

    I'm creating an application using Qt which consists of a widget that is used as the background of the application, and a user control interface that is floating above. A similar example is google maps, where the map is on the background and the contr

  • Rails Sass: variables arenot passed with @import 2016-10-20

    I have a rails project which uses twitter bootstrap and sass. The scss files are structured into folders so i have a better overview. Now I want to define a file for global variables which contains my colors etc. and pass those values down to other f

  • Different color for different choices in tkinter option menu 2011-08-09

    I am using Python and Tkinter. I have an option menu with three choices with "on" being one of them. I want to make "on" be green when I select it. I don't mean the font. I want the background of the option menu to be green when I select "on" while t

  • Why i get this error 2010-07-06

    I have a png image on Library that i have declared it via Properties as Background class which extends BitmapData. When i type: var BMDClass:Class = getDefinitionByName( "Background" ) as Class; i get: variable Background is not defined!! But when i

  • Embedding PHP in CSS 2010-08-26

    I'm trying to create a variable background, where the image changes based on the time of day. This code I have USED to work, but I did something somewhere along the line and didn't notice that the functionality had broken. Can someone explain to me w

  • How to create a dynamic CSS-based interface using moving content tiles? 2010-09-16

    I'm trying to figure out what the best way would be to set up a website interface that has a large centre 'tile' (basically a div with rounded corners, a variable background image, and text on it) that acts as the hub of the interface, around which I

  • Tesseract OCR Library - Learning Font 2011-02-05

    Well I'm using a complied .NET version of this OCR which can be found @ I have it working, however the aim of this is to translate license plates, sadly the engine really doesn't accurately translate

  • Sorl thumbnail not showing thumb in AdminImageMixin 2011-03-27

    I'm having trouble with Django 1.3 using django-grappeli and sorl-thumbnail. I have a project that uses this code from the official sorl-thumbnails docs: # myapp/ from django.contrib import admin from myapp.models import MyModel from sorl.thu

  • Fields interfering with method resolution for Scala Dynamic trait? 2011-06-01

    As my first foray into Dynamic Scala land, I thought that I'd try accessing bean properties via applyDynamic. My first very rough cut is trait BeanProperties extends Dynamic { def applyDynamic(name: String)(args: Any*) = { if (args.length == 0) Prope

  • " document.getElementById onmouseover and function " does not behave as wished × 108641 2011-07-01

    In this function, it should give the menu items (li's) an specific background (png) out of an array. However; it doesn't. It gives all the li's the background called color 'blue' :(. Do you see the problem? //Gives the menu items a style when hoverin

  • Are these controller specs good enough? 2011-07-06

    I am new to testing controllers with RSpec. In my controller, I have these methods: def edit @widget = Widget.find(params[:id]) if @widget.present? @all_widgets = Widget.where(:id !="id, title") wfs else redirect_to wid

  • Add ID to menu items in drupal main menu 2011-08-15

    Attached to my template, that I received from my slicer, there was a javascript file for coloring the menu items. Now I need to convert the template to a Drupal template. The javascript is based on the fact that every menu item has an id, according t

  • Returning a value from Sub Report to Main Report in iReport 2011-09-08

    Hi every one I am using iReports for generating one of the reports and stuck at one place. The situation is like this: I am using one sub report in my main report and i want to return a variable (float) back to the main report from sub report after t

  • iReport 4.1.3 table component never shows the first entry of the dataset 2011-12-07

    i have a probably simple problem when using ireport table component. I'm using xml as the datasource for the report. The problem is that the table never shows the first entry of the dataset associated with it. Imagine i have this data: <name>

  • Centering Dynamic width Divs 2012-01-08

    I have a page that has 2 columns. The first column is a dynamic width. It contains a bunch of tabular data in tables. The 2nd column is a fixed width full of navigation stuff. The 2 columns are divs with float left. I need to accomplish 2 things. I n

  • JasperReports: how to tell if a field is pushed onto next page 2012-01-31

    I am generating a report with contacts that span across different pages. Previously I had isSplitAllowed set to "true". But I don't want a contact to split across different pages. So I set it to "false", the layout of the report looked much better. H

  • How to generate possible arragment of two or more different designed tiles using c# /jquery/javascript/silverlight? 2012-02-01

    I'm trying to figure out what the best way would be to set up a interface of multiple 'tiles' (a variable background image, and text on it.) that acts as the hub of the interface. I want to generate possible arrangement of two or more different tiles

  • Placing a text over an image 2012-04-05

    I can't think of a good way to place text over an image. Here is what I want to do: This is what I have. I want to place text over the yellow navigation signs on the left (like normal navigation of Home, Contact Us, About Us, etc...) but I can't real

Copyright (C), All Rights Reserved.

processed in 0.164 (s). 11 q(s)