I am building small android project with beeware..and recently found that beeware toga GUI toolkit does not support images/imageview in android is there any tweak or other method which I can used to add image in my android project. I found one called toga-android but there is no guide. any help will be very help full to me thank you.
here is my small code snippet.
"""
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()
I could successfully launch an early test app I'm (re)building with BeeWare/Toga on an emulator and an amazon-HD-10 tablet using this list of imports:
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...
Maybe you forgot a crucial import?
There are 2 overlapping pics of briefcase's SDK emulator on the left side of the screenshot below.
(To make ImageViews "clickable" I had to use a pull request fork that's NOT merged into Toga yet -- and possibly never will...)
(Here's a link to my github discussion about Toga's ImageView. Smaller pics to the right are from a JS version, originally made for a Sony-PRS 500 eBook reader, 16 shades of grey)
. . . Youtube video of advanced WORKING APP in emulator
===============================================