Last active
March 27, 2020 02:39
-
-
Save RawrBear/eb5b523136b098f0c590dc4407c6ec2e to your computer and use it in GitHub Desktop.
An image viewer GUI built with Beeware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple test area for me to learn to use Beeware | |
""" | |
import toga | |
from toga.style import Pack | |
from toga.style.pack import COLUMN, ROW, CENTER | |
class TestGUI(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. | |
""" | |
main_box = toga.Box( | |
style=Pack( | |
direction=COLUMN, | |
width=500, | |
height=500 | |
) | |
) | |
top_area = toga.Box( | |
style=Pack( | |
direction=ROW, | |
padding=5, | |
) | |
) | |
main_box.add(top_area) | |
# Options for Category drop down list | |
categories = [ | |
'Landscape', | |
'Portrait', | |
'Sports', | |
'Animals', | |
'Plants' | |
] | |
category_list = toga.Selection( | |
items=categories, | |
style=Pack(padding=(0, 5)) | |
) | |
top_area.add(category_list) | |
search_input = toga.TextInput( | |
style=Pack(flex=1) | |
) | |
top_area.add(search_input) | |
# Image viewing box | |
middle_area = toga.Box( | |
style=Pack( | |
padding=(4, 4), | |
alignment=CENTER, | |
width=400, | |
height=400, | |
background_color='slateblue' | |
) | |
) | |
main_box.add(middle_area) | |
my_img = toga.Image('https://images.unsplash.com/photo-1562262516-df1e0b7efcb8?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80') | |
image_view = toga.ImageView( | |
image=(my_img), | |
style=Pack( | |
width=200, | |
height=200, | |
alignment=CENTER | |
) | |
) | |
middle_area.add(image_view) | |
self.main_window = toga.MainWindow(title=self.formal_name) | |
self.main_window.content = main_box | |
self.main_window.show() | |
def main(): | |
return TestGUI() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment