initial
This commit is contained in:
commit
74ae93a96e
7 changed files with 94691 additions and 0 deletions
6
joplin notion extension/Web Development/Python/Extras.md
Normal file
6
joplin notion extension/Web Development/Python/Extras.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Extras
|
||||
|
||||
python http server
|
||||
`python -m http.server 8000`
|
||||
for custom directory
|
||||
`python -m http.server 8000 --directory /path/to/your/folder`
|
||||
43
joplin notion extension/Web Development/Python/Flet/Intro.md
Normal file
43
joplin notion extension/Web Development/Python/Flet/Intro.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
Intro
|
||||
https://flet.dev/docs/
|
||||
Flutter in python
|
||||
|
||||
- Installation
|
||||
`pip install flet` (Need python version>3.8)
|
||||
- Running code
|
||||
`python counter.py`
|
||||
- Sample code
|
||||
```py
|
||||
import flet as ft
|
||||
|
||||
def main(page: ft.Page):
|
||||
page.title = "Flet counter example"
|
||||
page.vertical_alignment = ft.MainAxisAlignment.CENTER
|
||||
|
||||
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)
|
||||
|
||||
def minus_click(e):
|
||||
txt_number.value = str(int(txt_number.value) - 1)
|
||||
page.update()
|
||||
|
||||
def plus_click(e):
|
||||
txt_number.value = str(int(txt_number.value) + 1)
|
||||
page.update()
|
||||
|
||||
page.add(
|
||||
ft.Row(
|
||||
[
|
||||
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
|
||||
txt_number,
|
||||
ft.IconButton(ft.icons.ADD, on_click=plus_click),
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.CENTER,
|
||||
)
|
||||
)
|
||||
|
||||
ft.app(target=main)
|
||||
```
|
||||
- Packing
|
||||
Need to install pyinstaller first using `pip install pyinstaller`
|
||||
then
|
||||
`flet pack counter.py`
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
Installing modules
|
||||
|
||||
|
||||
- When installing modules with pip we may get this error
|
||||
`This environment is externally managed`
|
||||
So use this to bypass the error message
|
||||
`pip install package_name --break-system-packages`
|
||||
- another error may be `Expat >=2.6.0 API function XML_SetReparseDeferralEnabled`
|
||||
in this case upgrade `expat` package
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
Tkinter Snippets
|
||||
|
||||
|
||||
[10 Interesting Python Tkinter Programs with Code _ by Swathi Arun _ Level Up Coding (12_11_2023 3_47_59 am).html](../../../_resources/10%20Interesting%20Python%20Tkinter%20Programs%20with%20Code%20_.html)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
compiling python
|
||||
|
||||
1. download tar file from python site.
|
||||
2. after extracting and moving to this directory, run `make -j $(nproc)` to use all cpu cores or just use `make`
|
||||
3. then run `sudo make altinstall` to have packages on `/usr/local/bin` or use `make DESTDIR=~/local install` (this might not always work)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package
|
||||
|
||||
- to install in virtual environment
|
||||
- `python3 -m venv env` : to create venv
|
||||
- `source env/bin/activate` : to activate it
|
||||
- `pip install -r requirements.txt`
|
||||
- finally to deactivate use `deactivate`
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
pyenv
|
||||
https://realpython.com/intro-to-pyenv/
|
||||
|
||||
- Installation
|
||||
`$ curl https://pyenv.run | bash`
|
||||
- Confirguration
|
||||
Adding following in `~/.bashrc`
|
||||
```
|
||||
export PATH="$HOME/.pyenv/bin:$PATH"
|
||||
eval "$(pyenv init -)"
|
||||
eval "$(pyenv virtualenv-init -)"
|
||||
```
|
||||
|
||||
- Use
|
||||
`$ pyenv install --list | grep " 3\.[678]"`
|
||||
To install desired one
|
||||
`pyenv install -v 3.7.2`
|
||||
List versions
|
||||
`pyenv versions`
|
||||
- Switching versions
|
||||
`pyenv global 2.7.15`
|
||||
|
||||
Loading…
Reference in a new issue