You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Pydroid的VPython代码中调整按钮尺寸

调整VPython中按钮的尺寸

在VPython里,button()函数支持通过width和height参数直接设置按钮的尺寸,同时搭配font_size调整按钮文字大小,能让按钮整体显示更协调。修改后的代码如下:

import asyncio
from vpython import *

scene = canvas()

scene.width = 1600
scene.height = 1600

text(text = "Hello World", align = "center")

def capture_scene():
    img = scene.capture("image")

# 添加width、height和font_size参数调整按钮尺寸与文字匹配度
button(bind=capture_scene, text='Download', width=150, height=50, font_size=20)

asyncio.get_event_loop().run_forever()
  • width和height以像素为单位定义按钮宽高,可根据Android屏幕实际情况修改数值
  • font_size用于放大按钮文字,避免按钮尺寸增大后文字显得过小

内容的提问来源于stack exchange,提问作者Hassan Voyeau

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 05:42:09