Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions .github/workflows/commit-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6

# - name: Install Rust Toolchain
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# override: true

- name: install rustup (Windows)
if: runner.os == 'Windows'
shell: pwsh
Expand Down Expand Up @@ -77,24 +71,21 @@ jobs:
- name: sync dep
run: uv sync --all-extras

# - name: build
# run: cargo build --release

- name: use build script
run: uv run build_script.py
run: uv run scripts/build_script.py

- name: zip files (Linux)
id: zip_files_linux
if: runner.os == 'Linux'
run: |
file=$(uv run ci/zip_files.py)
file=$(uv run scripts/ci/zip_files.py)
echo "zip_path=$file" >> $GITHUB_OUTPUT

- name: zip files (Windows)
id: zip_files_windows
if: runner.os == 'Windows'
run: |
$file = (uv run ci/zip_files.py)
$file = (uv run scripts/ci/zip_files.py)
echo "zip_path=$file" >> $env:GITHUB_OUTPUT

- name: Upload exe artifact (Linux)
Expand Down Expand Up @@ -123,11 +114,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Prepare CI Venv
run: |
cd ci
uv venv --python cpython-3.13
cd ..
# - name: Prepare CI Venv
# run: |
# cd ci
# uv venv --python cpython-3.13
# cd ..

- name: Download all artifacts
uses: actions/download-artifact@v8
Expand All @@ -137,17 +128,13 @@ jobs:
- name: Get datetime
id: get_datetime
run: |
cd ci
datetime=$(uv run get_datetime.py)
datetime=$(uv run scripts/ci/get_datetime.py)
echo "datetime=$datetime" >> $GITHUB_OUTPUT
cd ..

- name: Get package get_version
id: get_version
run: |
cd ci
version=$(uv run get_version.py)
cd ..
version=$(uv run scripts/ci/get_version.py)
echo "version=$version" >> $GITHUB_OUTPUT

- name: List Dir (for debug)
Expand Down
40 changes: 39 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
# authors = ["TW0hank0"]
# repository = "https://github.com/TW0hank0/positive_toolbox"

[workspace.package]
version = "0.1.0"
edition = "2024"
repository = "https://github.com/TW0hank0/positive_toolbox"
description = "面向使用者的工具"
license = "AGPL-3.0-only"
authors = ["TW0hank0"]
rust-version = "1.94"

