Esempio n. 1
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)

        box = toga.Box()
        box.style.padding = 40
        box.style.update(alignment=CENTER)
        box.style.update(direction=COLUMN)

        # image from local path
        # load brutus.png from the package
        # We set the style width/height parameters for this one
        image_from_path = toga.Image('../resources/brutus.png')
        imageview_from_path = toga.ImageView(image_from_path)
        imageview_from_path.style.update(height=72)
        imageview_from_path.style.update(width=72)
        box.add(imageview_from_path)

        # image from remote URL
        # no style parameters - we let Pack determine how to allocate
        # the space
        image_from_url = toga.Image(
            'https://beeware.org/project/projects/libraries/toga/toga.png')
        imageview_from_url = toga.ImageView(image_from_url)
        box.add(imageview_from_url)

        self.main_window.content = box
        self.main_window.show()
Esempio n. 2
0
def build(app):
    img_01 = toga.Image(path='icons/brutus-256.png')
    img_02 = toga.Image(
        path='https://dict.leo.org/img/leo/160x60/schriftzug-222990a1.png')

    image_view_01 = toga.ImageView(image=img_01)
    image_view_02 = toga.ImageView(image=img_02)
    box = toga.Box(style=CSS(flex=1))
    box.add(image_view_01)
    box.add(image_view_02)
    return box
Esempio n. 3
0
 def __init__(self):
     """Initialize box."""
     logo_path = Path(__file__).parent.parent / "resources" / "eddington_gui.png"
     logo = toga.Image(str(logo_path))
     super(HeaderBox, self).__init__(
         alignment=TOP,
         children=[
             toga.Label(
                 text=f"Version: {__version__}",
                 style=Pack(
                     font_size=SMALL_FONT_SIZE, font_family=HEADER_FONT_FAMILY
                 ),
             ),
             toga.Box(style=Pack(flex=1)),
             toga.ImageView(
                 image=logo, style=Pack(height=LOGO_SIZE, width=LOGO_SIZE)
             ),
             toga.Box(style=Pack(flex=1)),
             toga.Label(
                 text=f"Author: {__author__}",
                 style=Pack(
                     font_size=SMALL_FONT_SIZE, font_family=HEADER_FONT_FAMILY
                 ),
             ),
         ],
     )
Esempio n. 4
0
    def setupGUI(self):
        self.playerMatBG = toga.Image(path='resources/playmat.png')
        self.playerBagImage = toga.Image(path='resources/user.png')
        self.playerMatContainer = toga.ImageView(self.playerMatBG,
                                                 style=Pack(padding=0))
        self.playerBagContainer = toga.ImageView(self.playerBagImage,
                                                 style=Pack(padding=0,
                                                            width=25,
                                                            height=50))

        self.boxBasicDies = toga.Box(style=Pack(flex=1, direction=ROW))
        self.boxPlayerMat = toga.Box(
            children=[self.playerBagContainer, self.playerMatContainer],
            style=Pack(flex=1, direction=ROW, background_color=RED))
        self.main_window.content = toga.Box(children=[self.boxPlayerMat],
                                            style=Pack(direction=COLUMN))
Esempio n. 5
0
    def startup(self):
        # Controls

        self.index_stats_label = toga.Label('No tracks loaded, please index.',
                                            style=Pack(padding=10))

        self.reindex_button = toga.Button('Index Collection',
                                          on_press=self.re_index)
        self.reindex_button.style.padding = 10
        self.reindex_button.style.flex = 1

        self.mock_switch = toga.Switch('Enable mock Sender',
                                       on_toggle=self.mock_switch_handler)
        self.mock_switch.style.padding = 10
        self.mock_switch.style.flex = 1

        top_box = toga.Box(style=Pack(direction=ROW),
                           children=[self.reindex_button, self.mock_switch])

        # Cover Art Image Preview

        self.img = toga.Image(os.getcwd() + "/resources/testcard720.png")
        self.img_view = toga.ImageView(id='img_view',
                                       image=self.img,
                                       style=Pack(flex=1))

        self.img_label = toga.Label('Waiting for mock information...',
                                    style=Pack(padding=10))

        bottom_box = toga.Box(children=[self.img_label, self.img_view],
                              style=Pack(flex=1, direction=COLUMN))

        main_box = toga.Box(
            style=Pack(direction=COLUMN),
            children=[self.index_stats_label, top_box, bottom_box])

        self.main_window = toga.MainWindow(title=self.name, size=(400, 500))
        self.main_window.content = main_box
        self.main_window.show()

        self.cache_file = os.getcwd() + "/tracks.p"

        self.mapping = {
            "A": {
                "play": False,
                "updated_at": 0
            },
            "B": {
                "play": False,
                "updated_at": 0
            },
            "C": {
                "play": False,
                "updated_at": 0
            },
            "D": {
                "play": False,
                "updated_at": 0
            }
        }
Esempio n. 6
0
    def startup(self):
        # Create a main window with a name matching the app
        self.main_window = toga.MainWindow(self.name)

        self.input = toga.TextInput(style=Pack(flex=1))
        self.avatar_type = toga.Selection(items=sorted(AVATAR_TYPES.keys()),
                                          style=Pack(padding_left=10),
                                          on_select=self.generate)
        self.button = toga.Button('Go!',
                                  style=Pack(padding_left=10),
                                  on_press=self.generate)

        input_box = toga.Box(
            children=[self.input, self.avatar_type, self.button],
            style=Pack(direction=ROW, padding=10, alignment=CENTER))

        self.avatar = toga.ImageView()

        # Create a main content box
        main_box = toga.Box(children=[input_box, self.avatar],
                            style=Pack(direction=COLUMN))

        # Add the content on the main window
        self.main_window.content = main_box

        # Show the main window
        self.main_window.show()
Esempio n. 7
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(660, 520))
        self.ScrollContainer = toga.ScrollContainer()

        main_box = toga.Box()
        plot_box = toga.Box()

        main_box.style.padding = 10
        main_box.style.update(alignment=CENTER)
        main_box.style.update(direction=COLUMN)

        button = toga.Button('Play',
                             on_press=self.playback,
                             style=Pack(width=100))

        GenerateSpectrum(self.filename)
        image_from_path = toga.Image('Figure_temp.png')
        imageview_from_path = toga.ImageView(image_from_path)
        imageview_from_path.style.update(height=480)
        imageview_from_path.style.update(width=640)
        plot_box.add(imageview_from_path)

        main_box.add(button)
        main_box.add(plot_box)

        self.main_window.content = main_box

        self.main_window.show()
Esempio n. 8
0
    def results_pane(self):
        results_pane = toga.OptionContainer(style=Pack(width=280, padding_left=20))

        self.qr_image = toga.ImageView(id='qr', image=None, style=Pack(width=250, height=250, padding_bottom=10))
        
        self.save_qr_button = toga.Button('Save QR', on_press=self.save_qr ,style=Pack(alignment=CENTER, width=250))

        self.qr_box = toga.Box(
            children=[self.qr_image, self.save_qr_button],
            style=Pack(direction=COLUMN, padding=10, width=270)
            )
        results_pane.add('QR Code', self.qr_box)

        self.xmp_text = toga.MultilineTextInput(
            style=Pack(width=270, height=350, padding=5)
            )
        self.xmp_button = toga.Button(
            'Save XMP',
            on_press=self.save_xmp,
            style=Pack(width=250, alignment=CENTER)
            )
        self.xmp_box = toga.Box(
            children=[self.xmp_text, self.xmp_button],
            style=Pack(direction=COLUMN)
        )
        results_pane.add('XMP', self.xmp_box)
        return results_pane
