def __init__(self, flex):
        """Initialize box."""
        super().__init__(style=Pack(direction=COLUMN, flex=flex))

        self.__title_input = self.__add_column_option("Title:")
        self.__residuals_title_input = self.__add_column_option(
            "Residuals title:")
        self.__xlabel_input = self.__add_column_option("X label:")
        self.__ylabel_input = self.__add_column_option("Y label:")

        self.__grid_switch = toga.Switch(label="Grid")
        self.__legend_switch = toga.Switch(label="Legend")
        self.add(LineBox(children=[self.__grid_switch, self.__legend_switch]))

        self.__x_domain_switch = toga.Switch(
            label="Custom X domain",
            on_toggle=lambda _: self.x_domain_switch_handler())
        self.__x_min_title = toga.Label("X minimum:",
                                        style=Pack(visibility=HIDDEN))
        self.__x_min_input = toga.TextInput(style=Pack(visibility=HIDDEN))
        self.__x_max_title = toga.Label("X maximum:",
                                        style=Pack(visibility=HIDDEN))
        self.__x_max_input = toga.TextInput(style=Pack(visibility=HIDDEN))
        self.add(
            LineBox(children=[
                self.__x_domain_switch,
                self.__x_min_title,
                self.__x_min_input,
                self.__x_max_title,
                self.__x_max_input,
            ]))
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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 __init__(self, flex):
        """Initialize box."""
        super(FittingFunctionBox, self).__init__(
            style=Pack(direction=COLUMN, flex=flex)
        )
        fit_function_box = LineBox()
        fit_function_box.add(toga.Label(text="Fitting function:"))
        self.fitting_function_selection = toga.Selection(
            on_select=self.load_select_fit_function_name,
        )
        fit_function_box.add(self.fitting_function_selection)
        self.fitting_function_syntax = toga.TextInput(
            readonly=True,
            style=Pack(flex=1, padding_left=BIG_PADDING, padding_right=BIG_PADDING),
        )
        fit_function_box.add(self.fitting_function_syntax)
        self.load_module_button = toga.Button(
            label="Load module", on_press=self.load_module
        )
        fit_function_box.add(self.load_module_button)
        self.add(fit_function_box)

        self.parameters_box = LineBox()
        self.parameters_box.add(toga.Label("Parameters:"))
        self.parameter_inputs = toga.TextInput(
            readonly=True,
            style=Pack(width=PARAMETER_WIDTH),
            on_change=lambda widget: self.reset_fit_function(),
        )
        self.parameters_box.add(self.parameter_inputs)
        self.add(self.parameters_box)

        self.update_fitting_function_options()
Ejemplo n.º 6
0
    def startup(self):
        main_box = toga.Box(style=Pack(direction=COLUMN))

        self.math_label = toga.Label(
            'First math game:',
            style=Pack(padding=(0, 10))
        )
        self.task_display = toga.TextInput(style=Pack(flex=1))
        self.user_input = toga.TextInput(style=Pack(flex=1))


        math_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
        math_box.add(self.math_label)
        math_box.add(self.task_display)
        math_box.add(self.user_input)

        button = toga.Button(
            'Submit answer!!',
            on_press=self.change_index(),
            style=Pack(padding=5)
        )

        main_box.add(math_box)
        main_box.add(button)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 7
0
    def products(self, widget):
        main_box = toga.Box(style=Pack(
            padding=250, padding_top=50, direction=COLUMN, alignment=CENTER))

        name_label = toga.Label('Product Name: ', style=Pack(padding=(10, 2)))
        self.product_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.product_name_input)

        # Phone number
        phone_label = toga.Label('Model Number: ', style=Pack(padding=(10, 5)))
        self.model_input = toga.TextInput(style=Pack(flex=1))

        phone_box = toga.Box(style=Pack(direction=ROW, padding=5))
        phone_box.add(phone_label)
        phone_box.add(self.model_input)

        button = toga.Button('Show',
                             on_press=self.get_product,
                             style=Pack(padding_top=25,
                                        width=100,
                                        alignment=CENTER))

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

        self.prooduct_window = toga.Window(title="Products")
        self.prooduct_window.content = main_box
        self.prooduct_window.show()
Ejemplo n.º 8
0
Archivo: app.py Proyecto: xmonader/toga
    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()
