Exemple #1
0
    def startup(self):
        # Window class
        #   Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(300, 150))

        style = Pack(padding_top=24)
        substyle = Pack(padding_right=24, flex=1)

        # Add the content on the main window
        self.main_window.content = toga.Box(
            children=[
                toga.Label('Section 1'),
                toga.Divider(style=style),
                toga.Label('Section 2', style=style),
                toga.Divider(style=style),
                toga.Label('Section 3', style=style),
                toga.Box(
                    children=[
                        toga.DetailedList(['List 1'], style=substyle),
                        toga.Divider(direction=toga.Divider.VERTICAL, style=substyle),
                        toga.DetailedList(['List 2'], style=substyle),
                    ],
                    style=Pack(direction=ROW, padding=24, flex=1),
                ),
            ],
            style=Pack(direction=COLUMN, padding=24)
        )

        # Show the main window
        self.main_window.show()
Exemple #2
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)

        self.webview = toga.WebView(style=Pack(flex=1))
        self.url_input = toga.TextInput(initial='https://github.com/',
                                        style=Pack(flex=1))

        box = toga.Box(children=[
            toga.Box(children=[
                self.url_input,
                toga.Button('Go',
                            on_press=self.load_page,
                            style=Pack(width=50, padding_left=5)),
            ],
                     style=Pack(
                         direction=ROW,
                         alignment=CENTER,
                         padding=5,
                     )),
            self.webview,
        ],
                       style=Pack(direction=COLUMN))

        self.main_window.content = box
        self.webview.url = self.url_input.value

        # Show the main window
        self.main_window.show()
Exemple #3
0
 def test_setting_content_valid_input(self):
     new_content = [
         toga.Box(style=TestStyle(), factory=toga_dummy.factory),
         toga.Box(style=TestStyle(), factory=toga_dummy.factory)
     ]
     self.split.content = new_content
     self.assertEqual(self.split.content, new_content)
Exemple #4
0
    def _installed_section(self) -> toga.Widget:
        desc = "Choose directories for installed games lookup. The lookup is based on child directory names."
        description = toga.Label(desc,
                                 style=Pack(font_size=self.TEXT_SIZE_BIG,
                                            padding_bottom=12))
        if IS_MAC:
            desc_os = "If nothing selected, '/Applications' will be used."
        if IS_WINDOWS:
            desc_os = "e.g. 'C:/Humble' to detect 'C:/Humble/Torchlight/torch.exe' ('Torchlight' matches game name)."
        description_os = toga.Label(desc_os,
                                    style=Pack(font_size=self.TEXT_SIZE_BIG,
                                               padding_bottom=12))

        self._paths_table = OneColumnTable(
            'Path', data=[str(p) for p in self._cfg.installed.search_dirs])

        select_btn = toga.Button('Add path', on_press=self._add_path)
        select_btn.style.flex = 1
        select_btn.style.padding_bottom = 4
        self._remove_btn = toga.Button('Remove path',
                                       on_press=self._remove_paths,
                                       enabled=self._paths_table.not_empty)
        self._remove_btn.style.flex = 1
        config_panel = toga.Box(children=[select_btn, self._remove_btn])
        config_panel.style.direction = 'row'
        config_panel.style.padding_top = 15

        paths_container = toga.Box(children=[
            description, description_os, self._paths_table, config_panel
        ])
        paths_container.style.direction = 'column'
        return paths_container
Exemple #5
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()
Exemple #6
0
    def startup(self):
        main_box = toga.Box(style=Pack(direction=COLUMN))

        name_label = toga.Label(
            'Your name pls: ',
            style=Pack(padding=(0, 5))
        )
        self.name_input = toga.TextInput(style=Pack(flex=1))

        name_box = toga.Box(style=Pack(direction=ROW, padding=5))
        name_box.add(name_label)
        name_box.add(self.name_input)

        button = toga.Button(
            'Say Hello!',
            on_press=self.say_hello,
            style=Pack(padding=5)
        )

        main_box.add(name_box)
        main_box.add(button)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Exemple #7
