appunti3s:modulo_python
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
appunti3s:modulo_python [2020/07/13 21:03] – [Usare un Modulo] profpro | appunti3s:modulo_python [2020/07/29 18:38] (current) – profpro | ||
---|---|---|---|
Line 1: | Line 1: | ||
< [[appunti3s: | < [[appunti3s: | ||
+ | |||
+ | ==== Installare un modulo ==== | ||
+ | |||
+ | apt update | ||
+ | apt install python-tk | ||
====Usare un Modulo==== | ====Usare un Modulo==== | ||
Line 11: | Line 16: | ||
Quando si fa //import Tkinter// viene cercato un file Tkinter.py dentro qualche cartella (si veda // | Quando si fa //import Tkinter// viene cercato un file Tkinter.py dentro qualche cartella (si veda // | ||
- | Per mostrare gli attributi | + | Si potrebbe ottenere una semplificazione del codice scrivendo |
+ | |||
+ | >>> | ||
+ | >>> | ||
+ | |||
+ | Tuttavia è rischioso perché unisce il namespace di un modulo con quello attuale e rischia di avere omonimie. | ||
+ | |||
+ | Per mostrare gli attributi | ||
>>> | >>> | ||
Line 19: | Line 31: | ||
Dato che un modulo da importare non è altro che un file.py, è facile crearne uno | Dato che un modulo da importare non è altro che un file.py, è facile crearne uno | ||
- | miomodulo.py | + | miomodulo.py |
<file python miomodulo.py> | <file python miomodulo.py> | ||
Line 40: | Line 52: | ||
Come in linguaggio C, anche in Python, in alto si definiscono le funzioni e poi si eseguono le eventuali istruzioni | Come in linguaggio C, anche in Python, in alto si definiscono le funzioni e poi si eseguono le eventuali istruzioni | ||
+ | |||
+ | |||
+ | |||
+ | ===Approfondimento su python-tk=== | ||
+ | |||
+ | Installando python-tk diventa disponibile una interfaccia per usare Tk . Infatti **Tk inter** sta per interfaccia | ||
+ | |||
+ | https:// | ||
+ | |||
+ | Tk is a cross-platform graphical toolkit | ||
+ | |||
+ | |||
+ | |||
+ | Tk non fa parte di python, per questo è necessaria un' | ||
+ | |||
+ | |||
+ |
appunti3s/modulo_python.1594667014.txt.gz · Last modified: 2020/07/13 21:03 by profpro