Ejemplo n.º 9
0
    def startup(self):
        main_box = toga.Box()
        w_box = toga.Box()
        m_box = toga.Box()
        f_box = toga.Box()

        w_input = toga.TextInput()
        m_input = toga.PasswordInput()
        f_input = toga.TextInput(readonly=True)

        w_label = toga.Label('Website:', style=Pack(text_align=CENTER))
        m_label = toga.Label('Master Password:'******'Your Password:'******'Generate Password', on_press=genPasswd)

        w_box.add(w_label)
        w_box.add(w_input)

        m_box.add(m_label)
        m_box.add(m_input)

        f_box.add(f_label)
        f_box.add(f_input)

        main_box.add(w_box)
        main_box.add(m_box)
        main_box.add(f_box)
        main_box.add(button)

        main_box.style.update(direction=COLUMN, padding_top=10)
        w_box.style.update(direction=ROW, padding=5, padding_bottom=50)
        m_box.style.update(direction=ROW, padding=5, padding_bottom=50)
        f_box.style.update(direction=ROW, padding=5)

        w_input.style.update(flex=1, padding_right=10)
        m_input.style.update(flex=1, padding_right=10)
        f_input.style.update(flex=1, padding_right=10)
        w_label.style.update(flex=1)
        m_label.style.update(flex=1)
        f_label.style.update(flex=1)

        button.style.update(padding=15, flex=1)

        self.main_window = toga.MainWindow(title=self.formal_name, size=(446, 308))
        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 10
0
    def startup(self):
        # Set up main window
        self.main_window = toga.MainWindow(title=self.name)

        # Labels to show responses.
        self.label = toga.Label('Enter some values and press extract.',
                                style=Pack(padding=10))
        self.text_label = toga.Label('Ready.', style=Pack(padding=10))
        self.password_label = toga.Label('Ready.', style=Pack(padding=10))
        self.password_content_label = toga.Label(EMPTY_PASSWORD,
                                                 style=Pack(padding_bottom=10,
                                                            font_size=9))
        self.number_label = toga.Label('Ready.', style=Pack(padding=10))

        # Text inputs and a button
        self.text_input = toga.TextInput(placeholder='Type something...',
                                         style=Pack(padding=10))
        self.password_input = toga.PasswordInput(
            placeholder='Password...',
            style=Pack(padding=10),
            on_change=self.on_password_change)
        self.email_input = toga.TextInput(placeholder='Email...',
                                          style=Pack(padding=10),
                                          validator=self.validate_email)
        self.number_input = toga.NumberInput(style=Pack(padding=10))
        btn_extract = toga.Button('Extract values',
                                  on_press=self.do_extract_values,
                                  style=Pack(flex=1))

        # Outermost box
        box = toga.Box(children=[
            self.label,
            self.text_input,
            self.password_input,
            self.password_content_label,
            self.email_input,
            self.number_input,
            self.text_label,
            self.password_label,
            self.number_label,
            btn_extract,
        ],
                       style=Pack(
                           flex=1,
                           direction=COLUMN,
                           padding=10,
                       ))

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

        # Show the main window
        self.main_window.show()
Ejemplo n.º 11
0
    def startup(self):
        #adding two boxes for celsius and fahrenheit
        main_box = toga.Box()
        c_box = toga.Box()
        f_box = toga.Box()

        c_input = toga.TextInput(readonly=True)
        f_input = toga.TextInput()

        #creating labels

        c_label = toga.Label('Celsius', style=Pack(text_align="left"))
        f_label = toga.Label('Fahrenheit', style=Pack(text_align="left"))
        join_label = toga.Label('is equivalent to',
                                style=Pack(text_align="left"))

        def calculate(widget):
            try:
                c_input.value = (float(f_input.value) - 32.0) * 5.0 / 9.0
            except:
                pass

        button = toga.Button('Calculate', on_press=calculate)

        f_box.add(f_input)
        f_box.add(f_label)

        c_box.add(join_label)
        c_box.add(c_input)
        c_box.add(c_label)

        main_box.add(f_box)
        main_box.add(c_box)
        main_box.add(button)

        main_box.style.update(direction=COLUMN, padding_top=10)
        f_box.style.update(direction=ROW, padding_top=5)
        c_box.style.update(direction=ROW, padding_top=5)

        c_input.style.update(flex=1)
        f_input.style.update(flex=1, padding_left=160)
        c_label.style.update(width=100, padding_left=10)
        f_label.style.update(width=100, padding_left=10)
        join_label.style.update(width=140, padding_left=10)

        button.style.update(padding=15, flex=1)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 12