0
    def startup(self):

        main_box = toga.Box(style=Pack(direction=COLUMN))

        name_label = toga.Label("Your name: ", style=Pack(padding=(0, 5)))
        self.name_input = toga.TextInput(style=Pack(flex=1))
        self.display_score = toga.TextInput(style=Pack(flex=1), readonly=True)

        name_box = toga.Box(style=Pack(direction=ROW, padding=5))
        name_box.add(name_label)
        name_box.add(self.name_input)

        button_1 = toga.Button("Team A",
                               on_press=self.score_for_team_a,
                               style=Pack(padding=5))

        button_2 = toga.Button("Team B",
                               on_press=self.score_for_team_b,
                               style=Pack(padding=5))
        button_3 = toga.Button("Create Match",
                               on_press=self.create_match,
                               style=Pack(padding=5))

        main_box.add(name_box)
        main_box.add(button_1)
        main_box.add(button_2)
        main_box.add(button_3)
        main_box.add(self.display_score)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
def build(app):
    def on_load(widget):
        print('Finished loading!')
        print(widget.dom)

    def on_key(event, flag):
        print('Key down: ', event, ' Flag: ', flag)

    webview = toga.WebView(on_key_down=on_key,
                           on_webview_load=on_load,
                           style=CSS(flex=1))
    url_input = toga.TextInput(initial='https://github.com/',
                               style=CSS(flex=1, margin=5))

    def load_page(widget):
        print('loading: ', url_input.value)
        webview.url = url_input.value

    def print_dom(widget):
        print(webview.dom)

    box = toga.Box(children=[
        toga.Box(children=[
            url_input,
            toga.Button('Go', on_press=load_page, style=CSS(width=50)),
        ],
                 style=CSS(flex_direction='row', padding_top=25)), webview,
        toga.Box(children=[toga.Button('Print DOM', on_press=print_dom)])
    ],
                   style=CSS(flex_direction='column'))

    webview.url = url_input.value

    # Show the main window
    return box
Exemple #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()
Exemple #10
0
    def startup(self):
        # Window class
        #   Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(300, 150))

        style = Pack(padding_top=24)
        substyle = Pack(padding_right=12, padding_left=12, flex=1)

        # Add the content on the main window
        self.main_window.content = toga.Box(children=[
            toga.Label('Section 1'),
            toga.Divider(style=style),
            toga.Label('Section 2', style=style),
            toga.Divider(style=style),
            toga.Label('Section 3', style=style),
            toga.Box(
                children=[
                    toga.TextInput(placeholder="First textbox"),
                    toga.Divider(direction=toga.Divider.VERTICAL,
                                 style=substyle),
                    toga.TextInput(placeholder="Second textbox"),
                ],
                style=Pack(direction=ROW, padding=24, flex=1),
            ),
        ],
                                            style=Pack(direction=COLUMN,
                                                       padding=24))

        # Show the main window
        self.main_window.show()
Exemple #11
0
    def startup(self):
        box = toga.Box()
        box.style.direction = COLUMN
        box.style.padding = 10
        self.scroller = toga.ScrollContainer(horizontal=self.hscrolling,
                                             vertical=self.vscrolling)
        switch_box = toga.Box(style=Pack(direction=ROW))
        switch_box.add(
            toga.Switch('vertical scrolling',
                        is_on=self.vscrolling,
                        on_toggle=self.handle_vscrolling))
        switch_box.add(
            toga.Switch('horizontal scrolling',
                        is_on=self.hscrolling,
                        on_toggle=self.handle_hscrolling))
        box.add(switch_box)

        for x in range(100):
            label_text = 'Label {}'.format(x)
            box.add(Item(label_text))

        self.scroller.content = box

        self.main_window = toga.MainWindow(self.name, size=(400, 700))
        self.main_window.content = self.scroller
        self.main_window.show()
Exemple #12
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
                 ),
             ),
         ],
     )
Exemple #13
0
def build(app):
    def calculate(widget):
        try:
            result_form.value = int(input_form.value) * int(input_form.value)
        except ValueError:
            result_form.value = 'ValueError'

    box = toga.Box()

    input_box = toga.Box()
    box.add(input_box)
    input_form = toga.TextInput()
    input_form.style.update(flex=1)
    input_box.add(input_form)
    input_box.style.update(direction=ROW)

    result_box = toga.Box()
    box.add(result_box)
    result_form = toga.TextInput(readonly=True)
    result_box.add(result_form)
    result_box.style.update(direction=ROW)
    result_form.style.update(flex=1)

    button = toga.Button('confirm', on_press=calculate)
    button.style.update(flex=1)
    box.add(button)
    box.style.update(direction=COLUMN)

    return box
