Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CiS Projekt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ockenden, Samuel
CiS Projekt
Commits
f283c2c3
Commit
f283c2c3
authored
3 years ago
by
David, Sebastian
Browse files
Options
Downloads
Patches
Plain Diff
Erste Version der UI
parent
e5604131
No related branches found
No related tags found
1 merge request
!8
UI Hinzufügen
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ui_programm_fragmente/input_to_checklist.py
+63
-0
63 additions, 0 deletions
ui_programm_fragmente/input_to_checklist.py
ui_programm_fragmente/upload_to_checklist.py
+51
-0
51 additions, 0 deletions
ui_programm_fragmente/upload_to_checklist.py
with
114 additions
and
0 deletions
ui_programm_fragmente/input_to_checklist.py
0 → 100644
+
63
−
0
View file @
f283c2c3
import
dash
from
dash
import
dcc
from
dash
import
html
from
dash
import
callback_context
from
dash.dependencies
import
Input
,
Output
,
State
from
dash.exceptions
import
PreventUpdate
app
=
dash
.
Dash
(
__name__
)
list_of_inputs
=
dict
()
app
.
layout
=
html
.
Div
([
html
.
H4
(
"
Progressively add input strings to a list
"
),
html
.
Div
([
html
.
Button
(
id
=
'
show-info
'
,
children
=
'
Show Info
'
,
n_clicks
=
0
),
html
.
Div
(
id
=
'
info-box
'
)
]),
html
.
Div
([
"
Input:
"
,
dcc
.
Input
(
id
=
'
my-input
'
,
value
=
''
,
type
=
'
text
'
,
debounce
=
True
),
dcc
.
Checklist
(
id
=
'
list-of-inputs
'
,
labelStyle
=
dict
(
display
=
'
block
'
)),
html
.
Button
(
id
=
'
clear-all-button
'
,
children
=
'
Clear All
'
),
html
.
Button
(
id
=
'
clear-selected-button
'
,
children
=
'
Clear Selected
'
)
]),
])
@app.callback
(
Output
(
'
list-of-inputs
'
,
'
options
'
),
Output
(
'
my-input
'
,
'
value
'
),
Input
(
'
my-input
'
,
'
value
'
),
Input
(
'
clear-all-button
'
,
'
n_clicks
'
),
Input
(
'
clear-selected-button
'
,
'
n_clicks
'
),
State
(
'
list-of-inputs
'
,
'
value
'
)
)
def
update_input_list
(
input_value
,
btn1
,
btn2
,
all_inputs
):
changed_id
=
[
p
[
'
prop_id
'
]
for
p
in
callback_context
.
triggered
][
0
]
if
'
clear-all-button
'
in
changed_id
:
list_of_inputs
.
clear
()
return
list
(),
''
if
'
clear-selected-button
'
in
changed_id
:
for
key
in
range
(
len
(
all_inputs
)):
if
all_inputs
[
key
]:
del
list_of_inputs
[
all_inputs
[
key
]]
return
[{
'
label
'
:
i
,
'
value
'
:
i
}
for
i
in
list_of_inputs
],
''
if
input_value
==
''
:
return
list
(),
''
if
input_value
not
in
list_of_inputs
:
list_of_inputs
[
input_value
]
=
input_value
return
[{
'
label
'
:
i
,
'
value
'
:
i
}
for
i
in
list_of_inputs
],
''
@app.callback
(
Output
(
'
info-box
'
,
'
children
'
),
Input
(
'
show-info
'
,
'
n_clicks
'
)
)
def
show_hide_info_box
(
n_clicks
):
if
n_clicks
%
2
==
0
:
return
''
else
:
return
"
Hier koennte Ihre Werbung stehen
"
if
__name__
==
'
__main__
'
:
app
.
run_server
(
debug
=
True
)
This diff is collapsed.
Click to expand it.
ui_programm_fragmente/upload_to_checklist.py
0 → 100644
+
51
−
0
View file @
f283c2c3
import
dash
from
dash
import
dcc
from
dash
import
html
from
dash.dependencies
import
Input
,
Output
app
=
dash
.
Dash
(
__name__
)
list_of_inputs
=
dict
()
app
.
layout
=
html
.
Div
([
html
.
H4
(
"
Add all lines in a file to a list
"
),
html
.
Div
([
dcc
.
Upload
(
id
=
"
upload-data
"
,
children
=
html
.
Div
(
[
"
Drag and drop or click to select a file to upload.
"
]
),
style
=
{
"
width
"
:
"
30%
"
,
"
height
"
:
"
60px
"
,
"
lineHeight
"
:
"
60px
"
,
"
borderWidth
"
:
"
1px
"
,
"
borderStyle
"
:
"
dashed
"
,
"
borderRadius
"
:
"
5px
"
,
"
textAlign
"
:
"
center
"
,
"
margin
"
:
"
10px
"
,
}),
dcc
.
Checklist
(
id
=
'
list-of-inputs
'
,
labelStyle
=
dict
(
display
=
'
block
'
))
]),
])
@app.callback
(
Output
(
'
list-of-inputs
'
,
'
options
'
),
Input
(
'
upload-data
'
,
'
filenames
'
),
Input
(
'
upload-data
'
,
'
contents
'
)
)
def
update_input_list
(
uploaded_filenames
,
uploaded_file_contents
):
for
line
in
uploaded_file_contents
:
line
=
line
.
rstrip
()
list_of_inputs
[
line
]
=
line
try
:
stream
=
open
(
uploaded_filenames
,
'
r
'
)
# this statement may throw an exception
except
IOError
as
err
:
# exception stores error message in err
# now comes the code reacting on the exception
sys
.
stderr
.
write
(
'
{}: {}
\n
'
.
format
(
sys
.
argv
[
0
],
err
))
exit
(
1
)
return
[{
'
label
'
:
i
,
'
value
'
:
i
}
for
i
in
list_of_inputs
],
''
if
__name__
==
'
__main__
'
:
app
.
run_server
(
debug
=
True
)
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