Ejemplo n.º 1
0
    def startup(self):
        self.main_window = toga.MainWindow(self.name)
        self.main_window.app = self

        self.webview = toga.WebView()

        self.main_window.content = self.webview

        self.webview.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
        self.webview.url = "https://djangoconus2017.slack.com/messages"

        self.main_window.show()
Ejemplo n.º 2
0
    def startup(self):
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(700, 500))

        # set up common styls
        label_style = Pack(flex=1, padding_right=24)
        box_style = Pack(direction=ROW, padding=10)
        slider_style = Pack(flex=1)

        self.sliderValueLabel = toga.Label("slide me", style=label_style)

        # Add the content on the main window
        self.main_window.content = toga.Box(children=[
            toga.Box(style=box_style,
                     children=[
                         toga.Label("default Slider -- range is 0 to 1",
                                    style=label_style),
                         toga.Slider(style=slider_style),
                     ]),
            toga.Box(
                style=box_style,
                children=[
                    toga.Label(
                        "on a scale of 1 to 10, how easy is GUI with Toga?",
                        style=label_style),
                    toga.Slider(range=(1, 10),
                                default=10,
                                style=Pack(width=150)),
                ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("Sliders can be disabled",
                                    style=label_style),
                         toga.Slider(enabled=False, style=slider_style),
                     ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("give a Slider some style!",
                                    style=label_style),
                         toga.Slider(style=slider_style)
                     ]),
            toga.Box(style=box_style,
                     children=[
                         self.sliderValueLabel,
                         toga.Slider(on_slide=self.my_on_slide,
                                     range=(-40, 58),
                                     style=slider_style),
                     ]),
        ],
                                            style=Pack(direction=COLUMN,
                                                       padding=24))

        self.main_window.show()
Ejemplo n.º 3
0
    def startup(self):
        main_box = toga.Box(style=Pack(direction=COLUMN))

        self.devices_box = toga.Box(style=Pack(direction=COLUMN, padding=5))
        main_box.add(self.devices_box)

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

        self.add_background_task(self.discover_devices)
        self.add_background_task(self.add_known_devices)
Ejemplo n.º 4
0
    def startup(self):
        self.main_window = toga.MainWindow('main',
                                           title=self.name,
                                           size=self.size)

        split = toga.SplitContainer()
        split.content = [self.table, self.information_area]

        self.main_window.content = split
        self.main_window.toolbar.add(self.next_command, self.previous_command)

        self.main_window.show()
Ejemplo n.º 5
0
    def startup(self):
        # Create a main window with a name matching the app
        self.main_window = toga.MainWindow(title=self.name)

        # Create a main content box
        main_box = toga.Box()

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

        # Show the main window
        self.main_window.show()
Ejemplo n.º 6
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()

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

        split_c = SplitContainer(direction=SplitContainer.VERTICAL)
        split_c.content = [toga.Label("Hi"), toga.TextInput()]

        m_box = toga.Box()
        #m_box.content = split_c
        self.main_window.content = m_box

        self.main_window.show()
Ejemplo n.º 8
0
    def startup(self):
        # Window class
        #   Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(200, 200))

        # Common style of the inner boxes
        style_inner_box = Pack(direction=ROW)

        # Button class
        #   Simple button with label and callback function called when
        #   hit the button
        button1 = toga.Button('Change Label', on_press=self.callbackLabel)

        # Button with label and enable option
        button2 = toga.Button('Disabled', enabled=False)

        # Button with label and style option
        button3 = toga.Button('Bigger', style=Pack(width=200))

        # Button with label and callback function called when
        #   hit the button
        button4 = toga.Button('Resize Window', on_press=self.callbackResize)

        # Box class
        # Container of components
        #   Add components for the first row of the outer box
        inner_box1 = toga.Box(style=style_inner_box,
                              children=[button1, button2, button3, button4])

        # Button with label and margin style
        button5 = toga.Button('Far from home', style=Pack(padding=50))

        # Button with label and RGB color
        button6 = toga.Button('RGB : Fashion',
                              style=Pack(background_color=RED))

        # Button with label and string color
        button7 = toga.Button('String : Fashion',
                              style=Pack(background_color=BLUE))

        # Add components for the second row of the outer box
        inner_box2 = toga.Box(style=style_inner_box,
                              children=[button5, button6, button7])

        #  Create the outer box with 2 rows
        outer_box = toga.Box(style=Pack(direction=COLUMN, height=10),
                             children=[inner_box1, inner_box2])

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

        # Show the main window
        self.main_window.show()