0
    def startup(self):
        self.main_window = toga.MainWindow(self.name)
        self.main_window.app = self

        # Tutorial 1
        c_box = toga.Box()
        f_box = toga.Box()
        box = toga.Box()

        self.c_input = toga.TextInput(readonly=True)
        self.f_input = toga.TextInput()

        c_label = toga.Label('Celcius', alignment=toga.LEFT_ALIGNED)
        f_label = toga.Label('Fahrenheit', alignment=toga.LEFT_ALIGNED)
        join_label = toga.Label('is equivalent to',
                                alignment=toga.RIGHT_ALIGNED)

        button = toga.Button('Calculate', on_press=self.calculate)
        container = OptionContainer(style=CSS(width=600))

        f_box.add(self.f_input)
        f_box.add(f_label)

        c_box.add(join_label)
        c_box.add(self.c_input)
        c_box.add(c_label)

        box.add(f_box)
        box.add(c_box)
        box.add(button)

        table = toga.Table(['Hello', 'World'], style=CSS(width=200))

        t_box = toga.Box(style=CSS(
            width=500, height=300, padding_top=50, flex_direction='row'))
        t_box.add(toga.TextInput(style=CSS(width=400)))
        t_box.add(toga.Button("Hi"))
        table.insert(None, 'Value 1', 'Value 2')

        container = self.get_container(container, [box, table, t_box])

        container.add("test", toga.TextInput(style=CSS(width=400)))

        box.style.set(flex_direction='column', padding_top=10)

        x_box = toga.Box(style=CSS(flex_direction="column", width=300))
        x_box.add(container)

        self.main_window.content = x_box
        self.main_window.show()
Ejemplo n.º 13
0
    def startup(self):
        main_box = toga.Box()
        time_box = toga.Box()
        butt_box = toga.Box()
        table_box = toga.Box()
        info_box = toga.Box()

        time_label = toga.Label('Enter feeding time:', style=Pack(padding=10, padding_top=20))

        # TODO: Check if input is valid, on_change=self.validate_input??
        self.hour_input = toga.TextInput(placeholder='Hour', style=Pack(padding=10))
        self.min_input = toga.TextInput(placeholder='Minute', style=Pack(padding=10))
        time_box.add(time_label)
        time_box.add(self.hour_input)
        time_box.add(self.min_input)

        add_to_table_butt = toga.Button('Add time', on_press=self.addTime, style=Pack(padding=10))
        clear_table_butt = toga.Button('Clear times', on_press=self.clearTable, style=Pack(padding=10))
        self.send_butt = toga.Button('Send time', on_press=self.sendFeedingTime, style=Pack(padding=10))
        get_butt = toga.Button('Get times', on_press=self.getFeedingTimes, style=Pack(padding=10))
        self.send_butt.enabled = False
        butt_box.add(add_to_table_butt)
        butt_box.add(clear_table_butt)
        butt_box.add(self.send_butt)
        butt_box.add(get_butt)

        self.time_table = toga.Table(
            headings=['Feeding Times'],
            multiple_select=False
        )
        table_box.add(self.time_table)

        self.error_label = toga.Label('', style=Pack(padding=10, padding_top=20))
        info_box.add(self.error_label)

        main_box.add(time_box)
        main_box.add(butt_box)
        main_box.add(table_box)
        main_box.add(info_box)

        main_box.style.update(direction=COLUMN, padding_top=10)
        time_box.style.update(direction=ROW, padding=5)
        butt_box.style.update(direction=ROW, padding=5)
        table_box.style.update(direction=ROW, padding=5)
        info_box.style.update(direction=ROW, padding=5)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 14