Exemple #14
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.
        """
        main_box = toga.Box()

        for line in UI_data:
            box_tmp = toga.Box(style=Pack(flex=1))
            for el in line:
                if el['type'] == 'inputtext':
                    element_tmp = toga.TextInput(placeholder='enter expression here', readonly=True, style=Pack(flex=1, font_size=18))
                    self.input_text = element_tmp
                elif el['type'] == 'button':
                    element_tmp = toga.Button(el['name'], on_press=self.button_pressed, style=Pack(flex=1, padding=2, font_size=18))
                box_tmp.add(element_tmp)
            main_box.add(box_tmp)
        main_box.style.update(direction=COLUMN)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Exemple #15
0
    def startup(self):
        self.terms = []
        main_box = toga.Box(style=Pack(direction=COLUMN))

        term_label = toga.Label('Enter term(s): ', style=Pack(padding=(0, 5)))
        self.term_input = toga.TextInput(style=Pack(flex=1))

        term_box = toga.Box(style=Pack(direction=ROW, padding=5))
        term_box.add(term_label)
        term_box.add(self.term_input)

        term_button = toga.Button('Add term',
                                  on_press=self.term_list,
                                  style=Pack(padding=5))

        fetch_button = toga.Button('Fetch transcripts',
                                   on_press=self.hydra_fetch,
                                   style=Pack(padding=5))

        main_box.add(term_box)
        main_box.add(term_button)
        main_box.add(fetch_button)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Exemple #16
0
    def startup(self):
        self.db = {}
        self.root = None
        main_box = toga.Box(style=Pack(direction=COLUMN))

        self.pdf_tree = toga.Table(headings=['File'],
                                   data=[],
                                   on_double_click=self.rm_row,
                                   style=Pack(padding=5, width=250,
                                              height=600))

        self.select_btn = toga.Button('browse',
                                      on_press=self.select_cb,
                                      style=Pack(padding=5, width=120))

        self.merge_btn = toga.Button('merge',
                                     on_press=self.merge_cb,
                                     style=Pack(padding=5, width=120))

        info_panel = toga.Box(style=Pack(direction=ROW))
        info_panel.add(self.pdf_tree)

        button_panel = toga.Box(style=Pack(direction=ROW))
        button_panel.add(self.select_btn)
        button_panel.add(self.merge_btn)

        main_box.add(info_panel)
        main_box.add(button_panel)
        self.main_window = toga.MainWindow(title=self.formal_name,
                                           size=(250, 600))
        self.main_window.content = main_box
        self.main_window.show()
Exemple #17
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.
        """
        main_box = toga.Box(style=Pack(direction=COLUMN))

        name_label = toga.Label('Your name: ', style=Pack(padding=(0, 5)))
        self.name_input = toga.TextInput(style=Pack(flex=1))

        name_box = toga.Box(style=Pack(direction=ROW, padding=5))
        name_box.add(name_label)
        name_box.add(self.name_input)

        button = toga.Button('Say Hello!',
                             on_press=self.say_hello,
                             style=Pack(padding=5))

        main_box.add(name_box)
        main_box.add(button)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Exemple #18
0
    def startup(self):
        self.main_window = toga.MainWindow('main', title=self.title, size=self.size)

        self.top_container = toga.Box(children=[self.logo, self.price, self.currency],
            style=Pack(
                direction=COLUMN, alignment=CENTER
        ))

        self.bottom_container = toga.SplitContainer()
        right = toga.Box(
            children=[self.bid, self.bid_val, self.low, self.low_val, self.volume_24, self.volume_24_val],
            style=Pack(
                direction=COLUMN,
                padding_left=40, padding_top=20
            )
        )
        left = toga.Box(
            children=[self.ask, self.ask_val, self.high, self.high_val, self.volume, self.volume_val],
            style=Pack(
                direction=COLUMN,
                padding_left=40, padding_top=20
            )
        )
        self.bottom_container.content = [right, left]

        self.split = toga.SplitContainer(direction=toga.SplitContainer.HORIZONTAL)
        self.split.content = [self.top_container, self.bottom_container]

        self.main_window.content = self.split
        self.main_window.show()
