For When Your Brain Hurts Flashcards
What is the key for when you want to make something happen when you click on a BUTTON
on_press
What is the key for when you want to make something happen when you toggle a SWITCH
How do you make it on from the start of the program
on_active:
active: True
What is the key for when you want to make something happen when you toggle a TOGGLEBUTTON
on_state:
What is the key for when you want to make something happen when you slide a SLIDER
Change the number it starts on to 50
Make the lowest number 0 and the highest 100
change the orientation
on_value:
value: 50
min: 0
max: 100
orientation: ‘vertical’
How do you add TEXT
How do you make the initial text something
How do you have something happen when you click enter on your text.
How do you reference the text you just typed?
TextInput:
text: ‘foo’
multiline: False
on_text_validate: root.on_text_validate(self)
TextInput.text
What layout goes left to right, top to bottom but you can choose how it’s stacked horizontally and vertically?
StackLayout
orientation ‘lr-tb’
What layout goes top to bottom
BoxLayout
What layout allows you to place things according to boxes and rows?
GridLayout
What layout let’s you put something anywhere top, bottom, left, right
AnchorLayout
anchor_x = ‘left’
anchor_y = ‘top’
What is a layout that lets you flip through multiple pages of different layouts
PageLayout
What layout lets you scroll up and down or left and right
ScrollView
What do you use to be able to change a variable or float
from kivy.properties import StringProperty, BooleanProperty
How do you create something that tracks your slider that the progress bar can use? What key do you add so it can follow the slider?
ProgressBar:
max: 100
value: int(my_slider.value)
What module do you import to get shapes and lines?
What module do you import for colors?
from kivy.graphics.vertex_instructions import Ellipse, Line, Rectangle, Circle
from kivy.graphics.context import Color
What is the difference in how you make shapes via the Python file and the Kivy file?
class CanvasExample(Widget):
def __init__(self, kwargs):
super().__init__(kwargs):
with self.canvas:
KV FILE
canvas:
What is the difference making shapes with Line vs just the shape itself do kivy file version and python version
Line:
rectangle: (x, x, x, x)
circle: (x, x, x)
ellipse: (x, x, x, x)
Position is added in the argument
Circle:
size:
pos:
with self.canvas:
Rectangle(pos=(700, 200), size=(150, 100))
Line=(rectangle=(700,500, 150, 100), width=5
What are the options to automatically to the end of the screen horizontally and vertically
self.width
self.height
You’ve created a variable named rect with the value of a rectangle. What do you put to reference it’s position and size?
self.rect.pos
self.rect.size
What Variable do you use to update something in your code 60 times in a second (60 fps)
How do you tell your program what to update?
What does DT stand for?
What does DP stand for?
from kivy.properties import Clock
class CanvasExample5(GridLayout):
def __init__(self, kwargs):
super().__init__(kwargs)
Clock.schedule_interval(self.update, 1/60)
def update(self, dt):
print(‘update’)
Density Independent Pixels
Delta Time
How do you create a variable in a kv file?
”#:set s dp(150)”
Ignore the quotes, think that will protect it from BrainScape formatting my flash cards like morons.
What do you get when you try to use self.center?
Two numbers.