A growing collection of tools: a Textual-based menu shell and an inline questionary-based network adapter picker.
Project description
xiepengcheng
Python 工具集合,目前包含:
MenuApp:基于 Textual 的全屏终端菜单外壳,菜单项由外部传入select_network_adapter:基于 questionary 的内联(非全屏)网络适配器选择器(仅支持 Windows)
pip install xiepengcheng
网络适配器选择
import xiepengcheng
adapter = xiepengcheng.select_network_adapter()
if adapter:
print(adapter.name, adapter.ip_addresses, adapter.mac_address, adapter.is_up)
也可以跳过交互,直接拿列表自己处理:
from xiepengcheng import list_network_adapters
for a in list_network_adapters():
print(a.name, a.description, a.mac_address, a.ip_addresses, a.status)
NetworkAdapter 字段:id(系统级标识符,程序里应该用它而不是 name 来指定网卡)、name、description、mac_address、ip_addresses、status、speed,以及派生属性 is_up。
全屏菜单(MenuApp)
菜单项可以是 MenuItem 对象,也可以是内置菜单的名称字符串(目前内置:"网络适配器选择"):
import xiepengcheng
# 空菜单
xiepengcheng.MenuApp().run()
# 外部传入菜单项
items = [
xiepengcheng.MenuItem(label="功能 A", description="这里是功能 A 的详情"),
xiepengcheng.MenuItem(label="功能 B", action=lambda: print("执行功能 B")),
"网络适配器选择",
]
result = xiepengcheng.MenuApp(items=items, title="我的工具").run()
交互方式:上下箭头选择,回车进入子菜单/详情/直接返回结果,Esc 或再次回车返回上一级,q 退出。
Project details
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 xiepengcheng-0.4.0.tar.gz.
File metadata
- Download URL: xiepengcheng-0.4.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97a847d6f0bc7060c9c3bee47c536a5626c01209342f51c7f68dca4e96005c62
|
|
| MD5 |
ab0f9a87d804517807edfde14baf4b05
|
|
| BLAKE2b-256 |
92dfcba4df8586cc967a8868ce9e8e50e571c2d108b1d112965bb1d1da4c51ff
|
File details
Details for the file xiepengcheng-0.4.0-py3-none-any.whl.
File metadata
- Download URL: xiepengcheng-0.4.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3615a34c7ad4ea9c9875471b3c3e957810fea458c8448752a1efe58c3382d33b
|
|
| MD5 |
99c71369faf203e470ba4aa4b6328722
|
|
| BLAKE2b-256 |
2ff6ef0c5c31c37ea3bfd37401d8dc2a939ed041d69e53fbd676cbe2e2bfa6e6
|