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
Metadata
Release files for tkinterandcss 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tkinterandcss-0.1.0.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tkinterandcss-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / tkinterandcss-0.1.0.tar.gz
| Download URL | tkinterandcss-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c052bf4ca4e3b33769c561ec56ff17891d1118f3c71bdf6d0e6516cbb360108
|
|
BLAKE2b-256 checksum How to use checksums |
d1400027395f1fa229ae5ffd9f4cf572b8523a5faa5c87d99234fc27e071c214
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / tkinterandcss-0.1.0-py3-none-any.whl
| Download URL | tkinterandcss-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0955a896d82d24414b5f498b57eb2e578842ac8798518350ec141c7019254953
|
|
BLAKE2b-256 checksum How to use checksums |
56fcf6ce36bef61514f1d57c8a01e88084f10edd49ae952ea2f7a485c8fc0811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|