Exemple #19
0
def build(app):
    def installHandle(widget):
        packageToInstall = packageInput.value
        resultInput.value = runScript(where_is_scripts + packageToInstall +
                                      ".sh")

    packages = get_packages(where_is_scripts, "test.sh",
                            "updateYapiScripts.sh")
    box = toga.Box()
    listBox = toga.Box()
    listLabel = toga.Label('Packages Available: ')
    packageBox = toga.Box()
    packageLabel = toga.Label('Package To Install:')
    packageInput = toga.TextInput()
    submitBox = toga.Box()
    install = toga.Button('Install Package', on_press=installHandle)
    resultBox = toga.Box()
    resultInput = toga.TextInput(readonly=True)

    listBox.add(listLabel)
    packageBox.add(packageLabel)
    packageBox.add(packageInput)
    submitBox.add(install)
    resultBox.add(resultInput)
    box.add(listBox)
    box.add(packageBox)
    box.add(submitBox)
    box.add(resultBox)

    box.style.update(direction=COLUMN, padding_top=10)
    listBox.style.update(direction=ROW, padding=5)
    packageBox.style.update(direction=ROW, padding=5)
    submitBox.style.update(direction=ROW, padding=5)
    return box
Exemple #20
0
    def startup(self):

        main_box = toga.Box(style=Pack(direction=COLUMN))

        name_label = toga.Label('Test Packet: ', style=Pack(padding=(0, 5)))
        self.test_packet = toga.TextInput(style=Pack(flex=1))

        name_box = toga.Box(style=Pack(direction=ROW, padding=5))
        name_box.add(name_label)
        name_box.add(self.test_packet)

        button = toga.Button('Send Test Packet',
                             on_press=self.send_packet,
                             style=Pack(padding=5))
        button1 = toga.Button('Toggle GPIO C0',
                              on_press=self.toggle_gpio,
                              style=Pack(padding=5))

        main_box.add(name_box)
        main_box.add(button)
        main_box.add(button1)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Exemple #21
0
def build(app):
    data = []
    for x in range(5):
        data.append([str(x) for x in range(5)])

    label = toga.Label('No row selected.')

    def selection_handler(widget, row):
        label.text = 'You selected row: {}'.format(row) if row is not None else 'No row selected'

    table = toga.Table(headings=['heading_{}'.format(x) for x in range(5)],
                       data=data,
                       style=CSS(flex=1),
                       on_select=selection_handler)

    def insert_handler(widget):
        table.data.insert(0, [str(round(random() * 100)) for _ in range(5)])
        table._impl.refresh()
        print('Rows', len(table.data.data))

    def delete_handler(widget):
        if len(table.data.data) > 0:
            table.data.remove(table.data.data[0])
            table._impl.refresh()
        else:
            print('Table is empty!')

    btn_style = CSS(flex=1)
    btn_insert = toga.Button('Insert Row', on_press=insert_handler, style=btn_style)
    btn_delete = toga.Button('Delete Row', on_press=delete_handler, style=btn_style)
    btn_box = toga.Box(children=[btn_insert, btn_delete], style=CSS(flex_direction='row'))

    box = toga.Box(children=[table, btn_box, label], style=CSS(flex=1, flex_direction='column', padding=10))
    return box
Exemple #22
0
    def create_display(self, state):
        super().__init__(style=Pack(padding=50, direction=COLUMN))
        self.add(toga.Label("Castaway Community"))
        cast_box = toga.Box(style=Pack(direction=COLUMN))
        # cast_scroll = toga.widgets.scrollcontainer.ScrollContainer(
        #     content=cast_box,
        #     style=Pack(height=200)
        # )
        for cast in state.get_cast():
            info_box = toga.Box(style=Pack(direction=ROW))
            cast_box.add(info_box)
            left_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            right_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            info_box.add(left_box)
            info_box.add(right_box)

            img = cast['img']
            left_box.add(toga.Label('Name: {}'.format(cast['name'])))
            left_box.add(
                toga.widgets.imageview.ImageView(
                    toga.Image('resources/images/'+img),
                    style=Pack(width=48, height=48, direction=COLUMN)
                )
            )
            right_box.add(toga.Label('Stats'))
            right_box.add(toga.Label('Age: {}'.format(cast['age'])))
        self.add(cast_box)
        super().create_display(state)
Exemple #23
0
    def startup(self):
        # Set up main window
        self.main_window = toga.MainWindow(title=self.name)

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

        self.tree = toga.Tree(headings=['Year', 'Title', 'Rating', 'Genre'],
                              data=DecadeSource(),
                              on_select=self.on_select_handler,
                              style=Pack(flex=1))

        # Buttons
        btn_style = Pack(flex=1)
        btn_insert = toga.Button('Insert Row',
                                 on_press=self.insert_handler,
                                 style=btn_style)
        btn_box = toga.Box(children=[btn_insert], style=Pack(direction=ROW))

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

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

        # Show the main window
        self.main_window.show()
