Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dynamic_gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
dynamic_gui
Commits
33a1ef09
Commit
33a1ef09
authored
6 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Revised code to avoid student confusion from last semester.
parent
8bf8e85b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
demo.kv
+7
-7
7 additions, 7 deletions
demo.kv
main.py
+2
-5
2 additions, 5 deletions
main.py
with
9 additions
and
12 deletions
demo.kv
+
7
−
7
View file @
33a1ef09
...
@@ -17,10 +17,10 @@ BoxLayout:
...
@@ -17,10 +17,10 @@ BoxLayout:
on_press: app.print_total()
on_press: app.print_total()
<Field>:
<Field>:
BoxLayout
:
orientation: 'horizontal' # Field is a kind of
BoxLayout
orientation: 'horizontal'
Label:
Label:
text: root.label_text # Refers to a property declared in the Field class
text: root.label_text
TextInput:
TextI
nput
:
id: i
nput
id: input
multiline: False
multiline
: False
write_tab
: False
This diff is collapsed.
Click to expand it.
main.py
+
2
−
5
View file @
33a1ef09
...
@@ -4,10 +4,7 @@ from kivy.properties import StringProperty
...
@@ -4,10 +4,7 @@ from kivy.properties import StringProperty
class
Field
(
BoxLayout
):
class
Field
(
BoxLayout
):
label_text
=
StringProperty
(
'
Data:
'
)
label_text
=
StringProperty
()
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
class
DemoApp
(
App
):
class
DemoApp
(
App
):
...
@@ -26,7 +23,7 @@ class DemoApp(App):
...
@@ -26,7 +23,7 @@ class DemoApp(App):
total
=
0
total
=
0
for
field
in
container
.
children
:
for
field
in
container
.
children
:
try
:
try
:
total
+=
in
t
(
field
.
ids
.
input
.
text
)
total
+=
floa
t
(
field
.
ids
.
input
.
text
)
# refer to a subwidget by id
except
ValueError
:
except
ValueError
:
pass
# ignore non-numeric values
pass
# ignore non-numeric values
print
(
'
Total of fields
\'
numeric values: {total}
'
.
format
(
total
=
total
))
print
(
'
Total of fields
\'
numeric values: {total}
'
.
format
(
total
=
total
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment