Skip to content

fanyuuu2006/GUI-simplify-Tkinter-Pygame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

簡介 | Introduction

此項目提供了一個基於 Python 的應用程序,包含以下功能:

This project provides a Python-based application with the following features:

  1. Base64 資源編碼器 (yieldb64.py):將圖片與音訊檔案轉換為 Base64 格式,並生成可直採導入的 Python 字典。 Base64 Asset Encoder (yieldb64.py): Converts image and audio files into Base64 format and generates Python dictionaries for direct import.
  2. 圖形用戶界面管理器:使用 TkinterPygame 提供 GUI 控制功能。 Graphical User Interface (GUI) Manager: Provides GUI control features using Tkinter and Pygame.

項目包含兩個主要檔案: The project includes two main files:

  • yieldb64.py: 資源編碼器,處理圖片與音訊。 yieldb64.py: An asset encoder that processes images and audio.
  • __init__.py: GUI 管理程序,負責視窗、按鈕及音效控制。 __init__.py: A GUI manager responsible for window, button, and sound control.

功能特色 | Features

1. Base64 資源編碼器 (yieldb64.py) | Base64 Asset Encoder (yieldb64.py)

  • 自動檢測 ./Asset 資料夾中的圖片與音訊檔案。 Automatically detects image and audio files in the ./Asset directory.
  • 支援的圖片格式:.jpg, .png, .ico 。 Supported image formats: .jpg, .png, .ico.
  • 支援的音訊格式:.wav 。 Supported audio format: .wav.
  • 生成的 Base64 資源檔分別儲存於: Generated Base64 asset files are stored in:
    • imageb64.py (圖片字典 | Image dictionary)
    • soundb64.py (音訊字典 | Audio dictionary)

2. 圖形用戶界面管理器 | Graphical User Interface Manager

  • 視窗管理 | Window Management:

    • 設置視窗大小與標題。 Sets window size and title.
    • 支援視窗圖標設定與臨時檔案管理。 Supports window icon setting and temporary file management.
  • 畫庫與框架 | Canvas and Frame:

    • 提供多畫庫、多框架切換功能。 Provides multi-canvas and multi-frame switching functionality.
  • 按鈕與文字輸入 | Buttons and Text Input:

    • 支援圖片與文字按鈕。 Supports image and text buttons.
    • 提供文字輸入框管理。 Provides text input box management.
  • 圖片與文字操作 | Image and Text Operations:

    • 圖片載入、更新。 Loads and updates images.
    • 文字添加與更新。 Adds and updates text.
  • 音效與音樂控制 | Sound and Music Control:

    • 解碼並播放 Base64 編碼的音效與音樂。 Decodes and plays Base64-encoded sound effects and music.
    • 支援音效與背景音樂切換與控制。 Supports switching and controlling sound effects and background music.

環境需求 | Requirements

  • Python 3.8+
  • 必須庫 | Required Libraries:
    • tkinter (標準庫,用於 GUI 開發 | Standard library for GUI development)
    • Pillow (用於圖像處理 | For image processing)
    • pygame (用於音訊播放 | For audio playback)

安裝 | Installation

  1. 複製此儲存庫: Clone this repository:

    git clone https://github.com/Yorn90104/GUI-simplify-Tkinter-Pygame-.git
  2. 安裝依賴項: Install dependencies:

    pip install pygame pillow

使用範例 | Usage Examples

1. Base64 資源編碼器 (yieldb64.py) | Base64 Asset Encoder (yieldb64.py)

將圖片與音訊轉換為 Base64 格式: Convert images and audio into Base64 format:

  1. .jpg, .png, .ico, 或 .wav 檔案放入 ./Asset 資料夾。 Place .jpg, .png, .ico, or .wav files into the ./Asset folder.

  2. 執行 yieldb64.py: Run yieldb64.py:

    python yieldb64.py
  3. 檢查生成的 Base64 字典檔: Check the generated Base64 dictionary files:

    • 圖片的 Base64 字典:./src/imageb64.py Image Base64 dictionary: ./src/imageb64.py
    • 音訊的 Base64 字典:./src/soundb64.py Audio Base64 dictionary: ./src/soundb64.py

2. 圖形用戶界面管理器 | Graphical User Interface Manager

設置簡單 GUI 應用: Set up a simple GUI application:

  1. 將此資料夾匯入與主要執行程式 (main.py) 同資料夾,將 GUI-simplify-Tkinter-Pygame 與從 yield.b64src 資料夾下產生的 imageb64.pyimageb64.py 共同導入 Place this folder in the same directory as the main execution program (main.py). Import the GUI-simplify-Tkinter-Pygame module along with the imageb64.py and soundb64.py files, which are generated by yield.b64 and located in the src folder.

    from GUI-simplify-Tkinter-Pygame import Window, Picture, Audio
    from src.imageb64 import image_dict
    from src.soundb64 import wav_dict
    
    win = Window("Example", 300, 300)
    
    win.setup_frame_and_canvas("Main") # Main Screen
    win.add_text(
       "Main",
       "Hello, World!",
       150, 150,
       16,
       "#000000",
       "HelloWorld"
    )
    win.first_window("Main")
    win.mainloop()
  2. 保存檔案並執行: Save the file and execute:

    python main.py
  3. 你將看到一個簡單的 GUI,顯示文字「Hello, World!」。 You will see a simple GUI displaying the text "Hello, World!".


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages