首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >beeware将toga图像视图添加到android中

beeware将toga图像视图添加到android中
EN

Stack Overflow用户
提问于 2021-01-06 13:51:15
回答 1查看 697关注 0票数 3

我正在用beeware..and构建小型安卓项目,最近发现beeware..and工具包不支持android中的图像/图像视图,我可以使用任何修改或其他方法在我的android项目中添加图像。我找到了一个叫toga的机器人,但是没有向导。任何帮助都会对我有很大的帮助,谢谢。

这是我的小代码片段。

代码语言:javascript
运行
复制
"""
Time Table app for salah 
"""
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW

class drd(toga.App):

    
    def startup(self):
        """
        Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """
        
        self.main_box = toga.Box(style=Pack(direction=COLUMN))

        self.l_username = toga.TextInput(placeholder='User name',style=Pack(flex=1))
        self.l_password = toga.TextInput(placeholder='Password',style=Pack(flex=1))
        
        self.checkbutton = toga.Button('Log in',on_press=self.login_btn,style=Pack(padding=5))
        
        self.label_box = toga.Box(style=Pack(direction=ROW,padding=5))
        self.main_box.add(self.label_box)
        self.label_box.add(self.l_username)
        self.main_box.add(self.l_password)
        self.main_box.add(self.checkbutton)
        
        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = self.main_box
        self.main_window.show()
        
    def signup_btn(self,button):
        self.main_window.info_dialog("hi there","Hello {}".format(self.name_input.value))

    def login_btn(self,button):
        if self.l_username.value == "Imtiyaz" and self.l_password.value == "123":
            self.home()

        else:
            self.main_window.info_dialog("User name or Password is incorrect!")
            self.home()

    def home(self):
        self.main_box = toga.Box(style=Pack(direction=COLUMN, background_color='#7ed6c6'))
        self.hello = toga.Label('Hello there!')
        self.img = toga.ImageView(id='images',image='./resources/drd.png')
        self.main_box.add(self.hello)
        self.main_box.add(self.img)
        self.main_window = toga.MainWindow(title="app")
        self.main_window.content = self.main_box
        self.main_window.show()

def main():
    return drd()
EN

Stack Overflow用户

回答已采纳

发布于 2021-12-12 10:23:25

我可以成功地在模拟器和amazon-HD-10平板电脑上用BeeWare/Toga构建一个早期测试应用程序I'm (Re),使用,这是的导入列表:

代码语言:javascript
运行
复制
import toga
from toga import App, Box, MainWindow
from toga import ImageView, Image
from toga.style import Pack
from toga.style.pack import COLUMN, ROW, BOTTOM, TOP, LEFT
import sys                 # <==  that one's just to exit() the app...

,也许你忘了一个重要的进口?

有两个重叠的照片公文包的SDK仿真器在左边的屏幕截图下面。

(为了使ImageViews“可点击”,我不得不使用尚未合并到Toga的拉请求叉-而且可能永远不会.)

(这是一个关于Toga's ImageView的链接到我的github讨论。右边较小的图片来自JS版本,最初是为Sony 500 eBook阅读器制作的,有16种灰色)

。。。https://www.youtube.com/watch?v=8PMUxJGSTpo

代码语言:javascript
运行
复制
 ===============================================

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65597025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档