Ejemplo n.º 9
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.º 10
0
    def startup(self):
        self.main_window = toga.MainWindow(self.name)
        self.main_window.app = self

        # Label to show which row is currently selected.
        self.label = toga.Label('Ready.')

        # Create two tables with custom data sources; the data source
        # of the second reads from the first.
        # The headings are also in a different order.
        self.table1 = toga.Table(headings=['Year', 'Title', 'Rating', 'Genre'],
                                 data=MovieSource(),
                                 style=Pack(flex=1),
                                 on_select=self.on_select_handler)

        self.table2 = toga.Table(headings=['Rating', 'Title', 'Year', 'Genre'],
                                 data=GoodMovieSource(self.table1.data),
                                 style=Pack(flex=1))

        # Populate the table
        for entry in bee_movies:
            self.table1.data.add(entry)

        tablebox = toga.Box(children=[self.table1, self.table2],
                            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_delete = toga.Button('Delete Row',
                                 on_press=self.delete_handler,
                                 style=btn_style)
        btn_clear = toga.Button('Clear Table',
                                on_press=self.clear_handler,
                                style=btn_style)
        btn_box = toga.Box(children=[btn_insert, btn_delete, btn_clear],
                           style=Pack(direction=ROW))

        # Most outer box
        outer_box = toga.Box(children=[btn_box, tablebox, 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()
Ejemplo n.º 11
0
    def startup(self):
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(self.name, size=(700, 500))
        self.main_window.app = self

        self.sliderValueLabel = toga.Label("slide me")

        # set up common styls
        label_style = CSS(flex=1, padding_right=24)
        box_style = CSS(flex_direction="row", padding=24)

        # Add the content on the main window
        self.main_window.content = toga.Box(children=[
            toga.Box(style=box_style,
                     children=[
                         toga.Label("default Slider -- range is 0 to 1",
                                    style=label_style),
                         toga.Slider(),
                     ]),
            toga.Box(
                style=box_style,
                children=[
                    toga.Label(
                        "on a scale of 1 to 10, how easy is GUI with Toga?",
                        style=label_style),
                    toga.Slider(range=(1, 10), default=10),
                ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("Sliders can be disabled",
                                    style=label_style),
                         toga.Slider(enabled=False),
                     ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("give a Slider some style!",
                                    style=label_style),
                         toga.Slider(style=CSS(margin=16, width=300))
                     ]),
            toga.Box(
                style=box_style,
                children=[
                    toga.Label(
                        "use the 'on_slide' callback to respond to changes",
                        style=label_style),
                    toga.Slider(on_slide=self.my_on_slide, range=(-40, 58)),
                    self.sliderValueLabel
                ]),
        ],
                                            style=CSS(padding=24))

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

        # Label to show which row is currently selected.
        self.label = toga.Label('Ready.')

        # Data to populate the table.
        data = []
        for x in range(5):
            data.append(tuple(str(x) for x in range(5)))

        self.table1 = toga.Table(headings=headings,
                                 data=bee_movies[:4],
                                 style=CSS(flex=1),
                                 on_select=self.on_select_handler)

        self.table2 = toga.Table(headings=headings,
                                 data=self.table1.data,
                                 style=CSS(flex=1))

        tablebox = toga.Box(children=[self.table1, self.table2],
                            style=CSS(flex=1))

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

        # Most outer box
        outer_box = toga.Box(children=[btn_box, tablebox, self.label],
                             style=CSS(flex=1,
                                       flex_direction='column',
                                       padding=10,
                                       min_width=500,
                                       min_height=300))

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

        # Show the main window
        self.main_window.show()
Ejemplo n.º 13
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.', style=Pack(padding_top=20))

        # Buttons
        btn_style = Pack(flex=1)
        btn_info = toga.Button('Info', on_press=self.action_info_dialog, style=btn_style)
        btn_question = toga.Button('Question', on_press=self.action_question_dialog, style=btn_style)
        btn_open = toga.Button('Open File', on_press=self.action_open_file_dialog, style=btn_style)
        btn_save = toga.Button('Save File', on_press=self.action_save_file_dialog, style=btn_style)
        btn_select = toga.Button('Select Folder', on_press=self.action_select_folder_dialog, style=btn_style)
        dialog_btn_box = toga.Box(
            children=[
                btn_info,
                btn_question,
                btn_open,
                btn_save,
                btn_select
            ],
            style=Pack(direction=ROW)
        )
        # Dialog Buttons
        btn_style = Pack(flex=1)
        btn_do_stuff = toga.Button('Do stuff', on_press=self.do_stuff, style=btn_style)
        btn_clear = toga.Button('Clear', on_press=self.do_clear, style=btn_style)
        btn_box = toga.Box(
            children=[
                btn_do_stuff,
                btn_clear
            ],
            style=Pack(direction=ROW)
        )

        # Outermost box
        outer_box = toga.Box(
            children=[btn_box, dialog_btn_box, 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()
Ejemplo n.º 14
0
    def startup(self):
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(self.name, size=(400, 400))
        self.main_window.app = self

        # the user may change the value with +/- buttons
        self.progress2 = toga.ProgressBar(value=0)

        # the user may switch between "running" mode and a set value
        self.progress3 = toga.ProgressBar(value=3)

        # set up common styls
        label_style = CSS(flex=1, padding_right=24)
        box_style = CSS(flex_direction="row", padding=24)

        # Add the content on the main window
        self.main_window.content = toga.Box(
            children=[

                toga.Box(style=box_style, children=[
                    toga.Label("default ProgressBar", style=label_style),

                    toga.ProgressBar(),
                ]),

                toga.Box(style=CSS(padding=24), children=[
                    toga.Label("Use the +/- buttons to change the progress",
                               style=label_style),

                    self.progress2,

                    toga.Box(
                        children=[
                            toga.Button("+", on_press=self.increase_progress2,
                                        style=CSS(margin=8, flex=1)),
                            toga.Button("-", on_press=self.decrease_progress2,
                                        style=CSS(margin=8, flex=1)),
                        ],
                        style=CSS(flex=1, flex_direction="row")
                    ),
                ]),

                toga.Box(style=box_style, children=[
                    toga.Switch("Toggle running mode")
                    self.progress3    
                ])
            ],
            style=CSS(padding=24)
        )

        self.main_window.show()
Ejemplo n.º 15
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.º 16
0
Archivo: app.py Proyecto: uranusjr/toga
    def startup(self):
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(title=self.name, size=(148, 250))

        # Create canvas and draw tiberius on it
        self.canvas = toga.Canvas(style=Pack(flex=1))
        box = toga.Box(children=[self.canvas])
        self.draw_tiberius()

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

        # Show the main window
        self.main_window.show()
Ejemplo n.º 17
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.º 18
0
    def startup(self):
        self.main_window = toga.MainWindow(self.name)
        box = toga.Box()
        box.style.direction = COLUMN

        for x in range(100):
            label_text = 'Label %d' % (x)
            box.add(toga.Label(label_text, style=Pack(text_align=LEFT)))

        scroller = toga.ScrollContainer()
        scroller.content = box

        self.main_window.content = scroller
        self.main_window.show()
Ejemplo n.º 19
0
    def startup(self):
        # Set up main window
        self.main_window = toga.MainWindow(title=self.name)

        self.chart = toga_chart.Chart(style=Pack(flex=1))

        self.main_window.content = toga.Box(children=[
            self.chart,
        ],
                                            style=Pack(direction=COLUMN))

        self.chart.draw(sample_histogram())

        self.main_window.show()
Ejemplo n.º 20
0
    def startup(self):
        # Window class
        #   Main window of the application with title and size
        self.main_window = toga.MainWindow(self.name, size=(148, 200))
        self.main_window.app = self

        self.canvas = toga.Canvas(on_draw=self.draw_tiberius)
        box = toga.Box(children=[self.canvas])

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

        # Show the main window
        self.main_window.show()
Ejemplo n.º 21
0
    def startup(self):
        # Define the main box app
        main_box = toga.Box()

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

        # Define a intro label for the user
        # NOTE: should I store this inside a box?
        self.intro_label = toga.Label('Escolha um campi', id='intro_text')

        # Creating a selection of campus for the user
        self.campus_selection = toga.Selection(items=[
            'Araranguá', 'Blumenau', 'Curitibanos', 'Florianópolis',
            'Joinville', 'CCA'
        ])
        # Implement on_press function
        #self.search_menu_button = toga.Button('Ver cardápio', on_press=self.search_menu(self.campus_selection))
        self.search_menu_button = toga.Button('Ver cardápio')

        # Creating some more boxes
        intro_label_box = toga.Box()
        intro_label_box.add(self.intro_label)

        selection_box = toga.Box()
        selection_box.add(self.campus_selection)

        button_box = toga.Box()
        button_box.add(self.search_menu_button)

        # Styling the boxes
        main_box.style.update(direction=COLUMN, padding_top=10)
        intro_label_box.style.update(direction=ROW, padding=5)
        selection_box.style.update(direction=ROW, padding=5)
        button_box.style.update(direction=ROW, padding=5)

        intro_label_box.style.update(flex=1)
        selection_box.style.update(flex=1, padding_left=160)

        intro_label_box.style.update(width=100, padding_left=10)
        selection_box.style.update(width=100, padding_left=10)

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

        main_box.add(intro_label_box)
        main_box.add(selection_box)
        main_box.add(button_box)

        return main_box
Ejemplo n.º 22
0
    def startup(self): 
        self.amount=0
        main_box = toga.Box(style=Pack(direction=COLUMN))        
        

        name_label = toga.Label(
            'Your counter is at ',
            style=Pack(padding=(0, 5))
        )
        self.result = toga.TextInput(readonly=True)
        self.result.value= self.amount
        
        #button functions
        button_add_1 = toga.Button(
            'Click me to \nadd one \nto the counter',
            on_press=self.add_1,
            style=Pack(padding=5)
        )

        button_add_10 = toga.Button(
            'Click me to \nadd ten \nto the counter',
            on_press=self.add_10,
            style=Pack(padding=5)
        )

        button_sub_1 = toga.Button(
            'Click me to \nsubtract one \nto the counter',
            on_press=self.sub_1,
            style=Pack(padding=5)
        )

        button_sub_10 = toga.Button(
            'Click me to \nsubtract ten \nto the counter',
            on_press=self.sub_10,
            style=Pack(padding=5)
        )

        #add the buttons to the screen
        main_box.add(name_label)
        main_box.add(self.result)
        main_box.add(button_add_1)
        main_box.add(button_add_10)
        main_box.add(button_sub_1)
        main_box.add(button_sub_10)
        


        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 23
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.º 24
0
    def startup(self):
        # Main window of the application with title and size
        self.main_window = toga.MainWindow(self.name, size=(640, 400))
        self.main_window.app = self

        # set up common styls
        label_style = CSS(flex=1, padding_right=24)
        box_style = CSS(flex_direction="row", padding=24)

        # Add the content on the main window
        self.main_window.content = toga.Box(children=[
            toga.Box(
                style=box_style,
                children=[
                    toga.Label("Select an element", style=label_style),
                    toga.Selection(items=["Carbon", "Ytterbium", "Thulium"])
                ]),
            toga.Box(
                style=box_style,
                children=[
                    toga.Label(
                        "use the 'on_select' callback to respond to changes",
                        style=label_style),
                    toga.Selection(on_select=self.my_on_select,
                                   items=["Dubnium", "Holmium", "Zirconium"])
                ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("Long lists of items should scroll",
                                    style=label_style),
                         toga.Selection(items=dir(toga)),
                     ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("use some style!", style=label_style),
                         toga.Selection(
                             style=CSS(width=200, padding=24),
                             items=["Curium", "Titanium", "Copernicium"])
                     ]),
            toga.Box(style=box_style,
                     children=[
                         toga.Label("Selection widgets can be disabled",
                                    style=label_style),
                         toga.Selection(enabled=False)
                     ]),
        ],
                                            style=CSS(padding=24))

        self.main_window.show()
Ejemplo n.º 25
0
    def _2021_11_07b_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        x = 32
        y = 185
        font = toga.Font(family=SANS_SERIF, size=20)
        width, height = self.canvas.measure_text('Tiberius', font, tight=True)
        with self.canvas.stroke(line_width=4.0) as rect_stroker:
            rect_stroker.rect(x, y - height, width, height)
        with self.canvas.fill(color=rgb(149, 119, 73)) as text_filler:
            text_filler.write_text('Tiberius', x, y, font)
        # Show the main window
        self.main_window.show()
Ejemplo n.º 26
0
    def _2021_11_07_startup(self):
        self.main_window = toga.MainWindow(title=self.name, size=(250, 250))
        self.canvas = toga.Canvas(style=Pack(flex=1))
        self.main_window.content = toga.Box(children=[self.canvas])

        with self.canvas.stroke(line_width=4.0, color=rgb(255, 200, 200), line_dash=[4, 4]) as stroke:
            # Draw an arc
            stroke.arc(40, 100, 10, endangle=math.pi * 1.5)
            # Create a new path, which will cause the canvas to "forget" that arc was ever drawn
            stroke.new_path()
            # Draw an arc lower down the screen, instead.
            stroke.arc(80, 200, 10, endangle=math.pi * 1.5)

        # Show the main window
        self.main_window.show()
Ejemplo n.º 27
0
    def startup(self):
        self.main_window = toga.MainWindow(title=self.formal_name)

        main_box = toga.Box()
        main_box.add(
            toga.Label('Batatinha Frita', style=Pack(font_size=50,
                                                     padding=50)),
            toga.TextInput(placeholder='Sua batata preferida'),
            toga.Button('Click me',
                        on_press=partial(meu_box, self.main_window)),
        )
        main_box.style.update(direction=COLUMN)

        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 28
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()

        #self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window = toga.MainWindow(
            title="System Usability Scale (SUS) implemented by Dr. Jibo HE")
        self.main_window.content = main_box
        self.main_window.show()
Ejemplo n.º 29
0
Archivo: app.py Proyecto: yconst/toga
    def startup(self):
        # Set up main window
        self.main_window = toga.MainWindow(title=self.name, size=(148, 200))

        canvas = toga.Canvas(style=Pack(flex=1),
                             on_resize=self.resize_contents)
        box = toga.Box(children=[canvas])

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

        # Show the main window
        self.main_window.show()

        self.render_drawing(canvas, *self.main_window.size)
Ejemplo n.º 30
0
Archivo: app.py Proyecto: saroad2/toga
    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()
        self.commands.add(
            toga.Command(self.toggle_up,
                         "Toggle Up",
                         shortcut=toga.Key.MOD_1 + toga.Key.UP,
                         group=toga.Group.VIEW,
                         order=1),
            toga.Command(self.toggle_down,
                         "Toggle Down",
                         shortcut=toga.Key.MOD_1 + toga.Key.DOWN,
                         group=toga.Group.VIEW,
                         order=2),
            toga.Command(self.toggle_left,
                         "Toggle Left",
                         shortcut=toga.Key.MOD_1 + toga.Key.LEFT,
                         group=toga.Group.VIEW,
                         order=3),
            toga.Command(self.toggle_right,
                         "Toggle Right",
                         shortcut=toga.Key.MOD_1 + toga.Key.RIGHT,
                         group=toga.Group.VIEW,
                         order=4),
        )