Esempio n. 9
0
    def startup(self):
        self.word_input = toga.PasswordInput(style=Pack(flex=1, padding=5))
        self.new_game = toga.Button('New Game',
                                    on_press=self.new_game_handler,
                                    style=Pack(width=100, padding=5))
        self.give_up = toga.Button('Give Up',
                                   on_press=self.give_up_handler,
                                   style=Pack(width=100, padding=5))
        self.start = toga.Button('Start',
                                 on_press=self.start_game_handler,
                                 style=Pack(width=50, padding=5))
        self.buttons_box = toga.Box(children=[
            self.new_game, self.give_up, self.word_input, self.start
        ])
        self.buttons_box.remove(self.word_input)
        print(self.buttons_box.children)

        self.tree_image = toga.ImageView(toga.Image(IMAGES[0]))
        self.tree_image.style.update(height=400)
        self.tree_image.style.update(width=400)

        start_box = toga.Box(children=[self.tree_image, self.buttons_box])
        # start_box.add(tree_image)
        # start_box.add(buttons_box)
        start_box.style.update(direction=COLUMN)
        start_box.style.update(alignment=CENTER)

        self.main_window = toga.MainWindow(title=self.name)

        self.main_window.content = start_box
        self.main_window.show()
Esempio n. 10
0
    def setUp(self):
        super().setUp()
        # We need a test app to trigger app module discovery
        self.app = toga.App(
            formal_name="Test App",
            app_id="org.beeware.test-app",
            factory=toga_dummy.factory,
        )

        self.image_view = toga.ImageView(factory=toga_dummy.factory)
Esempio n. 11
0
    def get_about_window(self):
        """Return the "About" native window.

        This is a Toga window with the DativeTop icon and the versions of
        DativeTop, Dative and the OLD displayed.

        TODO: it would be nice if the text could be center-aligned underneath
        the DativeTop icon. Unfortunately, I found it difficult to do this
        using Toga's box model and ``Pack`` layout engine.
        """
        if self._about_window:
            return self._about_window
        dativetop_label = toga.Label('DativeTop {}'.format(
            dtutils.get_dativetop_version()))
        dative_label = toga.Label('Dative {}'.format(
            dtutils.get_dative_version()))
        old_label = toga.Label('OLD {}'.format(
            dtutils.get_old_version()))
        image_from_path = toga.Image(c.OLD_LOGO_PNG_PATH)
        logo = toga.ImageView(image_from_path)
        logo.style.update(height=72)
        logo.style.update(width=72)
        logo.style.update(direction=COLUMN)
        text_box = toga.Box(
            children=[
                dativetop_label,
                dative_label,
                old_label,
            ]
        )
        text_box.style.update(direction=COLUMN)
        text_box.style.update(alignment=CENTER)
        text_box.style.update(padding_left=20)
        text_box.style.update(padding_top=20)
        outer_box = toga.Box(
            children=[
                logo,
                text_box,
            ]
        )
        outer_box.style.update(direction=COLUMN)
        outer_box.style.update(alignment=CENTER)
        outer_box.style.update(padding=10)
        about_window = toga.Window(
            title=' ',
            id='about DativeTop window',
            minimizable=False,
            # resizeable = False,  # messes up layout
            size=(300, 150),
            position=(500, 200),
        )
        about_window.content = outer_box
        self._about_window = about_window
        return self._about_window
Esempio n. 12
0
 def __init__(self):
     """Initialize box."""
     logo_path = Path(
         __file__).parent.parent / "resources" / "eddington_gui.png"
     logo = toga.Image(str(logo_path))
     super().__init__(
         alignment=TOP,
         children=[
             toga.Box(style=Pack(flex=1)),
             toga.ImageView(
                 image=logo,
                 style=Pack(height=LOGO_SIZE,
                            width=LOGO_SIZE,
                            alignment=CENTER),
             ),
             toga.Box(style=Pack(flex=1)),
         ],
     )
Esempio n. 13
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(720, 580))
        self.ScrollContainer = toga.ScrollContainer()

        plot_box = toga.Box()

        button = toga.Button('Play',
                             on_press=self.playback,
                             style=Pack(width=100))

        GenerateSpectrum(self.filename)
        image_from_path = toga.Image('Figure_temp.png')
        imageview_from_path = toga.ImageView(image_from_path)
        imageview_from_path.style.update(height=480)
        imageview_from_path.style.update(width=640)
        plot_box.add(imageview_from_path)

        self.things = toga.Group('File')

        cmdOpen = toga.Command(self.actionOpenFileDialog,
                               label='Open',
                               tooltip='Open Audio File',
                               group=self.things)

        self.commands.add(cmdOpen)

        # Label to show responses.
        self.label = toga.Label('Ready.')

        # Outermost box
        outer_box = toga.Box(children=[self.label, button, plot_box],
                             style=Pack(flex=1,
                                        direction=COLUMN,
                                        alignment=CENTER,
                                        padding=10))

        # Add the content on the main window
        self.main_window.content = outer_box

        self.main_window.show()
Esempio n. 14
0
    def display_pics(self, final_characters):
        picture_box = toga.Box(style=Pack(direction=COLUMN))
        for i in range(1, 11):
            image_from_path = toga.Image('./resources/images/' + (
                final_characters[i - 1]['Name'].lower().replace(" ", "-") +
                ".jpg"))
            imageview_from_path = toga.ImageView(image_from_path,
                                                 style=Pack(direction=COLUMN,
                                                            alignment=CENTER,
                                                            padding=40,
                                                            width=150,
                                                            height=240,
                                                            flex=1))
            picture_box.add(imageview_from_path)

        if len(self.outer_box.children) > 3:
            self.outer_box.children[3] = picture_box
        else:
            self.outer_box.add(picture_box)

        self.scroller.content = self.outer_box
        self.main_window.show()
Esempio n. 15
0
def build(app):

    container = toga.OptionContainer()

    box1 = toga.Box()

    button = toga.Button('Hello world', on_press=button_handler)
    button.style.padding = 50
    button.style.flex = 1

    label = toga.NumberInput(min_value=10.5,
                             max_value=50.6,
                             on_change=lambda app: print(app.value))
    label.text = 'Hola Mundo'

    selection = toga.Selection(items=['Casella', 'Pedro Infante', 'Camilo'],
                               on_select=lambda app: print(app.value))
    selection.items = ['321', '123', '456', '654', '789', '987']

    box1.add(button)
    box1.add(label)
    box1.add(selection)

    box2 = toga.Box()

    image = toga.Image('../../static/images/tiberius.svg')
    imageview = toga.ImageView(image)

    slider = toga.Slider(range=(30, 50), on_slide=lambda app: print(app.value))

    box2.add(imageview)
    box2.add(slider)

    container.add('Window 1', box1)
    container.add('Window 2', box2)

    return container
