For When Your Brain Hurts Flashcards

1
Q

What is the key for when you want to make something happen when you click on a BUTTON

A

on_press

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

on_active:
active: True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the key for when you want to make something happen when you toggle a TOGGLEBUTTON

A

on_state:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

on_value:
value: 50
min: 0
max: 100
orientation: ‘vertical’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?

A

TextInput:
text: ‘foo’
multiline: False
on_text_validate: root.on_text_validate(self)

TextInput.text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What layout goes left to right, top to bottom but you can choose how it’s stacked horizontally and vertically?

A

StackLayout
orientation ‘lr-tb’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What layout goes top to bottom

A

BoxLayout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What layout allows you to place things according to boxes and rows?

A

GridLayout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What layout let’s you put something anywhere top, bottom, left, right

A

AnchorLayout
anchor_x = ‘left’
anchor_y = ‘top’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a layout that lets you flip through multiple pages of different layouts

A

PageLayout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What layout lets you scroll up and down or left and right

A

ScrollView

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do you use to be able to change a variable or float

A

from kivy.properties import StringProperty, BooleanProperty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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?

A

ProgressBar:
max: 100
value: int(my_slider.value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What module do you import to get shapes and lines?

What module do you import for colors?

A

from kivy.graphics.vertex_instructions import Ellipse, Line, Rectangle, Circle

from kivy.graphics.context import Color

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference in how you make shapes via the Python file and the Kivy file?

A

class CanvasExample(Widget):
def __init__(self, kwargs):
super().__init__(
kwargs):
with self.canvas:

KV FILE
canvas:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference making shapes with Line vs just the shape itself do kivy file version and python version

A

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
17
Q

What are the options to automatically to the end of the screen horizontally and vertically

A

self.width
self.height

18
Q

You’ve created a variable named rect with the value of a rectangle. What do you put to reference it’s position and size?

A

self.rect.pos
self.rect.size

19
Q

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?

A

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

20
Q

How do you create a variable in a kv file?

A

”#:set s dp(150)”

Ignore the quotes, think that will protect it from BrainScape formatting my flash cards like morons.

21
Q

What do you get when you try to use self.center?

A

Two numbers.