0
    def __init__(self, main_window): # note: to alter another class, add
        # the object as a parameter
        # This is just the test box items, doesn't do a lot.
        self.main_window = main_window
        self.nothing_label = toga.Label(
            'See what happens:',
            style=Pack(padding=(0, 5))
            )
        self.nothing_input = toga.TextInput(
            initial="Moo?",
            style=Pack(flex=1)
            )
        self.nothing_button = toga.Button(
            'Click me now.',
            on_press=self.say_nothing,
            style=Pack(padding=(0, 5))
            )

        # Nothing box with relevant items
        self.nothing_box = toga.Box(
            children=[
                self.nothing_label,
                self.nothing_input,
                self.nothing_button
                ],
            style=Pack(direction=ROW, alignment=CENTER, padding_top=5)
            )
Ejemplo n.º 15
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()
Ejemplo n.º 16
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()
Ejemplo n.º 17
0
    def __init__(self, on_choose_record):
        """Initialize box."""
        super().__init__()
        self.__sheet_selection_enabled = False
        self.on_input_file_change = None
        self.on_csv_read = None
        self.on_excel_read = None
        self.on_select_excel_file = None

        self.__input_file_path = toga.TextInput(readonly=True,
                                                style=Pack(flex=1))
        self.__select_file_button = toga.Button(
            label="Choose file",
            on_press=self.select_file,
            style=Pack(padding_left=SMALL_PADDING),
        )
        self.add(
            toga.Label(text="Input file:"),
            self.__input_file_path,
            self.__select_file_button,
            toga.Button(
                label="Choose records",
                on_press=on_choose_record,
                style=Pack(padding_left=SMALL_PADDING),
            ),
        )

        self.__sheet_label = toga.Label(text="Sheet:")
        self.__sheet_selection = toga.Selection(on_select=self.select_sheet)
Ejemplo n.º 18
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()
Ejemplo n.º 19
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()
Ejemplo n.º 20
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()
Ejemplo n.º 21
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()
Ejemplo n.º 22
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)
Ejemplo n.º 23
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()
Ejemplo n.º 24
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()
Ejemplo 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.
        """
        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()
Ejemplo n.º 26
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()
Ejemplo n.º 27
0
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
Ejemplo n.º 28
0
    def __init__(self, flex):
        """Initialize box."""
        super().__init__(style=Pack(direction=COLUMN, flex=flex))
        self.fitting_function_box = LineBox()
        self.fitting_function_box.add(toga.Label(text="Fitting function:"))
        self.fitting_function_selection = toga.Selection(
            on_select=self.load_select_fitting_function_name, )
        self.fitting_function_box.add(self.fitting_function_selection)
        self.fitting_function_syntax = toga.TextInput(
            readonly=True,
            style=Pack(flex=1,
                       padding_left=BIG_PADDING,
                       padding_right=BIG_PADDING),
        )
        self.fitting_function_box.add(self.fitting_function_syntax)
        self.load_module_button = toga.Button(label="Load module",
                                              on_press=self.load_module)
        self.fitting_function_box.add(self.load_module_button)
        self.add(self.fitting_function_box)

        self.polynomial_degree_title = toga.Label("Degree:")
        self.polynomial_degree_input = toga.NumberInput(
            min_value=1,
            max_value=5,
            default=1,
            on_change=lambda widget: self.set_polynomial_degree(),
        )

        self.update_fitting_function_options()
Ejemplo n.º 29
0
    def __init__(self, on_fitting_function_load):
        """Initialize box."""
        super().__init__()
        self.__fitting_function = None
        self.on_fitting_function_load = None
        self.__polynomial_is_set = False

        self.add(toga.Label(text="Fitting function:"))
        self.fitting_function_selection = toga.Selection(
            on_select=self.load_select_fitting_function_name,
        )
        self.fitting_function_syntax = toga.TextInput(
            readonly=True,
            style=Pack(flex=1, padding_left=BIG_PADDING, padding_right=BIG_PADDING),
        )
        self.add(self.fitting_function_selection, self.fitting_function_syntax)

        self.polynomial_degree_title = toga.Label("Degree:")
        self.polynomial_degree_input = toga.NumberInput(
            min_value=1,
            max_value=5,
            default=1,
            on_change=lambda widget: self.set_polynomial_degree(),
        )

        self.update_fitting_function_options()
        self.on_fitting_function_load = on_fitting_function_load
Ejemplo n.º 30
0
 def createInput(self, id, placeholder):
     """returns a standard input with an id of id param."""
     return toga.TextInput(
         id=id,
         placeholder=placeholder,
         style=Pack(flex=1, padding=2)
     )