Esempio n. 16
0
    def startup(self):
        """ Initialise the window """
        self.main_window = toga.MainWindow(
            title=self.name,
            size=(400,400)
        )

        self.scaleFactor = 0.3048

        logoImage = toga.Image('joke.png')
        logo = toga.ImageView(id='header', image=logoImage)
        headerBox = toga.Box(
            children=[logo],
            style=Pack(direction=ROW, padding=10, height=170)
        )

        # create input elements
        inputLabel = self.createLabel('Feet to Metres: ') # this never changes
        self.inputValue = self.createInput('feetVal', 'Feet...') # this does
        # create an array for the input elements
        inputElements = [inputLabel, self.inputValue]
        # package the input elements in a box
        inputBox = self.createBox(ROW, inputElements)

        # create action elements
        actionButton = self.createButton('CONVERT', self.convert)
        actionBox = self.createBox(ROW, [actionButton])

        self.result = self.createLabel('[Results]')
        resultBox = self.createBox(ROW, [self.result])

        # create main Box
        mainBox = self.createBox(COLUMN, [headerBox, inputBox, actionBox, resultBox])

        self.main_window.content = mainBox

        self.main_window.show()
Esempio n. 17
0
    def __init__(
        self,
        title: str = "Alert",
        message: str = "",
        button_labels: Iterable[str] = ("Ok",),
        default: str = "Ok",
        accessory_view: toga.Widget = toga.Box(),
        icon: toga.Icon | None = None,
        callback: Callable | None = None,
        app: toga.App | None = None,
    ):
        super().__init__(
            resizeable=False,
            closeable=False,
            minimizable=False,
            title=" ",
            is_dialog=True,
            app=app,
        )

        if not callback:

            def callback(sender):
                self.close()

        self.resizeable = True
        self.size = (self.WINDOW_WIDTH, self.WINDOW_MIN_HEIGHT)

        if not icon:
            if self.app:
                icon = self.app.icon
            else:
                icon = Icon("")

        self.msg_title = Label(
            text=title,
            style=Pack(
                width=self.CONTENT_WIDTH,
                padding_bottom=self.TITLE_PADDING_BOTTOM,
                font_weight=BOLD,
                font_size=13,
                background_color=TRANSPARENT,
            ),
        )
        self.image = toga.ImageView(
            icon,
            style=Pack(
                width=self.ICON_SIZE[0],
                height=self.ICON_SIZE[1],
                padding_right=self.ICON_PADDING_RIGHT,
                background_color=TRANSPARENT,
            ),
        )
        self.msg_content = Label(
            text=message,
            linebreak_mode=WORD_WRAP,
            style=Pack(
                width=self.CONTENT_WIDTH,
                padding_bottom=10,
                font_size=11,
                flex=1,
                background_color=TRANSPARENT,
            ),
        )
        self.spinner = toga.ActivityIndicator(
            style=Pack(width=16, height=16, background_color=TRANSPARENT)
        )
        self.dialog_buttons = DialogButtons(
            labels=button_labels,
            default=default,
            on_press=callback,
            style=Pack(
                width=self.CONTENT_WIDTH,
                padding=0,
                alignment=CENTER,
                background_color=TRANSPARENT,
            ),
        )
        self.dialog_buttons.children.insert(0, self.spinner)

        self.accessory_view = accessory_view

        self.content_box = toga.Box(
            children=[
                self.msg_title,
                self.msg_content,
                self.accessory_view,
                self.dialog_buttons,
            ],
            style=Pack(
                direction=COLUMN,
                background_color=TRANSPARENT,
            ),
        )

        self.outer_box = toga.Box(
            children=[self.image, self.content_box],
            style=Pack(
                direction=ROW,
                padding=(
                    self.PADDING_TOP,
                    self.PADDING_RIGHT,
                    self.PADDING_BOTTOM,
                    self.PADDING_LEFT,
                ),
                background_color=TRANSPARENT,
            ),
        )

        self.content = self.outer_box
        self.center()
Esempio n. 18
0
    def startup(self):
        # choose a default publisher
        self.publisher = 'TOI'

        # Load App configuration from default location
        self.app_config = AppConfig()

        # setup logging
        logging.basicConfig(
            filename=self.app_config.config['App']['log_file'],
            filemode='w',
            format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
            level=logging.DEBUG)

        # Scraper
        self.scraper = Scraper(publisher=self.publisher,
                               app_config=self.app_config)

        # Data object instances
        self.epaper = EPaper(publisher=self.publisher,
                             app_config=self.app_config)

        # GUI
        self._menu_items = {}
        self.document_types = ['.jpg', '.png', '.pdf']
        self.main_window = toga.MainWindow(self.name)

        # Get publications
        doc = self.scraper.fetch(self.scraper.site_archive_url)
        if doc:
            self.epaper.publications = self.scraper.parse_publication_codes(
                doc)

        # Get previously selected publication from config or None
        val = self.app_config.config[self.publisher].get(
            'selected_pub_code', '')
        if val:
            self.epaper.selected_publication = [
                p for p in self.epaper.publications.items() if p[1] == val
            ][0]

        # Publication Selection widget
        self.publication_selection = toga.Selection(
            items=self.epaper.publications.keys(),
            style=Pack(flex=1, padding_left=5, padding_right=5))

        # Get editions
        doc = self.scraper.fetch(
            self.scraper.site_archive_edition_url.format(
                pub_code=self.epaper.selected_publication[1]))
        if doc:
            self.epaper.editions = self.scraper.parse_edition_codes(doc)

        # Get previously selected edition from config or None
        val = self.app_config.config[self.publisher].get(
            'selected_edition_code', '')
        if val:
            self.epaper.selected_edition = [
                e for e in self.epaper.editions.items() if e[1] == val
            ][0]

        self.edition_selection = toga.Selection(
            items=self.epaper.editions.keys(),
            style=Pack(flex=1, padding_left=5, padding_right=5))

        self.date_selection = toga.Selection(items=self.epaper.available_dates,
                                             style=Pack(flex=1,
                                                        padding_left=5,
                                                        padding_right=5))

        # Thumbnail View Commands
        thumbnail_commands = []
        for i in range(self.epaper.num_pages):
            thumbnail_commands.append(
                toga.Command(self.display_page(None, i),
                             label='Display Page',
                             tooltip='Display Page {}'.format(i),
                             group=toga.Group.VIEW,
                             section=0))

        thumbnail_buttons = [
            toga.Button('Page {}'.format(i),
                        on_press=self.display_page(None, i),
                        style=Pack(width=100, padding=2))
            for i in range(self.epaper.num_pages)
        ]

        # left view of SplitContainer below
        self.thumbnail_view = toga.ScrollContainer(content=toga.Box(
            children=thumbnail_buttons, style=Pack(direction=COLUMN)))

        # right view of SplitContainer below
        self.page_view = toga.ScrollContainer(content=toga.ImageView(
            id='page-view',
            image=self.epaper.get_page_image_from_disk(
                self.epaper.selected_page),
        ))

        # MainWindow view
        box = toga.Box(children=[
            toga.Box(children=[
                self.publication_selection, self.edition_selection,
                self.date_selection
            ],
                     style=Pack(direction=ROW, padding=5)),
            toga.SplitContainer(content=(self.thumbnail_view, self.page_view),
                                style=Pack(direction=ROW, padding=5))
        ],
                       style=Pack(direction=COLUMN))

        self.main_window.content = box
        self.main_window.show()
