在Pydroid上更改VPython中的按钮大小

huangapple go评论91阅读模式
英文:

Change button size in vpython on Pydroid

问题

我在Pydroid中有以下代码。它在Android上用Python创建3D文本。我需要将按钮变大。

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")

button(bind=capture_scene, text='Download')

asyncio.get_event_loop().run_forever()
英文:

I have the following code in Pydroid. I creates 3D text in Python on Android. I need to make the button bigger.

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")

button(bind=capture_scene, text='Download')

asyncio.get_event_loop().run_forever()

答案1

得分: 0

这是对我有效的方法。不是尝试更改按钮及其字体,我发现我可以在按钮文本中注入HTML。

button(bind=capture_scene, text="""<span style="font-size: 63px;"><h1 style="display: inline-block; margin:0; padding:23px;">下载</h1></span>""")
英文:

This is what worked for me. Instead of trying to change the button and its font. I discovered that I could inject html in the button text.

button(bind=capture_scene, text=&quot;&quot;&quot;&lt;span style=&quot;font-size: 63px;&quot;&gt;&lt;h1 style=&quot;display: inline-block;margin:0;padding:23px;&quot;&gt;Download&lt;/h1&gt;&lt;/span&gt;&quot;&quot;&quot;)

huangapple
  • 本文由 发表于 2023年5月21日 21:19:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76300103.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定