Thư viện để áp dụng CSS cho widget Tkinter.
Project description
tkinterandcss
Thư viện tkinterandcss cho phép bạn áp dụng các style CSS cho widget Tkinter, giúp việc tạo giao diện dễ dàng hơn.
Cài đặt
Để cài đặt thư viện, hãy clone kho lưu trữ này và sử dụng pip:
git clone https://github.com/hqmdokkai/tkinterandcss.git cd tkinterandcss pip install .
Cách sử dụng Dưới đây là cách sử dụng thư viện:
Tạo file CSS: Tạo một file style.css với nội dung như sau:
.button-primary { background-color: red; color: white; font-size: 16px; font-family: Arial; font-weight: bold; padding: 10px 20px; width: 150px; height: 50px; text-align: center; border: 2px solid black; } Tạo ứng dụng Tkinter: Tạo file Python (example.py) và thêm mã sau:
import tkinter as tk from tkinterandcss import CssParser
if name == "main": root = tk.Tk() root.geometry("400x300")
css_parser = CssParser()
css_parser.parse_file('style.css')
button = tk.Button(root, text="Click Me")
css_parser.apply_style(button, '.button-primary')
button.pack(pady=20)
root.mainloop()
Chạy ứng dụng: Chạy file main.py để xem giao diện với các style đã áp dụng.
Các thuộc tính hỗ trợ Thư viện hỗ trợ một số thuộc tính CSS phổ biến:
background-color color font-size font-family font-weight padding width height text-align border Ghi chú Thư viện này hỗ trợ các giá trị màu như tên màu CSS và mã hex. Hãy đảm bảo rằng bạn đang sử dụng Python 3.6 trở lên. Liên hệ Nếu bạn có bất kỳ câu hỏi nào, hãy liên hệ với tôi qua email: akirasumeragi699@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkinterandcss-0.1.0.tar.gz.
File metadata
- Download URL: tkinterandcss-0.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c052bf4ca4e3b33769c561ec56ff17891d1118f3c71bdf6d0e6516cbb360108
|
|
| MD5 |
7667d3509ab48c06e86a7600c5eb0896
|
|
| BLAKE2b-256 |
d1400027395f1fa229ae5ffd9f4cf572b8523a5faa5c87d99234fc27e071c214
|
File details
Details for the file tkinterandcss-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tkinterandcss-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0955a896d82d24414b5f498b57eb2e578842ac8798518350ec141c7019254953
|
|
| MD5 |
05acd9971fa6fa76cfc936cba8e03049
|
|
| BLAKE2b-256 |
56fcf6ce36bef61514f1d57c8a01e88084f10edd49ae952ea2f7a485c8fc0811
|