Esempio n. 19
0
    def setUp(self):
        # mock factory to return a mock button
        self.factory = MagicMock()
        self.factory.ImageView = MagicMock(return_value=MagicMock(spec=toga_dummy.widgets.imageview.ImageView))

        self.image_view = toga.ImageView(factory=self.factory)
Esempio n. 20
0
    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.logger.info("Starting Application\n------------------------------------------------")

        self.mode_info = {"Overwrite": "Overwrites already replaced faces",
                          "Preserve":  "Preserves already replaced faces",
                          "Generate": "Generates mapping from scratch."}
        os.makedirs(".config", exist_ok=True)
        self.cfg_path = ".config/cfg.json"
        self.logger.info("Loading cfg.json")
        self.config = self._load_config(self.cfg_path)
        for k, v in self.config["Profile"].items():
            if v:
                self.cur_prf = k
                break

        self.logger.info("Loading current profile")
        self.prf_cfg = self._load_config(".config/"+self.cur_prf+".json")
        self.logger.info("Creating GUI")
        self.main_box = toga.Box()
        self.logger.info("Created main box")

        # TOP Profiles
        prf_box = toga.Box()
        self.logger.info("Created prf_box")

        prf_inp = toga.TextInput()
        self.logger.info("Created prf_inp")

        self.prfsel_box = toga.Box()
        prf_lab = toga.Label(text="Create Profile: ")

        prfsel_lab = toga.Label(text="Select Profile: ")
        self.prfsel_lst = SourceSelection(items=list(self.config["Profile"].keys()), on_select=self._set_profile_status)
        self.prfsel_lst.value = self.cur_prf
        prfsel_btn = toga.Button(label="Delete", on_press=lambda e=None, c=self.prfsel_lst : self._delete_profile(c))
        prf_btn = toga.Button(label="Create", on_press=lambda e=None, d=prf_inp, c=self.prfsel_lst: self._create_profile(d, c))

        self.main_box.add(prf_box)
        prf_box.add(prf_lab)
        prf_box.add(prf_inp)
        prf_box.add(prf_btn)
        prf_lab.style.update(padding_top=7)
        prf_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)

        self.main_box.add(self.prfsel_box)
        self.prfsel_box.add(prfsel_lab)
        self.prfsel_box.add(self.prfsel_lst)
        self.prfsel_box.add(prfsel_btn)
        self.prfsel_lst.style.update(direction=ROW, padding=(0, 20), flex=0.5)
        prfsel_lab.style.update(padding_top=7)

        # MID Path selections
        dir_box = toga.Box()
        dir_lab = toga.Label(text="Select Image Directory: ")
        self.dir_inp = toga.TextInput(readonly=True, initial=self.prf_cfg['img_dir'])
        self.dir_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)

        self.dir_btn = toga.Button(label="...", on_press=self.action_select_folder_dialog, enabled=False)

        rtf_box = toga.Box()
        rtf_lab = toga.Label(text="RTF File: ")
        self.rtf_inp = toga.TextInput(readonly=True, initial=self.prf_cfg['rtf'])
        self.rtf_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)

        self.rtf_btn = toga.Button(label="...", on_press=self.action_open_file_dialog, enabled=False)

        self.main_box.add(dir_box)
        self.main_box.add(rtf_box)
        dir_box.add(dir_lab)
        dir_box.add(self.dir_inp)
        dir_box.add(self.dir_btn)
        rtf_box.add(rtf_lab)
        rtf_box.add(self.rtf_inp)
        rtf_box.add(self.rtf_btn)
        dir_lab.style.update(padding_top=7)
        rtf_lab.style.update(padding_top=7)

        gen_mode_box = toga.Box()
        self.genmde_lab = toga.Label(text="Mode: ")
        self.genmdeinfo_lab = toga.Label(text=self.mode_info["Generate"])
        self.genmde_lst = SourceSelection(items=list(self.mode_info.keys()), on_select=self.update_label)
        self.genmde_lst.value = "Generate"
        self.genmde_lst.style.update(direction=ROW, padding=(0, 20), flex=0.5)
        self.genmde_lab.style.update(padding_top=7)
        self.genmdeinfo_lab.style.update(padding_top=7)

        gen_mode_box.add(self.genmde_lab)
        gen_mode_box.add(self.genmde_lst)
        gen_mode_box.add(self.genmdeinfo_lab)
        self.main_box.add(gen_mode_box)
        # BOTTOM Generation
        gen_box = toga.Box()
        self.gen_btn = toga.Button(label="Replace Faces", on_press=self._replace_faces, enabled=False)
        self.gen_btn.style.update(padding_bottom=20)
        self.gen_lab = toga.Label(text="")

        self.gen_prg = toga.ProgressBar(max=110)
        gen_box.add(self.gen_btn)
        gen_box.add(self.gen_lab)
        gen_box.add(self.gen_prg)
        self.main_box.add(gen_box)
        self.gen_lab.style.update(padding_top=20)

        # Report bad image
        rep_box = toga.Box()
        self.rep_lab = toga.Label(text="Player UID: ")
        self.rep_inp = toga.TextInput(on_change=self.change_image)
        self.rep_img = toga.ImageView(toga.Image("resources/logo.png"))
        self.rep_img.style.update(height=180)
        self.rep_img.style.update(width=180)
        self.rep_btn = toga.Button(label="Report", on_press=self.send_report, enabled=False)

        rep_box.add(self.rep_lab)
        rep_box.add(self.rep_inp)
        rep_box.add(self.rep_img)
        rep_box.add(self.rep_btn)
        self.main_box.add(rep_box)
        self.rep_lab.style.update(padding_top=10)
        self.rep_inp.style.update(direction=ROW, padding=(0, 20), flex=0.5)


        # END configs
        rep_box.style.update(direction=ROW, padding=20)
        gen_mode_box.style.update(direction=ROW, padding=20)
        prf_box.style.update(direction=ROW, padding=20)
        self.prfsel_box.style.update(direction=ROW, padding=20)
        dir_box.style.update(direction=ROW, padding=20)
        rtf_box.style.update(direction=ROW, padding=20)
        gen_box.style.update(direction=COLUMN, padding=20, alignment='center')
        self.main_box.style.update(direction=COLUMN, padding=10, alignment='center')

        self.main_window = toga.MainWindow(title=self.formal_name, size=(1000, 600))
        self.main_window.content = self.main_box
        self.main_window.show()
Esempio n. 21
0
    def setUp(self):
        super().setUp()

        self.image_view = toga.ImageView(factory=toga_dummy.factory)
Esempio n. 22
0
    def create_image_view(self, url, width=200, height=200):
        image = toga.Image(url)
        style = Pack(width=width, height=height)

        self.image_view = toga.ImageView(image, style=style)
