Spaces:
No application file
No application file
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
# 1. 模拟 Windows 窗口配置
|
| 5 |
+
st.set_page_config(
|
| 6 |
+
page_title="Windows 模拟器",
|
| 7 |
+
page_icon="💻",
|
| 8 |
+
layout="wide"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
# 2. 自定义 CSS 增强“软件感” (隐藏网页元素)
|
| 12 |
+
st.markdown("""
|
| 13 |
+
<style>
|
| 14 |
+
#MainMenu {visibility: hidden;}
|
| 15 |
+
footer {visibility: hidden;}
|
| 16 |
+
header {visibility: hidden;}
|
| 17 |
+
.stApp {background-color: #f0f2f6;}
|
| 18 |
+
</style>
|
| 19 |
+
""", unsafe_allow_html=True)
|
| 20 |
+
|
| 21 |
+
# 3. 模拟左侧“开始菜单/侧边栏”
|
| 22 |
+
with st.sidebar:
|
| 23 |
+
st.title("📁 我的电脑")
|
| 24 |
+
menu = st.radio(
|
| 25 |
+
"导航菜单",
|
| 26 |
+
["桌面首页", "控制面板", "文件管理器", "运行命令"],
|
| 27 |
+
index=0
|
| 28 |
+
)
|
| 29 |
+
st.divider()
|
| 30 |
+
st.info("系统状态: 运行中")
|
| 31 |
+
|
| 32 |
+
# 4. 根据选择渲染不同的“窗口”内容
|
| 33 |
+
if menu == "桌面首页":
|
| 34 |
+
st.title("📺 欢迎使用 Python 桌面")
|
| 35 |
+
st.write("这是一个运行在 Hugging Face 上的 Python 模拟界面。")
|
| 36 |
+
|
| 37 |
+
col1, col2 = st.columns(2)
|
| 38 |
+
with col1:
|
| 39 |
+
with st.expander("📝 记事本", expanded=True):
|
| 40 |
+
note = st.text_area("在此输入笔记...", "Hello World!")
|
| 41 |
+
if st.button("保存文件"):
|
| 42 |
+
st.toast("文件已成功保存到虚拟磁盘!")
|
| 43 |
+
|
| 44 |
+
with col2:
|
| 45 |
+
with st.expander("📊 性能监控", expanded=True):
|
| 46 |
+
st.write("CPU 使用率")
|
| 47 |
+
st.progress(45)
|
| 48 |
+
st.write("内存占用")
|
| 49 |
+
st.progress(62)
|
| 50 |
+
|
| 51 |
+
elif menu == "控制面板":
|
| 52 |
+
st.subheader("⚙️ 系统设置")
|
| 53 |
+
theme = st.selectbox("选择界面主题", ["Windows Classic", "Dark Mode", "Fluent Design"])
|
| 54 |
+
volume = st.slider("系统音量", 0, 100, 50)
|
| 55 |
+
st.toggle("开启自动更新")
|
| 56 |
+
|
| 57 |
+
elif menu == "文件管理器":
|
| 58 |
+
st.subheader("📂 磁盘路径: C:/Users/Admin/Documents")
|
| 59 |
+
files = {
|
| 60 |
+
"文件名": ["report.pdf", "photo.jpg", "app.py", "data.csv"],
|
| 61 |
+
"大小": ["1.2MB", "4.5MB", "2KB", "150KB"],
|
| 62 |
+
"修改日期": ["2024-01-01", "2024-02-15", "2024-03-20", "2024-04-18"]
|
| 63 |
+
}
|
| 64 |
+
st.table(files)
|
| 65 |
+
|
| 66 |
+
elif menu == "运行命令":
|
| 67 |
+
st.subheader("💻 命令提示符 (CMD)")
|
| 68 |
+
cmd = st.text_input("C:\Users\Admin>", "")
|
| 69 |
+
if cmd:
|
| 70 |
+
with st.status("正在执行命令...", expanded=True):
|
| 71 |
+
time.sleep(1)
|
| 72 |
+
st.write(f"正在检索: {cmd}")
|
| 73 |
+
time.sleep(0.5)
|
| 74 |
+
st.code(f"Error: '{cmd}' 并非内部或外部命令,也不是可运行的程序。")
|