Python

Python Flet Framework

This section introduces the Flet framework, which allows building desktop, web, and smartphone applications with Python.

이 섹션에서는 Python으로 데스크톱, 웹, 스마트폰 애플리케이션을 구축할 수 있는 Flet 프레임워크를 소개합니다. Flet is based on Flutter, making its syntax similar and potentially easing the learning curve for Flutter. Flet은 Flutter를 기반으로 하여 구문이 유사하고 Flutter 학습 곡선을 완화할 수 있습니다.

Installation

Flet can be installed using Poetry with the command:

Flet은 Poetry를 사용하여 다음 명령으로 설치할 수 있습니다.

poetry add flet

Basic Example

A basic counter example from the official Flet documentation is provided, demonstrating how to create a simple application with a counter that can be incremented and decremented.

공식 Flet 문서의 기본 카운터 예제가 제공되어 카운터를 증가 및 감소시킬 수 있는 간단한 애플리케이션을 만드는 방법을 보여줍니다.

Running the Program

The program can be run as a desktop application using flet run counter.py.

프로그램은 flet run counter.py를 사용하여 데스크톱 애플리케이션으로 실행할 수 있습니다. For web execution, a modification is needed: 웹 실행을 위해서는 수정이 필요합니다.

ft.app(main, view=ft.AppView.WEB_BROWSER)

This allows the application to be run directly in a web browser.

이를 통해 애플리케이션을 웹 브라우저에서 직접 실행할 수 있습니다.

Learning Resources

The official Flet tutorials are recommended for further learning.

공식 Flet 튜토리얼은 추가 학습을 위해 권장됩니다.

Python Package Managers: pip vs Poetry

This section compares Python package managers, focusing on pip, Poetry 1.8, and Poetry 2.1.

이 섹션에서는 Python 패키지 관리자를 비교하며 pip, Poetry 1.8 및 Poetry 2.1에 중점을 둡니다. It highlights the differences in virtual environment management, dependency management, and Python version management. 가상 환경 관리, 종속성 관리 및 Python 버전 관리의 차이점을 강조합니다.

Key Features

FeaturepipPoetry 1.8Poetry 2.1
Virtual Environment ManagementManualAutomaticAutomatic
Dependency Lock Filerequirements.txt (manual)poetry.lockpoetry.lock
Python Version ManagementNoNoExperimental

Basic Poetry Usage

  • Installing Poetry: pip install poetry

    Poetry 설치: pip install poetry

  • Creating a new project: poetry new myproject or poetry init

    새 프로젝트 생성: poetry new myproject 또는 poetry init

  • Adding packages: poetry add package_name

    패키지 추가: poetry add package_name

  • Activating the virtual environment: poetry shell

    가상 환경 활성화: poetry shell

  • Installing dependencies: poetry install

    종속성 설치: poetry install

Install PyCharm on Windows

This section guides through installing Python and PyCharm on Windows, recommending Python 3.11 for stability.

이 섹션에서는 Windows에 Python 및 PyCharm을 설치하는 방법을 안내하며 안정성을 위해 Python 3.11을 권장합니다.

Installation Steps

  1. Download and install Python, ensuring “Add python.exe to PATH” is checked.

    Python을 다운로드하여 설치하고 “Add python.exe to PATH”가 선택되어 있는지 확인합니다.

  2. Set up environment variables to easily use Python from the command line.

    명령줄에서 Python을 쉽게 사용할 수 있도록 환경 변수를 설정합니다.

  3. Download and install PyCharm Community Edition.

    PyCharm Community Edition을 다운로드하여 설치합니다.

Environment Variables

Setting up environment variables allows running Python commands from any terminal.

환경 변수를 설정하면 모든 터미널에서 Python 명령을 실행할 수 있습니다. The necessary paths to add are: 추가해야 할 필수 경로는 다음과 같습니다.

  • Python설치경로\Python311
  • Python설치경로\Python311\Scripts

Python Virtual Environment Management

This section explains how to manage Python virtual environments using PyCharm, venv, uv, and pyenv.

이 섹션에서는 PyCharm, venv, uvpyenv를 사용하여 Python 가상 환경을 관리하는 방법을 설명합니다. Virtual environments isolate project dependencies, preventing conflicts. 가상 환경은 프로젝트 종속성을 격리하여 충돌을 방지합니다.

Virtual Environment Management in PyCharm

PyCharm simplifies virtual environment management with a GUI.

PyCharm은 GUI를 통해 가상 환경 관리를 단순화합니다.

  1. Create a project folder.

    프로젝트 폴더를 만듭니다.

  2. Create a virtual environment and interpreter via File > Settings > Project > Python Interpreter.

    파일 > 설정 > 프로젝트 > Python 인터프리터를 통해 가상 환경 및 인터프리터를 만듭니다.

  3. Verify the setup by opening the Terminal within PyCharm.

    PyCharm 내에서 터미널을 열어 설정을 확인합니다.

Command Line Virtual Environment Management

  • Using venv:

    venv 사용:

    python -m venv venv
    venvScriptsactivate   # Windows
    source venv/bin/activate  # macOS/Linux
    ```
  • Using uv for faster dependency management.

    uv를 사용하여 더 빠른 종속성 관리.

  • Using pyenv for Python version management.

    pyenv를 사용하여 Python 버전 관리.

Related Pages

© 2024 Coding Stairs. All rights reserved.