Esempio n. 23
0
    def startup(self):
        main_box = toga.Box(id="mainbox",
                            style=Pack(direction=COLUMN, padding=5))
        self.solver = solver()
        self.detector = detector()
        self.ImagePath = None
        self.ROIPath = None
        self.Preview = toga.ImageView(
            image=toga.Image("resources/blank_sudoku.jpg"))
        self.grid = []
        self.hideROI = True
        self.imgLoaded = False
        self.ImgStatusLabel = None

        for i in range(9):
            self.grid.append([])
            row = toga.Box(style=Pack(direction=ROW, padding=0))
            for j in range(9):
                self.grid[i].append(
                    toga.Button(label=" ",
                                id='{}{}'.format(i, j),
                                on_press=self.pressedButton,
                                style=Pack(flex=1, background_color="white")))
                row.add(self.grid[i][j])
                if (j + 1) % 3 == 0 and j < 8:
                    row.add(toga.Label(style=Pack(padding=0), text="\t"))
            main_box.add(row)
            if (i + 1) % 3 == 0 and i < 8:
                main_box.add(toga.Label(text="\t"))

        #adding solvebutton
        main_box.add(toga.Label(text="\t"))
        main_box.add(
            toga.Button(label="Get obvious Fields",
                        on_press=self.obviousButton))
        main_box.add(toga.Button(label="Solve", on_press=self.solveButton))

        selection_box = toga.Box(id="imagebox",
                                 style=Pack(direction=ROW, padding=10))
        selection_buttons = toga.Box(style=Pack(direction=COLUMN, padding=5))
        selection_buttons.add(
            toga.Button(label="Open   ", on_press=self.openButton))
        selection_buttons.add(
            toga.Button(label="ROI      ",
                        on_press=self.switchButton,
                        style=Pack(direction=COLUMN)))
        self.ImgStatusLabel = toga.Label(text="Select an Image")
        selection_buttons.add(toga.Label(text=""))
        selection_buttons.add(self.ImgStatusLabel)
        selection_box.add(selection_buttons)
        selection_box.add(self.Preview)

        option = toga.OptionContainer()
        option.add("Image", selection_box)
        option.add("Sudoku", main_box)

        #init window
        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = option

        self.main_window.show()
