Milind Kamat commited on
Commit
327366d
·
1 Parent(s): 8ba5c6a

2024 Dec 30: Ver 1 helper methods added

Browse files

Signed-off-by: Milind Kamat <36366961+milindkamat0507@users.noreply.github.com>

Files changed (1) hide show
  1. app.py +140 -0
app.py CHANGED
@@ -61,6 +61,146 @@ class StreamlitTutorial:
61
  </style>
62
  """, unsafe_allow_html=True)
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  def get_text_elements(self) -> List[Tuple[str, str]]:
65
  """
66
  Provides collection of text element examples with corresponding code.
 
61
  </style>
62
  """, unsafe_allow_html=True)
63
 
64
+ # Add these helper methods in the StreamlitTutorial class
65
+
66
+ def _get_basic_concepts_content(self) -> str:
67
+ """
68
+ Provides content for Basic Concepts section.
69
+ Contains fundamental explanations and examples.
70
+
71
+ Returns:
72
+ str: Markdown formatted basic concepts content
73
+ """
74
+ return """
75
+ **What are Text Elements?**
76
+ - Basic building blocks for displaying text
77
+ - Range from titles to formatted text
78
+ - Support markdown formatting
79
+
80
+ **Key Components:**
81
+ 1. Title & Headers
82
+ 2. Regular text
83
+ 3. Formatted text
84
+ 4. Colored text
85
+ """
86
+
87
+ def _get_best_practices_content(self) -> str:
88
+ """
89
+ Provides content for Best Practices section.
90
+ Contains guidelines and recommended approaches.
91
+
92
+ Returns:
93
+ str: Markdown formatted best practices content
94
+ """
95
+ return """
96
+ **Writing Tips:**
97
+ 1. Use appropriate heading levels
98
+ 2. Keep text concise and clear
99
+ 3. Use formatting for emphasis
100
+ 4. Add visual hierarchy with headers
101
+
102
+ **Code Structure:**
103
+ ```python
104
+ st.title('Main Title')
105
+ st.header('Section Header')
106
+ st.subheader('Sub-section')
107
+ st.write('Regular text')
108
+ ```
109
+ """
110
+
111
+ def _get_examples_content(self) -> str:
112
+ """
113
+ Provides content for Examples section.
114
+ Contains practical examples and use cases.
115
+
116
+ Returns:
117
+ str: Markdown formatted examples content
118
+ """
119
+ return """
120
+ **Common Patterns:**
121
+
122
+ 1. Page Structure
123
+ ```python
124
+ st.title('Dashboard')
125
+ st.header('Sales Data')
126
+ st.subheader('Monthly Trends')
127
+ ```
128
+
129
+ 2. Formatted Text
130
+ ```python
131
+ st.markdown('**Bold** and *italic*')
132
+ st.markdown(':blue[Colored text]')
133
+ ```
134
+
135
+ 3. Mixed Elements
136
+ ```python
137
+ st.title('Report')
138
+ st.write('Regular text')
139
+ st.markdown('- Bullet point')
140
+ ```
141
+ """
142
+
143
+ def _get_common_mistakes_content(self) -> str:
144
+ """
145
+ Provides content for Common Mistakes section.
146
+ Contains typical errors and how to avoid them.
147
+
148
+ Returns:
149
+ str: Markdown formatted common mistakes content
150
+ """
151
+ return """
152
+ 1. Skipping header levels
153
+ 2. Overusing formatting
154
+ 3. Inconsistent styling
155
+ 4. Missing hierarchy
156
+
157
+ **How to Avoid:**
158
+ - Plan your page structure
159
+ - Use consistent formatting
160
+ - Test different screen sizes
161
+ - Keep it simple
162
+ """
163
+
164
+ def _get_advanced_tips_content(self) -> str:
165
+ """
166
+ Provides content for Advanced Tips section.
167
+ Contains advanced usage and techniques.
168
+
169
+ Returns:
170
+ str: Markdown formatted advanced tips content
171
+ """
172
+ return """
173
+ **Advanced Formatting:**
174
+ ```python
175
+ # Custom HTML
176
+ st.markdown('''
177
+ <span style='color:blue'>
178
+ Custom styled text
179
+ </span>
180
+ ''', unsafe_allow_html=True)
181
+
182
+ # Complex Markdown
183
+ st.markdown('''
184
+ # Title
185
+ ## Subtitle
186
+ * Point 1
187
+ * Subpoint
188
+ > Quote
189
+ ''')
190
+ ```
191
+
192
+ **Layout Combinations:**
193
+ ```python
194
+ col1, col2 = st.columns(2)
195
+ with col1:
196
+ st.header('Column 1')
197
+ with col2:
198
+ st.header('Column 2')
199
+ ```
200
+ """
201
+
202
+
203
+
204
  def get_text_elements(self) -> List[Tuple[str, str]]:
205
  """
206
  Provides collection of text element examples with corresponding code.