[workspace.dependencies]
positive_toolbox = { path = "." }
ptb_shared = { path = "ptb_shared" }
Expand All @@ -47,15 +56,6 @@ iced = { version = "0.14.0", features = [
positive_tool_rs = { git = "https://github.com/TW0hank0/positive_tool_rs" }
open = "5.3.3"

[workspace.package]
version = "0.1.0"
edition = "2024"
repository = "https://github.com/TW0hank0/positive_toolbox"
description = "面向使用者的工具"
license = "AGPL-3.0-only"
authors = ["TW0hank0"]
rust-version = "1.94"

[workspace]
resolver = "3"
members = ["ptb_main", "ptb_shared", "ptb_tools"]
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# positive_toolbox

![icon](./icon.png)
![icon](./assets/icon.png)

**中文** | [English](./READMEs/README_en.md)

Expand Down Expand Up @@ -36,6 +36,8 @@ wasm-pack build --target web --out-dir ./pkg

第三方專案授權見:

- [ThirdPartyLicense-Rust.html](./ThirdPartyLicense-Rust.html)
- [ThirdPartyLicense-Rust.html](./auto_generated/ThirdPartyLicense-Rust.html)

- [ThirdPartyLicense-Python.html](./ThirdPartyLicense-Python.html)

- [ThirdPartyLicense-Rust.md](./auto_generated/ThirdPartyLicense-Rust.md)
39 changes: 0 additions & 39 deletions TODO.md

This file was deleted.

4 changes: 4 additions & 0 deletions change_logs/change_log_v0.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
- 主頁UI排版
- 檔案結構 (Members 獨立)
- INSTALL.md 移至README內

### 修復

- 第三方授權聲明
94 changes: 88 additions & 6 deletions ptb_launcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@


def main():
if (
hasattr(sys, "frozen") is True
and getattr(sys, "frozen") is True
) and (hasattr(sys, "_MEIPASS") is True):
if (hasattr(sys, "frozen") is True and getattr(sys, "frozen") is True) and (
hasattr(sys, "_MEIPASS") is True
):
main_exec_path = os.path.join(
os.path.dirname(sys.executable), "positive_toolbox"
)
file_base_path = os.path.dirname(sys.executable)
else:
print("這是為打包後檔案結構設計的", file=sys.stderr)
print("WARNING:這是為打包後檔案結構設計的", file=sys.stderr)
main_exec_path = os.path.join(
os.path.dirname(__file__), "positive_toolbox"
)
file_base_path = os.path.dirname(__file__)
if os.name == "nt":
main_exec_path = main_exec_path + ".exe"
#
print(main_exec_path)
file_err = open(
os.path.join(file_base_path, ".stderr.txt"),
Expand All @@ -61,8 +59,92 @@ def main():
)
if process.wait() != 0:
print("發生錯誤", file=sys.stderr)
process_stdout = str(
"無法取得stdout!"
if process.stdout.read().decode() is None # pyright: ignore[reportOptionalMemberAccess]
else process.stdout
)
process_stderr = str(
"無法取得stderr!"
if process.stderr.read().decode() is None # pyright: ignore[reportOptionalMemberAccess]
else process.stderr
)
show_error(process_stdout, process_stderr)
#
file_err.close()
file_out.close()
file_in.close()


def show_error(stdout: str, stderr: str):
import tkinter as tk
from tkinter import messagebox

class CopyableTextWindow:
def __init__(self, root: tk.Tk) -> None:
self.root: tk.Tk = root
self.text_content: str = "文字"
self.setup_ui()

def setup_ui(self) -> None:
self.root.title("positive_toolbox launcher - error-handler")
self.root.geometry("540x360")

# 建立文字標籤
self.label: tk.Label = tk.Label(
self.root,
text=self.text_content,
font=("Microsoft JhengHei", 12),
wraplength=300,
justify=tk.CENTER,
)
self.label.pack(pady=20)

# 建立按鈕框架
self.btn_frame: tk.Frame = tk.Frame(self.root)
self.btn_frame.pack()

# 建立複製按鈕
self.copy_btn: tk.Button = tk.Button(
self.btn_frame,
text="複製文字",
command=self.copy_to_clipboard,
width=10,
)
self.copy_btn.pack(side=tk.LEFT, padx=10)

# 建立關閉按鈕
self.close_btn: tk.Button = tk.Button(
self.btn_frame,
text="關閉視窗",
command=self.root.destroy,
width=10,
)
self.close_btn.pack(side=tk.LEFT, padx=10)

def copy_to_clipboard(self) -> None:
try:
self.root.clipboard_clear()
self.root.clipboard_append(self.text_content)
self.root.update() # 確保剪貼簿內容已更新
messagebox.showinfo("成功", "文字已複製到剪貼簿")
except Exception as e:
messagebox.showerror("錯誤", f"複製失敗:{str(e)}")

root: tk.Tk = tk.Tk()
# 設定 DPI 感知(針對高解析度螢幕)
try:
from ctypes import windll

windll.shcore.SetProcessDpiAwareness(1)
except Exception:
pass

app: CopyableTextWindow = CopyableTextWindow(root)
app.text_content = (
f"--- stdout --- \n{stdout} \n\n --- stderr --- \n {stderr}"
)
root.mainloop()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion ptb_launcher/ptb_launcher.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

a = Analysis(
[os.path.join('src', 'launcher', 'main.py')],
['main.py'],
pathex=[],
binaries=[],
datas=[],
Expand Down
1 change: 1 addition & 0 deletions ptb_main/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub fn wasm_start() -> iced::Result {
}

pub fn main() -> iced::Result {
//
let (icon,) = shared::init();
log::info!("已設定logger。");
//
Expand Down
3 changes: 3 additions & 0 deletions ptb_shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pub mod languages;
pub mod shared;

pub mod licenses_python;
pub mod licenses_rust;
File renamed without changes.
Loading
Loading