Esempio n. 24
0
    def __init__(self, **kwargs) -> None:
        super().__init__(
            title="Maestral Settings",
            resizeable=False,
            minimizable=False,
            release_on_close=False,
            **kwargs,
        )

        # ==== account info section ====================================================

        self.profile_pic_view = toga.ImageView(
            self.faceholder,
            style=Pack(
                width=SettingsGui.IMAGE_WIDTH,
                height=SettingsGui.IMAGE_WIDTH,
                background_color=TRANSPARENT,
            ),
        )
        apply_round_clipping(self.profile_pic_view)

        self.profile_pic_view_spacer = toga.Box(style=Pack(
            width=SettingsGui.COLUMN_WIDTH_LEFT - SettingsGui.IMAGE_WIDTH,
            direction=ROW,
            background_color=TRANSPARENT,
        ))

        self.label_name = Label(
            "Account Name (Company Name)",
            style=Pack(
                font_size=17,
                padding_bottom=SettingsGui.ELEMENT_PADDING - 4,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )
        self.label_email = Label(
            "[email protected], Business",
            style=Pack(
                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                font_size=12,
            ),
        )
        self.label_usage = Label(
            "10.5 % from 1,005 TB used",
            style=Pack(
                padding_bottom=SettingsGui.ELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                font_size=12,
            ),
        )
        self.btn_unlink = toga.Button(
            "Unlink this Dropbox...",
            style=Pack(width=SettingsGui.BUTTON_WIDTH))

        account_info_box = toga.Box(
            children=[
                self.profile_pic_view_spacer,
                self.profile_pic_view,
                toga.Box(
                    children=[
                        self.label_name,
                        self.label_email,
                        self.label_usage,
                        self.btn_unlink,
                    ],
                    style=Pack(direction=COLUMN,
                               padding_left=SettingsGui.COLUMN_PADDING),
                ),
            ],
            style=Pack(direction=ROW),
        )

        # ==== sync settings section ===================================================

        self._label_select_folders = Label(
            "Selective sync:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.btn_select_folders = toga.Button(
            label="Select files and folders...",
            style=Pack(padding_left=SettingsGui.COLUMN_PADDING,
                       width=SettingsGui.BUTTON_WIDTH),
        )

        self._label_dbx_location = Label(
            "Local Dropbox folder:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.combobox_dbx_location = FileSelectionButton(
            initial=get_home_dir(),
            select_files=False,
            select_folders=True,
            style=Pack(padding_left=SettingsGui.COLUMN_PADDING,
                       width=SettingsGui.BUTTON_WIDTH),
        )

        dropbox_settings_box = toga.Box(
            children=[
                toga.Box(
                    children=[
                        self._label_select_folders, self.btn_select_folders
                    ],
                    style=Pack(alignment=CENTER,
                               padding_bottom=SettingsGui.ELEMENT_PADDING),
                ),
                toga.Box(
                    children=[
                        self._label_dbx_location, self.combobox_dbx_location
                    ],
                    style=Pack(alignment=CENTER),
                ),
            ],
            style=Pack(direction=COLUMN),
        )

        # ==== system settings section =================================================

        self._label_update_interval = Label(
            "Check for updates:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.combobox_update_interval = toga.Selection(
            items=["Daily", "Weekly", "Monthly", "Never"],
            style=Pack(padding_left=SettingsGui.COLUMN_PADDING,
                       width=SettingsGui.BUTTON_WIDTH),
        )

        self._label_system_settings = Label(
            "System settings:",
            style=Pack(text_align=RIGHT, width=SettingsGui.COLUMN_WIDTH_LEFT),
        )
        self.checkbox_autostart = Switch(
            label="Start Maestral on login",
            style=Pack(
                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )
        self.checkbox_notifications = Switch(
            label="Enable notifications on file changes",
            style=Pack(
                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                width=SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )

        children = [
            toga.Box(
                children=[
                    self._label_update_interval, self.combobox_update_interval
                ],
                style=Pack(alignment=CENTER,
                           padding_bottom=SettingsGui.ELEMENT_PADDING),
            ),
            toga.Box(children=[
                self._label_system_settings,
                toga.Box(
                    children=[
                        self.checkbox_autostart,
                        self.checkbox_notifications,
                    ],
                    style=Pack(
                        alignment=TOP,
                        direction=COLUMN,
                        padding_left=SettingsGui.COLUMN_PADDING,
                    ),
                ),
            ], ),
        ]

        if FROZEN:
            # add UI to install command line interface
            self._label_cli_tool = Label(
                "Command line tool:",
                style=Pack(text_align=RIGHT,
                           width=SettingsGui.COLUMN_WIDTH_LEFT),
            )

            self.label_cli_tool_info = Label(
                "Install the 'maestral' command line tool to /usr/local/bin.",
                style=Pack(
                    color=GRAY,
                    font_size=12,
                    width=SettingsGui.COLUMN_WIDTH_RIGHT,
                    padding_left=SettingsGui.COLUMN_PADDING,
                ),
            )

            self.btn_cli_tool = toga.Button(
                "Install",
                style=Pack(
                    width=SettingsGui.BUTTON_WIDTH / 2,
                    padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                    padding_left=SettingsGui.COLUMN_PADDING,
                ),
            )

            children.append(
                toga.Box(
                    children=[
                        self._label_cli_tool,
                        self.btn_cli_tool,
                    ],
                    style=Pack(alignment=CENTER,
                               padding_top=SettingsGui.ELEMENT_PADDING),
                ))
            children.append(
                toga.Box(
                    children=[
                        Label(
                            " ",
                            style=Pack(text_align=RIGHT,
                                       width=SettingsGui.COLUMN_WIDTH_LEFT),
                        ),
                        self.label_cli_tool_info,
                    ],
                    style=Pack(alignment=CENTER,
                               padding_top=SettingsGui.SUBELEMENT_PADDING),
                ))

        maestral_settings_box = toga.Box(
            children=children,
            style=Pack(direction=COLUMN),
        )

        # ==== about section ===========================================================

        about_box = toga.Box(
            children=[
                Label(
                    "About Maestral:",
                    style=Pack(text_align=RIGHT,
                               width=SettingsGui.COLUMN_WIDTH_LEFT),
                ),
                toga.Box(
                    children=[
                        Label(
                            f"GUI v{__version__}, daemon v{__daemon_version__}",
                            style=Pack(
                                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                            ),
                        ),
                        LinkLabel(
                            text=__url__,
                            url=__url__,
                            style=Pack(
                                padding_bottom=SettingsGui.SUBELEMENT_PADDING,
                                width=SettingsGui.COLUMN_WIDTH_RIGHT,
                            ),
                        ),
                        Label(
                            f"© 2018 - {year}, {__author__}.",
                            style=Pack(color=GRAY,
                                       width=SettingsGui.COLUMN_WIDTH_RIGHT),
                        ),
                    ],
                    style=Pack(direction=COLUMN,
                               padding_left=SettingsGui.COLUMN_PADDING),
                ),
            ],
            style=Pack(direction=ROW),
        )

        main_box = toga.Box(
            children=[
                account_info_box,
                toga.Divider(style=Pack(padding=SettingsGui.SECTION_PADDING)),
                dropbox_settings_box,
                toga.Divider(style=Pack(padding=SettingsGui.SECTION_PADDING)),
                maestral_settings_box,
                toga.Divider(style=Pack(padding=SettingsGui.SECTION_PADDING)),
                about_box,
            ],
            style=Pack(
                direction=COLUMN,
                padding=30,
                width=SettingsGui.COLUMN_WIDTH_LEFT +
                SettingsGui.COLUMN_WIDTH_RIGHT,
            ),
        )

        self.content = main_box
Esempio n. 25
0
    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.logger.info(
            "Starting Application\n------------------------------------------------"
        )
        self.logger.info(str(self.paths.app))
        self.facepack_dirs = set([
            "African", "Asian", "Caucasian", "Central European", "EECA",
            "Italmed", "MENA", "MESA", "SAMed", "Scandinavian", "Seasian",
            "South American", "SpanMed", "YugoGreek"
        ])
        self.mode_info = {
            "Overwrite": "Overwrites already replaced faces",
            "Preserve": "Preserves already replaced faces",
            "Generate": "Generates mapping from scratch."
        }
        os.makedirs(str(self.paths.app) + "/.config", exist_ok=True)
        if not os.path.isfile(str(self.paths.app) + "/.user/cfg.json"):
            shutil.copyfile(
                str(self.paths.app) + "/.user/default_cfg.json",
                str(self.paths.app) + "/.user/cfg.json")

        self.logger.info("Loading current profile")
        self.profile_manager = Profile_Manager(
            Config_Manager().get_latest_prf(
                str(self.paths.app) + "/.user/cfg.json"), str(self.paths.app))
        self.profile_manager.migrate_config()
        self.logger.info("Creating GUI")
        self.main_box = toga.Box()
        self.logger.info("Created main box")

        self.hook = "https://discord.com/api/webhooks/796137178328989768/ETMNtPVb-PHuZPayC5G5MZD24tdDi5jmG6jAgjZXg0FDOXjy-VIabATXPco05qLIr4ro"

        # CREATE MENUBAR
        troubleshooting = toga.Command(
            lambda e=None, u=
            "https://github.com/Maradonna90/NewGAN-Manager/wiki/Troubleshooting":
            self.open_link(u),
            label='Troubleshooting',
            group=toga.Group.HELP,
            section=1)
        usage = toga.Command(
            lambda e=None, u="https://www.youtube.com/watch?v=iJqZNp0nomM":
            self.open_link(u),
            label='User Guide',
            group=toga.Group.HELP,
            section=0)

        faq = toga.Command(
            lambda e=None, u=
            "https://github.com/Maradonna90/NewGAN-Manager/wiki/FAQ": self.
            open_link(u),
            label='FAQ',
            group=toga.Group.HELP,
            section=2)

        discord = toga.Command(
            lambda e=None, u="https://discord.gg/UfRpJVc": self.open_link(u),
            label='Discord',
            group=toga.Group.HELP,
            section=3)

        self.commands.add(discord, faq, troubleshooting, usage)

        label_width = 125
        # TOP Profiles
        prf_box = toga.Box()
        self.logger.info("Created prf_box")

        prf_inp = toga.TextInput()
        self.logger.info("Created prf_inp")

        self.prfsel_box = toga.Box()
        prf_lab = toga.Label(text="Create Profile: ")
        prf_lab.style.update(width=label_width)

        prfsel_lab = toga.Label(text="Select Profile: ")
        prfsel_lab.style.update(width=label_width)
        self.prfsel_lst = SourceSelection(items=list(
            self.profile_manager.config["Profile"].keys()),
                                          on_select=self._set_profile_status)
        self.prfsel_lst.value = self.profile_manager.cur_prf
        prfsel_btn = toga.Button(
            label="Delete",
            on_press=lambda e=None, c=self.prfsel_lst: self._delete_profile(c))
        prf_btn = toga.Button(label="Create",
                              on_press=lambda e=None, d=prf_inp, c=self.
                              prfsel_lst: self._create_profile(d, c))

        self.main_box.add(prf_box)
        prf_box.add(prf_lab)
        prf_box.add(prf_inp)
        prf_box.add(prf_btn)
        prf_lab.style.update(padding_top=7)
        prf_inp.style.update(direction=ROW, padding=(0, 20), flex=1)

        self.main_box.add(self.prfsel_box)
        self.prfsel_box.add(prfsel_lab)
        self.prfsel_box.add(self.prfsel_lst)
        self.prfsel_box.add(prfsel_btn)
        self.prfsel_lst.style.update(direction=ROW, padding=(0, 20), flex=1)
        prfsel_lab.style.update(padding_top=7)

        # MID Path selections
        dir_box = toga.Box()
        dir_lab = toga.Label(text="Select Image Directory: ")
        dir_lab.style.update(width=label_width)
        self.dir_inp = toga.TextInput(
            readonly=True, initial=self.profile_manager.prf_cfg['img_dir'])
        self.dir_inp.style.update(direction=ROW, padding=(0, 20), flex=1)
        self.dir_btn = toga.Button(label="...",
                                   on_press=self.action_select_folder_dialog,
                                   enabled=False)

        rtf_box = toga.Box()
        rtf_lab = toga.Label(text="RTF File: ")
        rtf_lab.style.update(width=label_width)
        self.rtf_inp = toga.TextInput(
            readonly=True, initial=self.profile_manager.prf_cfg['rtf'])
        self.rtf_inp.style.update(direction=ROW, padding=(0, 20), flex=1)
        self.rtf_btn = toga.Button(label="...",
                                   on_press=self.action_open_file_dialog,
                                   enabled=False)

        self.main_box.add(dir_box)
        self.main_box.add(rtf_box)
        dir_box.add(dir_lab)
        dir_box.add(self.dir_inp)
        dir_box.add(self.dir_btn)
        rtf_box.add(rtf_lab)
        rtf_box.add(self.rtf_inp)
        rtf_box.add(self.rtf_btn)
        dir_lab.style.update(padding_top=7)
        rtf_lab.style.update(padding_top=7)

        gen_mode_box = toga.Box()
        self.genmde_lab = toga.Label(text="Mode: ")
        self.genmde_lab.style.update(width=label_width)
        self.genmdeinfo_lab = toga.Label(text=self.mode_info["Generate"])
        self.gendup = toga.Switch(label="Allow Duplicates?")
        self.genmde_lst = SourceSelection(items=list(self.mode_info.keys()),
                                          on_select=self.update_label)
        self.genmde_lst.value = "Generate"
        self.genmde_lst.style.update(direction=ROW, padding=(0, 20), flex=1)
        self.genmde_lab.style.update(padding_top=7)
        self.genmdeinfo_lab.style.update(padding_top=7)
        self.gendup.style.update(padding_top=7, padding_left=20)

        gen_mode_box.add(self.genmde_lab)
        gen_mode_box.add(self.genmde_lst)
        gen_mode_box.add(self.genmdeinfo_lab)
        gen_mode_box.add(self.gendup)
        self.main_box.add(gen_mode_box)
        # BOTTOM Generation
        gen_box = toga.Box()
        self.gen_btn = toga.Button(label="Replace Faces",
                                   on_press=self._replace_faces,
                                   enabled=False)
        self.gen_btn.style.update(padding_bottom=20)
        self.gen_lab = toga.Label(text="")

        # self.gen_prg = toga.ProgressBar(max=110)
        self.gen_prg = Progressbar(label=self.gen_lab)
        gen_box.add(self.gen_btn)
        gen_box.add(self.gen_lab)
        gen_box.add(self.gen_prg)
        self.main_box.add(gen_box)
        self.gen_prg.style.update(width=570, alignment="center")
        self.gen_lab.style.update(padding_top=20,
                                  padding_bottom=20,
                                  width=100,
                                  alignment="center")

        # Report bad image
        rep_box = toga.Box()
        self.rep_lab = toga.Label(text="Player UID: ")
        self.rep_lab.style.update(width=label_width)
        self.rep_inp = toga.TextInput(on_change=self.change_image)
        self.rep_img = toga.ImageView(toga.Image("resources/logo.png"))
        self.rep_img.style.update(height=180)
        self.rep_img.style.update(width=180)
        self.rep_btn = toga.Button(label="Report",
                                   on_press=self.send_report,
                                   enabled=False)

        rep_box.add(self.rep_lab)
        rep_box.add(self.rep_inp)
        rep_box.add(self.rep_img)
        rep_box.add(self.rep_btn)
        self.main_box.add(rep_box)
        self.rep_lab.style.update(padding_top=10)
        self.rep_inp.style.update(direction=ROW, padding=(0, 20), flex=1)

        # END config
        self.prfsel_box.style.update(padding_bottom=20)
        dir_box.style.update(padding_bottom=20)
        prf_box.style.update(padding_bottom=20)
        rtf_box.style.update(padding_bottom=20)
        gen_mode_box.style.update(padding_bottom=20)
        rep_box.style.update(padding_top=20)
        gen_box.style.update(direction=COLUMN, alignment='center')
        self.main_box.style.update(direction=COLUMN,
                                   padding=30,
                                   alignment='center')

        self.main_window = toga.MainWindow(title=self.formal_name,
                                           size=(1000, 600))
        self.main_window.content = self.main_box
        self.main_window.show()

        self.check_for_update()
Esempio n. 26
0
    def startup(self):

        # agu logo
        image = toga.Image('resources/agu.png')
        self.agu_image_view = toga.ImageView(image,
                                             style=Pack(padding=10,
                                                        width=300,
                                                        height=300))

        # username
        username_label = toga.Label('Username: '******'Password: '******'Login',
                             on_press=self.home,
                             style=Pack(padding_top=25, width=100))

        login_box.add(button)

        self.login_main_box = toga.Box(children=[login_box],
                                       style=Pack(direction=COLUMN,
                                                  padding=250,
                                                  padding_top=100,
                                                  alignment=CENTER,
                                                  flex=1))

        image1 = toga.Image('resources/RDDR.png')
        self.logo_image_view = toga.ImageView(image1,
                                              style=Pack(padding=10,
                                                         width=300,
                                                         height=300))

        company_logo_box = toga.Box(style=Pack(direction=COLUMN,
                                               padding=250,
                                               padding_top=100,
                                               alignment=CENTER,
                                               flex=1))
        company_logo_box.add(self.logo_image_view)

        self.main_window = toga.MainWindow(title="AGU")
        self.main_window.content = company_logo_box
        self.main_window.show()

        self.add_background_task(self.do_background_task)
Esempio n. 27
0
    def __init__(self, app: toga.App) -> None:
        # noinspection PyTypeChecker
        super().__init__(
            title="Maestral Setup",
            size=(self.WINDOW_WIDTH, self.WINDOW_HEIGHT),
            resizeable=False,
            minimizable=False,
            app=app,
        )

        # FIXME: remove private API access
        self._impl.native.titlebarAppearsTransparent = True
        self._impl.native.titleVisibility = 1
        self._impl.native.styleMask |= NSFullSizeContentViewWindowMask
        self._impl.native.movableByWindowBackground = True

        self.current_page = 0

        # ==== welcome page ============================================================
        # noinspection PyTypeChecker
        self.image0 = toga.ImageView(
            self.app.icon,
            style=Pack(width=128,
                       height=128,
                       alignment=CENTER,
                       padding=(40, 0, 40, 0)),
        )
        self.label0 = Label(
            text="Welcome to Maestral, an open source Dropbox client.",
            style=Pack(width=self.WINDOW_WIDTH,
                       padding_bottom=40,
                       text_align=CENTER),
        )
        self.btn_start = toga.Button("Link Dropbox Account",
                                     style=Pack(width=180))

        self.welcome_page = toga.Box(
            children=[
                self.image0, self.label0, self.btn_start,
                Spacer(COLUMN)
            ],
            style=self.page_style,
        )

        # ==== link page ===============================================================

        # noinspection PyTypeChecker
        self.image1 = toga.ImageView(self.app.icon,
                                     style=Pack(width=64,
                                                height=64,
                                                padding=(40, 0, 40, 0)))
        self.label1 = Label(
            text=(
                "To link Maestral to your Dropbox account, please retrieve an "
                "authorization token from Dropbox and enter it below."),
            linebreak_mode=WORD_WRAP,
            style=Pack(width=self.CONTENT_WIDTH * 0.9,
                       text_align=CENTER,
                       padding_bottom=10),
        )
        self.btn_auth_token = FollowLinkButton("Retrieve Token",
                                               style=Pack(width=125,
                                                          padding_bottom=35))
        self.text_field_auth_token = toga.TextInput(
            placeholder="Authorization Token",
            style=Pack(
                width=self.CONTENT_WIDTH * 0.9,
                text_align=CENTER,
                background_color=TRANSPARENT,
            ),
        )
        self.spinner_link = toga.ActivityIndicator(
            style=Pack(width=32, height=32))
        self.dialog_buttons_link_page = DialogButtons(labels=("Link",
                                                              "Cancel"),
                                                      style=self.btn_box_style)
        self.dialog_buttons_link_page["Link"].enabled = False

        self.link_page = toga.Box(
            children=[
                self.image1,
                self.label1,
                self.btn_auth_token,
                self.text_field_auth_token,
                Spacer(COLUMN),
                self.spinner_link,
                Spacer(COLUMN),
                self.dialog_buttons_link_page,
            ],
            style=self.page_style,
        )

        # ==== dbx location page =======================================================

        # noinspection PyTypeChecker
        self.image2 = toga.ImageView(self.app.icon,
                                     style=Pack(width=64,
                                                height=64,
                                                padding=(40, 0, 40, 0)))
        self.dbx_location_label = Label(
            text=
            ("Maestral has been successfully linked with your Dropbox account.\n\n"
             "Please select a local folder for your Dropbox. If the folder is not "
             "empty, you will be given the option to merge its content with your "
             "remote Dropbox. Merging will not transfer or duplicate any identical "
             "files.\n\n"
             "In the next step, you will be asked to choose which folders to sync."
             ),
            linebreak_mode=WORD_WRAP,
            style=Pack(
                width=self.CONTENT_WIDTH,
                height=90,
                padding_bottom=20,
                text_align=CENTER,
            ),
        )
        self.combobox_dbx_location = FileSelectionButton(
            initial=get_home_dir(),
            select_files=False,
            select_folders=True,
            show_full_path=True,
            style=Pack(width=self.CONTENT_WIDTH * 0.9, padding_bottom=20),
        )

        self.dialog_buttons_location_page = DialogButtons(
            labels=("Select", "Cancel & Unlink"), style=self.btn_box_style)

        self.dbx_location_page = toga.Box(
            children=[
                self.image2,
                self.dbx_location_label,
                self.combobox_dbx_location,
                Spacer(COLUMN),
                self.dialog_buttons_location_page,
            ],
            style=self.page_style,
        )

        # ==== selective sync page =====================================================

        self.label3 = Label(
            text=
            ("Please select which files and folders to sync below. The initial "
             "download may take some time, depending on the size of your Dropbox."
             ),
            linebreak_mode=WORD_WRAP,
            style=Pack(width=self.CONTENT_WIDTH, padding=(20, 0, 20, 0)),
        )
        self.dropbox_tree = toga.Tree(
            headings=["Name", "Included"],
            accessors=["name", "included"],
            data=[],
            style=Pack(width=self.CONTENT_WIDTH, padding_bottom=20, flex=1),
            multiple_select=True,
        )

        self.dialog_buttons_selective_sync_page = DialogButtons(
            labels=["Select", "Back"],
            style=self.btn_box_style,
        )

        self.selective_sync_page = toga.Box(
            children=[
                self.label3,
                self.dropbox_tree,
                self.dialog_buttons_selective_sync_page,
            ],
            style=self.page_style,
        )

        # ==== done page ===============================================================

        # noinspection PyTypeChecker
        self.image4 = toga.ImageView(
            self.app.icon,
            style=Pack(width=128,
                       height=128,
                       alignment=CENTER,
                       padding=(40, 0, 40, 0)),
        )
        self.label4 = Label(
            text=
            ("You have successfully set up Maestral. Please allow some time for the "
             "initial indexing and download of your Dropbox before Maestral will "
             "commence syncing."),
            linebreak_mode=WORD_WRAP,
            style=Pack(width=self.CONTENT_WIDTH,
                       text_align=CENTER,
                       padding_bottom=50),
        )
        self.close_button = toga.Button("Close",
                                        style=Pack(width=100),
                                        on_press=lambda s: self.close())

        self.done_page = toga.Box(
            children=[
                self.image4, self.label4, self.close_button,
                Spacer(COLUMN)
            ],
            style=self.page_style,
        )

        self.pages = (
            self.welcome_page,
            self.link_page,
            self.dbx_location_page,
            self.selective_sync_page,
            self.done_page,
        )
        self.content = toga.Box(children=[self.pages[0]])
Esempio n. 28
0
    def create_image(self, path, width=200, height=200):
        self.default_image = toga.Image(path)

        style = Pack(width=width, height=height)

        self.image_view = toga.ImageView(self.default_image, style=style)
Esempio n. 29
0
File: app.py Progetto: xmonader/toga
    def startup(self):

        self.button_hide = toga.Button(
            label='Hide label',
            style=Pack(padding=10, width=120),
            on_press=self.hide_label,
        )

        self.button_add = toga.Button(
            label='Add image',
            style=Pack(padding=10, width=120),
            on_press=self.add_image,
        )

        self.button_remove = toga.Button(
            label='Remove image',
            style=Pack(padding=10, width=120),
            on_press=self.remove_image,
            enabled=False,
        )

        self.button_insert = toga.Button(
            label='Insert image',
            style=Pack(padding=10, width=120),
            on_press=self.insert_image,
        )

        self.button_reparent = toga.Button(
            label='Reparent image',
            style=Pack(padding=10, width=120),
            on_press=self.reparent_image,
            enabled=False,
        )

        self.button_add_to_scroll = toga.Button(
            label='Add new label',
            style=Pack(padding=10, width=120),
            on_press=self.add_label,
        )

        self.scroll_box = toga.Box(children=[],
                                   style=Pack(direction=COLUMN,
                                              padding=10,
                                              flex=1))
        self.scroll_view = toga.ScrollContainer(content=self.scroll_box,
                                                style=Pack(width=120))

        image = toga.Image('resources/tiberius.png')
        self.image_view = toga.ImageView(image,
                                         style=Pack(padding=10,
                                                    width=60,
                                                    height=60))

        # this tests adding children during init, before we have an implementation
        self.button_box = toga.Box(
            children=[
                self.button_hide,
                self.button_add,
                self.button_insert,
                self.button_reparent,
                self.button_remove,
                self.button_add_to_scroll,
            ],
            style=Pack(direction=COLUMN),
        )

        self.box = toga.Box(children=[],
                            style=Pack(direction=ROW,
                                       padding=10,
                                       alignment=CENTER,
                                       flex=1))

        # this tests adding children when we already have an impl but no window or app
        self.box.add(self.button_box)
        self.box.add(self.scroll_view)

        # add a couple of labels to get us started
        self.labels = []
        for i in range(3):
            self.add_label()

        self.main_window = toga.MainWindow()
        self.main_window.content = self.box
        self.main_window.show()
Esempio n. 30
0
 def create_image(self):
     image = toga.Image(BTC_ICON)
     self.logo = toga.ImageView(image=image, style=Pack(
         width=150, height=150,
         padding_top=25, padding_bottom=25
     ))