BarBar288 commited on
Commit
e1d146f
·
verified ·
1 Parent(s): ea9e68b

Update app.py

Browse files

//LOG_ 111424_a
Add save names to file functionality
//endlog
/commit

Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -18,13 +18,8 @@ class WheelOfNames:
18
 
19
  def save_file(self):
20
  if self.names:
21
- with st.expander("Download Names as Text File"):
22
- st.download_button(
23
- label="Download",
24
- data="\n".join(self.names),
25
- file_name="names.txt",
26
- mime="text/plain"
27
- )
28
 
29
  def clear_names(self):
30
  self.names = []
@@ -88,7 +83,19 @@ def main():
88
  wheel.add_name(name_entry)
89
 
90
  wheel.upload_file()
91
- wheel.save_file()
 
 
 
 
 
 
 
 
 
 
 
 
92
  if st.button("Clear Names"):
93
  wheel.clear_names()
94
 
 
18
 
19
  def save_file(self):
20
  if self.names:
21
+ return "\n".join(self.names)
22
+ return None
 
 
 
 
 
23
 
24
  def clear_names(self):
25
  self.names = []
 
83
  wheel.add_name(name_entry)
84
 
85
  wheel.upload_file()
86
+
87
+ if st.button("Save Names to File"):
88
+ names_data = wheel.save_file()
89
+ if names_data:
90
+ st.download_button(
91
+ label="Download Names",
92
+ data=names_data,
93
+ file_name="names.txt",
94
+ mime="text/plain"
95
+ )
96
+ else:
97
+ st.error("No names to save.")
98
+
99
  if st.button("Clear Names"):
100
  wheel.clear_names()
101