Summary
Intro
let me help you with the homework I left in Lesson 03.05. I want to make sure you know how to make that Flex TextForm reusable.
So, let's have a look together.
Copying Files to Your Lib
Firstly, we need to copy our code to lib folder, and remember that we don't need xaml, since we made everything with Behind-Code.
So, copy the python file and rename to something like FlexTextForm.py
Cleaning Up the Code
Now, it's great time to actually clean up your code.
Go through the python code and remove all unnecessary comments, and remove the code example on the bottom.
Also, it will be really useful to make a doc string so we can always reference on how to use this form and leave an example.
And I will rename my classes a little, so they have my
ef_prefix in the beginning.
Here is my code after clean-up:
Import in __init__.py
Same as before, let's import this class inside of __init__ file so we can import directly from ef_forms module (or however you called your folder).
Using the Reusable Flex Text Form
And now we can import and test it from any file in our extension.
Here is an example with a few text inputs:
Conclusion
I hope it helped you to make this class reusable, and now you are ready for the next module - Styling in WPF.
I wish you Happy Coding and I will see you soon.
🙋♂️ See you in the next lesson.
- EF