Exemple #24
0
    def create_display(self, state):
        self.state = state
        state.new_game()
        self.add(toga.Label("Name your castaways"))
        cast_box = toga.Box(style=Pack(direction=COLUMN))
        self.cast = []
        for cast in state.get_cast():
            info_box = toga.Box(style=Pack(direction=ROW))
            cast_box.add(info_box)
            left_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            right_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
            info_box.add(left_box)
            info_box.add(right_box)

            img = cast['img']
            left_box.add(
                toga.widgets.imageview.ImageView(
                    toga.Image('resources/images/'+img),
                    style=Pack(width=48, height=48, direction=COLUMN)
                )
            )
            self.cast.append(
                toga.TextInput(initial=cast['name'], placeholder='Enter Name')
            )
            right_box.add(self.cast[-1])
        self.add(cast_box)
        button = toga.Button('Save', on_press=self.next, style=Pack(padding_bottom=0))
        self.add(button)
Exemple #25
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()
Exemple #26
0
    def startup(self):
        # Set up main window
        self.main_window = toga.MainWindow(title=self.name)
        self.main_window.app = self

        self.partner = Eliza()

        self.chat = toga.DetailedList(data=[{
            'icon':
            toga.Icon('resources/brutus.png'),
            'title':
            'Brutus',
            'subtitle':
            'Hello. How are you feeling today?',
        }],
                                      style=Pack(flex=1))

        # Buttons
        self.text_input = toga.TextInput(style=Pack(flex=1, padding=5))
        send_button = toga.Button('Send',
                                  on_press=self.handle_input,
                                  style=Pack(padding=5))
        input_box = toga.Box(children=[self.text_input, send_button],
                             style=Pack(direction=ROW))

        # Outermost box
        outer_box = toga.Box(children=[self.chat, input_box],
                             style=Pack(direction=COLUMN))

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

        # Show the main window
        self.main_window.show()
Exemple #27
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
Exemple #28
0
    def startup(self):
        # Create a main window with a name matching the app
        self.main_window = toga.MainWindow(title=self.name)
        global msgs
        global messages
        messages = toga.Table(headings=['IP', 'Message'], data=[])
        msgs = []
        input_box = toga.Box()
        message_input = toga.TextInput()

        def button_handler(widget):
            global sock
            sock.send(message_input.value.encode("utf-8"))
            message_input.value = ""

        button = toga.Button('Send', on_press=button_handler)

        # Create a main content box
        input_box.add(message_input)
        input_box.add(button)
        main_box = toga.Box()
        main_box.add(messages)
        main_box.add(input_box)

        input_box.style.update(direction=ROW)
        messages.style.update(flex=1)
        message_input.style.update(flex=1)
        main_box.style.update(direction=COLUMN, padding_top=10)

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

        # Show the main window
        self.main_window.show()
Exemple #29
0
    def startup(self):
        # Create a main window with a name matching the app
        self.main_window = toga.MainWindow(title=self.name, size=(360, 280))

        # Create a main content box
        main_box = toga.Box(style=Pack(direction=COLUMN))

        # Add something to the main box
        main_box.add(toga.Label('Hello World!', style=Pack(padding=5)))

        # Create another box and add it to main_box
        grid_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
        main_box.add(grid_box)

        # Add 4 x 5 array of Buttons to the grid box
        count = 1
        for row in range(5):
            row_box = toga.Box(style=Pack(padding=5))
            for col in range(4):
                row_box.add(toga.Button(f'{count}', style=Pack(padding=5)))
                count += 1
            grid_box.add(row_box)

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

        # Show the main window
        self.main_window.show()
Exemple #30
0
    def startup(self):
        async def hello_world_async():
            print("async hello from hello_world_async()")

        loop = AndroidEventLoop(SelectorMinusSelect())
        asyncio.set_event_loop(loop)
        loop.run_forever_cooperatively()

        asyncio.ensure_future(hello_world_async())

        main_box = toga.Box(style=Pack(direction=COLUMN))

        name_label = toga.Label("Your name: ", style=Pack(padding=(0, 5)))
        self.name_input = toga.TextInput(style=Pack(flex=1))

        name_box = toga.Box(style=Pack(direction=ROW, padding=5))
        name_box.add(name_label)
        name_box.add(self.name_input)

        button = toga.Button("Say Hello!",
                             on_press=self.say_hello,
                             style=Pack(padding=5))

        main_box.add(name_box)
        main_box.add(button)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()