Esempio n. 1
0
File: app.py Progetto: yconst/toga
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)

        # 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=Pack(flex=1),
                                 on_select=self.on_select_handler)

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

        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_reset = toga.Button('Reset Table',
                                on_press=self.reset_handler,
                                style=btn_style)
        btn_toggle = toga.Button('Toggle Column',
                                 on_press=self.toggle_handler,
                                 style=btn_style)
        btn_box = toga.Box(children=[
            btn_insert, btn_delete, btn_clear, btn_reset, btn_toggle
        ],
                           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()
Esempio n. 2
0
    def startup(self):
        # Initialization
        self.dfs = Dfs()

        self.main_window = toga.MainWindow(title=self.name, size=(1366, 720))
        self.main_container = toga.SplitContainer(
            style=Pack(flex=1, padding=(0, 5, -62, 5)),
            direction=toga.SplitContainer.HORIZONTAL,
        )
        self.search_results_table = toga.Table(
            headings=["Name", "Size", "Hash"],
            on_select=self.download,
            data=[])
        self.logs_table = toga.Table(headings=["Category", "Detail"], data=[])
        self.search_query_input = toga.TextInput(placeholder="Search Query",
                                                 style=Pack(flex=1))
        box = toga.Box(
            children=[
                toga.Box(
                    children=[
                        self.search_query_input,
                        toga.Button(
                            "Search",
                            on_press=self.search,
                            style=Pack(width=80, padding_left=5),
                        ),
                    ],
                    style=Pack(direction=ROW,
                               alignment=CENTER,
                               padding=(70, 5, 5, 5)),
                ),
                self.main_container,
            ],
            style=Pack(direction=COLUMN),
        )
        self.main_container.content = [
            self.search_results_table, self.logs_table
        ]
        add_file_cmd = toga.Command(
            self.share,
            label="Add File",
            tooltip="Select file to share",
            icon=Path("./res/icons/baseline_add_black_18dp.png").absolute(),
        )
        add_folder_cmd = toga.Command(
            self.share,
            label="Add Folder",
            tooltip="Select folder to share",
            icon=Path("./res/icons/baseline_add_black_18dp.png").absolute(),
        )
        # self.commands.add(add_file_cmd)
        self.main_window.toolbar.add(add_file_cmd, add_folder_cmd)
        self.main_window.content = box
        self.main_window.show()
Esempio n. 3
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=CSS(flex=1),
                                 on_select=self.on_select_handler)

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

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

        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()
Esempio n. 4
0
def build(app):
    # Label to show which row is currently selected.
    label = toga.Label('No row selected.')

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

    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=headings,
                       data=bee_movies[:4],
                       style=CSS(flex=1),
                       on_select=selection_handler)

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

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

    # Button callback functions
    def insert_handler(widget):
        table.data.insert(0, choice(bee_movies))
        print('Nr of rows', len(table.data.data))

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

    def clear_handler(widget):
        table.data.clear()

    # Buttons
    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_clear = toga.Button('Clear Table', on_press=clear_handler, style=btn_style)
    btn_box = toga.Box(children=[btn_insert, btn_delete, btn_clear], style=CSS(flex_direction='row'))

    # Most outer box
    box = toga.Box(children=[tablebox, btn_box, label],
                   style=CSS(flex=1,
                             flex_direction='column',
                             padding=10,
                             min_width=500, min_height=300))
    return box
Esempio n. 5
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()
Esempio n. 6
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()
Esempio n. 7
0
def build(app):
    #self.main_window = toga.MainWindow(self.name)
   # self.main_window.app = self
    box = toga.Box()

    table = toga.Table(headings=['Navigate', 'Size'], style=CSS(width=200,height=200))
#    table.style = CSS(height=50, width=614)

    table.insert(None, 'root1', '5mb')

    table.insert(None, 'root2', '5mb')

    table.insert(None, 'root2.1', '5mb')
    table.insert(None, 'root2.2', "12")

    table.insert(None, 'root2.2.1', "1212")
    table.insert(None, 'root2.2.3', '23')
    table.insert(None, 'root2.2.2', '23')

   # box.add(toga.Label("Hello"))
    box.add(table)
   # box.add(toga.Label("World"))
   # self.main_window.content = box
   # self.main_window.show()
    return box
Esempio n. 8
0
def build(app):
    brutus_icon = "icons/brutus"
    cricket_icon = "icons/cricket-72.png"

    data = [('root%s' % i, 'value %s' % i) for i in range(1, 100)]

    left_container = toga.Table(headings=['Hello', 'World'], data=data)

    right_content = toga.Box(style=Pack(direction=COLUMN, padding_top=50))

    for b in range(0, 10):
        right_content.add(
            toga.Button('Hello world %s' % b,
                        on_press=button_handler,
                        style=Pack(width=200, padding=20)))

    right_container = toga.ScrollContainer(horizontal=False)

    right_container.content = right_content

    split = toga.SplitContainer()

    split.content = [left_container, right_container]

    things = toga.Group('Things')

    cmd0 = toga.Command(action0,
                        label='Action 0',
                        tooltip='Perform action 0',
                        icon=brutus_icon,
                        group=things)
    cmd1 = toga.Command(action1,
                        label='Action 1',
                        tooltip='Perform action 1',
                        icon=brutus_icon,
                        group=things)
    cmd2 = toga.Command(action2,
                        label='Action 2',
                        tooltip='Perform action 2',
                        icon=toga.Icon.TOGA_ICON,
                        group=things)
    cmd3 = toga.Command(action3,
                        label='Action 3',
                        tooltip='Perform action 3',
                        shortcut=toga.Key.MOD_1 + 'k',
                        icon=cricket_icon)

    def action4(widget):
        print("CALLING Action 4")
        cmd3.enabled = not cmd3.enabled

    cmd4 = toga.Command(action4,
                        label='Action 4',
                        tooltip='Perform action 4',
                        icon=brutus_icon)

    app.commands.add(cmd1, cmd3, cmd4, cmd0)
    app.main_window.toolbar.add(cmd1, cmd2, cmd3, cmd4)

    return split
Esempio n. 9
0
    def customers(self, widget):
        self.cust_window = toga.Window(title="Customer Details")

        # 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=customers[:4],
            style=Pack(flex=1),
            multiple_select=False,
        )

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

        # Most outer box
        outer_box = toga.Box(children=[tablebox],
                             style=Pack(
                                 flex=1,
                                 direction=COLUMN,
                                 padding=10,
                             ))

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

        # Show the main window
        self.cust_window.show()
Esempio n. 10
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
Esempio n. 11
0
    def __init__(self, **kwargs):
        super().__init__()
        style = {'height': 300, 'direction': COLUMN}

        # Observable for selected Row
        self._selected_row = None
        self._observers_selected_row = []

        # Observable for data change
        self._data = []
        self._observers_data_change = []

        if 'headers' in kwargs.keys():
            # set headers. Ex.:
            # [
            #   {'name': 'vaultname',label': 'Name'},
            #   {'name': 'numberofarchives', 'label': '# Archives'},
            #   {'name': 'sizeinbytes', 'label': 'Size (MB)'},
            # ]
            self._headers = kwargs['headers']

        if 'height' in kwargs.keys():
            style['height'] = kwargs['height']

        # create Toga Table
        table_style = Pack(**style)
        self._toga_table = toga.Table(self._get_header_labels(),
                                      data=[],
                                      style=table_style,
                                      on_select=self._on_row_selected,
                                      accessors=self._get_header_names())
        self.getcontrols().add('Table', self._toga_table.id)
        self.basebox.add(self._toga_table)
Esempio n. 12
0
    def show_final_statistic(self, stat):
        profit = int(stat.total_profit)
        lost = stat.total_lost
        couriers = [
            round(c / stat.courier_max_load, 2) for c in stat.delivered_history
        ]
        self.st_window = toga.Window(title='итоговая статистика')

        self.drugs_daily_table = toga.Table(
            headings=['загруженность курьеров'], data=couriers)

        right_container = toga.Box()
        right_container.style.update(direction=COLUMN, padding_top=50)

        self.cur_couriers_label = toga.Label('прибыль ' + str(profit),
                                             style=Pack(text_align=RIGHT))
        cur_couriers_box = toga.Box(children=[self.cur_couriers_label])
        cur_couriers_box.style.padding = 50
        right_container.add(cur_couriers_box)
        self.max_couriers_label = toga.Label(
            'потеряно из-за списания и скидок ' + str(lost),
            style=Pack(text_align=RIGHT))
        max_couriers_box = toga.Box(children=[self.max_couriers_label])
        max_couriers_box.style.padding = 50
        right_container.add(max_couriers_box)

        split = toga.SplitContainer()

        split.content = [self.drugs_daily_table, right_container]

        self.st_window.content = split
        self.st_window.show()
Esempio n. 13
0
 def test_multiple_select(self):
     self.assertEqual(self.table.multiple_select, False)
     secondtable = toga.Table(
         self.headings,
         multiple_select=True,
         factory=toga_dummy.factory
     )
     self.assertEqual(secondtable.multiple_select, True)
Esempio n. 14
0
    def setUp(self):
        self.table = toga.Table(headings=("one", "two"))

        # make a shortcut for easy use
        self.gtk_table = self.table._impl

        self.window = Gtk.Window()
        self.window.add(self.table._impl.native)
Esempio n. 15
0
    def button_handler(self, button):
        main_box = self.main_window.content

        if 0 <= self.textEntry.value.find('0x'):
            value = int(self.textEntry.value, 0)
            virtual_address = bin(value)[2:]
            address_len = len(virtual_address)

            # Check length of bit string
            if address_len < int(self.textEntry1.value) or int(
                    self.textEntry1.value) < address_len:
                n = 13 - address_len
                virtual_address = ('0' * n) + virtual_address

            # Calculate VPN, TLB index, TLB tag

            # Firstly get offset (Where VPN starts)
            vpn_offset = int(math.log2(int(self.textEntry3.value)))
            vpn_bits = virtual_address[:-vpn_offset]
            vpn_value = hex(int(vpn_bits, 2))

            TLB_index_length = int(math.log2(int(self.textEntry2.value)))
            TLB_index_bits = virtual_address[-(vpn_offset +
                                               TLB_index_length):-vpn_offset]
            TLB_index_value = hex(int(TLB_index_bits, 2))

            TLB_tag_offset = vpn_offset + TLB_index_length
            TLB_tag_bits = virtual_address[:-TLB_tag_offset]
            TLB_tag_value = hex(int(TLB_tag_bits, 2))

            # Add the results to window

            # Labels
            label = toga.Label('Bits of virtual address',
                               style=Pack(flex=1, text_align='center'))
            label.style.font_size = 18
            label.style.font_family = 'monospace'
            label.style.font_weight = 'bold'

            address_label = toga.Label(virtual_address,
                                       style=Pack(flex=1, text_align='center'))
            address_label.style.font_size = 15
            address_label.style.font_family = 'monospace'
            address_label.style.font_weight = 'bold'

            headings = ['VPN', 'TLB index', 'TLB tag', 'VPO/PPO bits']
            table = toga.Table(headings=headings,
                               data=[(vpn_value, TLB_index_value,
                                      TLB_tag_value, vpn_offset)],
                               style=Pack(flex=1,
                                          height=50,
                                          padding=(10, 10, 10, 10)))

            main_box.add(label)
            main_box.add(address_label)
            main_box.add(table)

        self.main_window.content = main_box
Esempio n. 16
0
    def build(app):
        left_container = toga.Table(['Hello', 'World'])

        left_container.insert(None, 'root1', 'value1')
        left_container.insert(None, 'root2', 'value2')
        left_container.insert(None, 'root3', 'value3')
        left_container.insert(1, 'root4', 'value4')

        for i in range(0, 100):
            left_container.insert(None, 'root%s' % (i + 5),
                                  'value%s' % (i + 5))

        right_content = toga.Box(
            style=CSS(flex_direction='column', padding_top=50))

        for b in range(0, 10):
            right_content.add(
                toga.Button('Hello world %s' % b,
                            on_press=button_handler,
                            style=CSS(width=200, margin=20)))

        right_container = toga.ScrollContainer(horizontal=False)

        right_container.content = right_content

        split = toga.SplitContainer()

        split.content = [left_container, right_container]

        cmd1 = toga.Command(action1,
                            'Action 1',
                            tooltip='Perform action 1',
                            icon='icons/brutus.icns')
        cmd2 = toga.Command(action2,
                            'Action 2',
                            tooltip='Perform action 2',
                            icon=toga.TIBERIUS_ICON)
        cmd3 = toga.Command(action3,
                            'Action 3',
                            tooltip='Perform action 3',
                            icon='icons/cricket-72.png')

        def action4(widget):
            print("CALLING Action 4")
            cmd3.enabled = not cmd3.enabled

        cmd4 = toga.Command(action4,
                            'Action 4',
                            tooltip='Perform action 4',
                            icon='icons/brutus.icns')

        app.main_window.toolbar = [
            cmd1, toga.SEPARATOR, cmd2, toga.SPACER, cmd3,
            toga.EXPANDING_SPACER, cmd4
        ]

        return split
Esempio n. 17
0
def build(app):
    table_container = toga.Table(['Hello', 'World'])

    table_container.insert(None, 'root1', 'value1')
    table_container.insert(None, 'root2', 'value2')
    table_container.insert(None, 'root3', 'value3')
    table_container.insert(1, 'root4', 'value4')

    for i in range(0, 100):
        table_container.insert(None, 'root%s' % (i + 5), 'value%s' % (i + 5))

    return table_container
Esempio n. 18
0
    def setUp(self):
        super().setUp()

        self.headings = ['Heading 1', 'Heading 2', 'Heading 3']

        def select_handler(widget, row):
            pass

        self.on_select = select_handler

        self.table = toga.Table(self.headings,
                                on_select=self.on_select,
                                factory=toga_dummy.factory)
Esempio n. 19
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()
Esempio n. 20
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()
Esempio n. 21
0
    def create_tmp_stat(self):
        # todo - add button handler
        self.main_window = toga.MainWindow(title='ежедневная статистика')

        data = []
        self.drugs_daily_table = toga.Table(
            headings=['лекарства', 'цена', 'сегодня заказали', 'осталось'],
            data=data)

        right_container = toga.Box()
        right_container.style.update(direction=COLUMN, padding_top=50)

        self.cur_day_label = toga.Label('номер дня',
                                        style=Pack(text_align=RIGHT))
        cur_day_box = toga.Box(children=[self.cur_day_label])
        cur_day_box.style.padding = 20
        right_container.add(cur_day_box)
        self.cur_ordered_label = toga.Label('сегодня сделано заказов',
                                            style=Pack(text_align=RIGHT))
        cur_ordered_box = toga.Box(children=[self.cur_ordered_label])
        cur_ordered_box.style.padding = 20
        right_container.add(cur_ordered_box)
        self.cur_couriers_label = toga.Label('сегодня доставлено заказов',
                                             style=Pack(text_align=RIGHT))
        cur_couriers_box = toga.Box(children=[self.cur_couriers_label])
        cur_couriers_box.style.padding = 20
        right_container.add(cur_couriers_box)
        self.max_couriers_label = toga.Label('максимально можно доставить ',
                                             style=Pack(text_align=RIGHT))
        max_couriers_box = toga.Box(children=[self.max_couriers_label])
        max_couriers_box.style.padding = 20
        right_container.add(max_couriers_box)

        def next_day_handler(widget):
            self.env.start_next_day()

        button = toga.Button('start new day', on_press=next_day_handler)
        button.style.padding = 100
        button.style.width = 300
        right_container.add(button)

        split = toga.SplitContainer()

        split.content = [self.drugs_daily_table, right_container]

        self.main_window.content = split
        self.main_window.show()
Esempio n. 22
0
def build(app):
    left_box = toga.Box()
    left_box.style.update(direction=COLUMN, padding=10)
    left_input = toga.TextInput()
    left_label = toga.Label('Anagram', style=Pack(text_align=LEFT))
    solve_button = toga.Button('Solve')
    left_box.add(left_label)
    left_box.add(left_input)
    left_box.add(solve_button)
    left_box.style.update(flex=1, padding=5)

    table = toga.Table(['Words'])
    table.style.update(flex=1)

    main_box = toga.Box()
    main_box.add(left_box)
    main_box.add(table)
    return main_box
Esempio n. 23
0
def build(app):
	path=os.path.dirname(os.path.abspath(__file__))
	brutus_icon=os.path.join(path,"icons","brutus.icns")
	cricket_icon=os.path.join(path,"icons","cricket-72.png")


	#List of tuples added as table values
	data=[('root%s' % i, 'value %s' % i) for i in range(1,100)]
	left_container=toga.Table(headings=['Hello','World'], data=data)
	




	right_content=toga.Box(style=Pack(direction=COLUMN, padding_top=50))
#Dynamically add buttons
	for b in range(0,10):
		right_content.add(toga.Button('Hello world %s' % b,on_press=button_handler,style=Pack(width=200,padding=20)))


	right_container=toga.ScrollContainer(horizontal=False)
	right_container.content=right_content

	split=toga.SplitContainer()
	split.content=[left_container,right_container]
	

	things=toga.Group('Things')

	#Command object
	cmd0=toga.Command(action0,label='Action 0',tooltip='Perform action 0',icon=brutus_icon,group=things)
	cmd1=toga.Command(action1,label='Action 1',tooltip='Perform action 1',icon=brutus_icon,group=things)
	cmd2=toga.Command(action2,label='Action 2',tooltip='Perform action 2',icon=cricket_icon,group=things)
	cmd3=toga.Command(action3,label='Action 3',tooltip='Perform action 3',shortcut='k',icon=cricket_icon)
	cmd4=toga.Command(action4, label='Action 4',tooltip='Perform action 4',icon=brutus_icon)
	#Add commands as Menu Items
	app.commands.add(cmd1,cmd3,cmd4,cmd0)
	#Add commands as Icons on Toolbar
	app.main_window.toolbar.add(cmd1,cmd2,cmd3,cmd4)

	return split
Esempio n. 24
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()

        titleLabel = toga.Label("Quick Inch <-> MM Conversion Tool",
                                style=Pack(text_align=LEFT))

        left_container = toga.Box()

        left_container.add(titleLabel)

        data = [("TEST", "TEST 2", "TEST 3"), ("TEST 4", "TEST 5", "TEST 6")]

        right_container = toga.Table(
            headings=['INCH DEC', "INCH FRAC", "MILLIMETERS"], data=data)

        right_container.style.update(width=400)

        left_container.style.update(width=400, padding_left=10)

        split = toga.SplitContainer(direction="VERTICAL")

        split.style.update(width=1000)

        split.content = [right_container, left_container]

        main_box.add(split)

        main_box.style.update(direction=COLUMN, padding_top=10)

        titleLabel.style.update(width=350, padding_left=10, padding_bottom=10)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
Esempio n. 25
0
def build(app):
    def installHandle(widget):
        import installer
        result_label.value = installer.full_install(package_input.value)

    #Ian Test code
    package_list = [{'Discord', 'Chat for Gamers'},
                    {'Google Chrome', 'Web Browser'},
                    {'Dropbox', 'Upload/Download Files'}]
    left_container = toga.Table(headings=['Package', 'Description'],
                                data=package_list)
    right_content = toga.Box(style=Pack(direction=COLUMN, padding_top=50))

    #Add content to right side
    packageBox = toga.Box()
    text_label = toga.Label('Package:')
    package_input = toga.TextInput()
    submit = toga.Button('Install Package', on_press=installHandle)
    packageBox.add(text_label)
    packageBox.add(package_input)
    packageBox.add(submit)
    resultBox = toga.Box()
    result_label = toga.TextInput(readonly=True)
    result_text = toga.Label('Status:')
    resultBox.add(result_text)
    resultBox.add(result_label)
    right_content.add(packageBox)
    right_content.add(resultBox)

    right_container = toga.ScrollContainer(horizontal=False)
    right_container.content = right_content

    split = toga.SplitContainer()
    split.content = [left_container, right_container]
    things = toga.Group('Things')

    return split
Esempio n. 26
0
    def __init__(self, mdbx: MaestralProxy, app: toga.App) -> None:
        super().__init__(title="Maestral Activity", release_on_close=False, app=app)
        self.size = WINDOW_SIZE

        self._refresh = False
        self._refresh_interval = 1
        self._ids: set[str] = set()

        self.on_close = self.on_close_pressed

        self.mdbx = mdbx

        self.table = toga.Table(
            headings=["File", "Location", "Change", "Time", " "],
            accessors=["filename", "location", "type", "time", "reveal"],
            missing_value="--",
            on_double_click=self.on_row_clicked,
            style=Pack(flex=1),
        )
        self.table._impl.columns[-1].maxWidth = 25  # TODO: don't use private API
        self.content = self.table

        self.center()
        self._initial_load = False
Esempio n. 27
0
def build(app):
    brutus_icon = "icons/brutus"
    cricket_icon = "icons/cricket-72.png"

    data = [('root%s' % i, 'value %s' % i) for i in range(1, 100)]

    left_container = toga.Table(headings=['Hello', 'World'], data=data)

    right_content = toga.Box(style=Pack(direction=COLUMN, padding_top=50))

    for b in range(0, 10):
        right_content.add(
            toga.Button('Hello world %s' % b,
                        on_press=button_handler,
                        style=Pack(width=200, padding=20)))

    right_container = toga.ScrollContainer(horizontal=False)

    right_container.content = right_content

    split = toga.SplitContainer()

    # The content of the split container can be specified as a simple list:
    #    split.content = [left_container, right_container]
    # but you can also specify "weight" with each content item, which will
    # set an initial size of the columns to make a "heavy" column wider than
    # a narrower one. In this example, the right container will be twice
    # as wide as the left one.
    split.content = [(left_container, 1), (right_container, 2)]

    # Create a "Things" menu group to contain some of the commands.
    # No explicit ordering is provided on the group, so it will appear
    # after application-level menus, but *before* the Command group.
    # Items in the Things group are not explicitly ordered either, so they
    # will default to alphabetical ordering within the group.
    things = toga.Group('Things')
    cmd0 = toga.Command(action0,
                        label='Action 0',
                        tooltip='Perform action 0',
                        icon=brutus_icon,
                        group=things)
    cmd1 = toga.Command(action1,
                        label='Action 1',
                        tooltip='Perform action 1',
                        icon=brutus_icon,
                        group=things)
    cmd2 = toga.Command(action2,
                        label='Action 2',
                        tooltip='Perform action 2',
                        icon=toga.Icon.TOGA_ICON,
                        group=things)

    # Commands without an explicit group end up in the "Commands" group.
    # The items have an explicit ordering that overrides the default
    # alphabetical ordering
    cmd3 = toga.Command(action3,
                        label='Action 3',
                        tooltip='Perform action 3',
                        shortcut=toga.Key.MOD_1 + 'k',
                        icon=cricket_icon,
                        order=3)

    # Define a submenu inside the Commands group.
    # The submenu group has an order that places it in the parent menu.
    # The items have an explicit ordering that overrides the default
    # alphabetical ordering.
    sub_menu = toga.Group("Sub Menu", parent=toga.Group.COMMANDS, order=2)
    cmd5 = toga.Command(action5,
                        label='Action 5',
                        tooltip='Perform action 5',
                        order=2,
                        group=sub_menu)
    cmd6 = toga.Command(action6,
                        label='Action 6',
                        tooltip='Perform action 6',
                        order=1,
                        group=sub_menu)

    def action4(widget):
        print("CALLING Action 4")
        cmd3.enabled = not cmd3.enabled

    cmd4 = toga.Command(action4,
                        label='Action 4',
                        tooltip='Perform action 4',
                        icon=brutus_icon,
                        order=1)

    # The order in which commands are added to the app or the toolbar won't
    # alter anything. Ordering is defined by the command definitions.
    app.commands.add(cmd1, cmd0, cmd6, cmd4, cmd5, cmd3)
    app.main_window.toolbar.add(cmd1, cmd3, cmd2, cmd4)

    return split
Esempio n. 28
0
    def startup(self):
        # Create the main window
        self.main_window = toga.MainWindow(self.name)

        left_container = toga.OptionContainer()

        left_table = toga.Table(headings=['Hello', 'World'],
                                data=[
                                    ('root1', 'value1'),
                                    ('root2', 'value2'),
                                    ('root3', 'value3'),
                                    ('root4', 'value4'),
                                ])

        left_tree = toga.Tree(headings=['Navigate'],
                              data={
                                  ('root1', ): {},
                                  ('root2', ): {
                                      ('root2.1', ):
                                      None,
                                      ('root2.2', ): [
                                          ('root2.2.1', ),
                                          ('root2.2.2', ),
                                          ('root2.2.3', ),
                                      ]
                                  }
                              })

        left_container.add('Table', left_table)
        left_container.add('Tree', left_tree)

        right_content = toga.Box(style=Pack(direction=COLUMN))
        for b in range(0, 10):
            right_content.add(
                toga.Button('Hello world %s' % b,
                            on_press=self.button_handler,
                            style=Pack(padding=20)))

        right_container = toga.ScrollContainer()

        right_container.content = right_content

        split = toga.SplitContainer()

        split.content = [left_container, right_container]

        cmd1 = toga.Command(
            self.action1,
            'Action 1',
            tooltip='Perform action 1',
            icon='resources/brutus',
        )
        cmd2 = toga.Command(self.action2,
                            'Action 2',
                            tooltip='Perform action 2',
                            icon=toga.Icon.TOGA_ICON)

        self.main_window.toolbar.add(cmd1, cmd2)

        self.main_window.content = split

        # Show the main window
        self.main_window.show()
Esempio n. 29
0
def build(app):
    # Get Config and Language
    config = json.loads(config_import.get_config())
    os_platform = config['OS.platform']
    search_url = config['Search.search_url']
    file_extension = config['Remote.file_extension']
    search_local = ('True' == config['Search.search_local'])
    cache_location = config['Cache.cache_location']
    language_selected = config['Languages.selected']
    language = json.loads(
        config_import.get_language(language_selected, os_platform))

    # Button Handles
    def install_handle(widget):
        import modules.installer as installer
        return_code = installer.full_install(package_input.value)
        package_install_result.value = language['err_' + str(return_code)]

    def search_handle(widget):
        import modules.search as search
        pattern = search_input.value
        matches = search.search(search_url, file_extension, search_local,
                                cache_location, pattern)
        for match in matches:
            search_result.data.insert(0, match)

    # Main Boxes
    main_box = toga.Box()
    package_box = toga.Box()
    package_input_box = toga.Box()
    package_submit_box = toga.Box()
    search_box = toga.Box()
    search_input_box = toga.Box()
    search_results_box = toga.Box()

    # Package Install
    package_label = toga.Label('Package to Install:')
    package_input = toga.TextInput()
    package_input_box.add(package_label)
    package_input_box.add(package_input)

    package_submit = toga.Button('Install Package', on_press=install_handle)
    package_install_result = toga.TextInput(readonly=True)
    package_submit_box.add(package_submit)
    package_submit_box.add(package_install_result)

    package_box.add(package_input_box)
    package_box.add(package_submit_box)

    # Search Function
    data = []
    search_label = toga.Label('Search Pattern:')
    search_input = toga.TextInput()
    search_button = toga.Button('Search Pattern', on_press=search_handle)
    search_result = toga.Table(headings=['Package'], data=[])
    search_input_box.add(search_label)
    search_input_box.add(search_input)
    search_results_box.add(search_button)
    search_results_box.add(search_result)

    search_box.add(search_input_box)
    search_box.add(search_results_box)

    # Main Box
    main_box.add(package_box)
    main_box.add(search_box)

    # Style Changes
    main_box.style.update(direction=ROW, padding_top=10)
    package_box.style.update(direction=COLUMN, padding_top=10)
    search_box.style.update(direction=COLUMN, padding_top=10)
    package_input_box.style.update(direction=ROW, padding=5)
    search_input_box.style.update(direction=ROW, padding=5)
    search_results_box.style.update(direction=COLUMN, padding=5)

    # Return GUI
    return main_box
Esempio n. 30
0
    def startup(self):
        # Create the main window
        self.main_window = toga.MainWindow(self.name)
        self.main_window.app = self

        left_container = toga.OptionContainer()

        left_table = toga.Table(['Hello', 'World'])

        left_table.insert(None, 'root1', 'value1')
        left_table.insert(None, 'root2', 'value2')
        left_table.insert(None, 'root3', 'value3')
        left_table.insert(1, 'root4', 'value4')

        left_tree = toga.Tree(['Navigate'])

        left_tree.insert(None, None, 'root1')

        root2 = left_tree.insert(None, None, 'root2')

        left_tree.insert(root2, None, 'root2.1')
        root2_2 = left_tree.insert(root2, None, 'root2.2')

        left_tree.insert(root2_2, None, 'root2.2.1')
        left_tree.insert(root2_2, None, 'root2.2.2')
        left_tree.insert(root2_2, None, 'root2.2.3')

        left_container.add('Table', left_table)
        left_container.add('Tree', left_tree)

        right_content = toga.Box()
        for b in range(0, 10):
            right_content.add(
                toga.Button('Hello world %s' % b,
                            on_press=self.button_handler,
                            style=CSS(margin=20)))

        right_container = toga.ScrollContainer()

        right_container.content = right_content

        split = toga.SplitContainer()

        split.content = [left_container, right_container]

        cmd1 = toga.Command(self.action1,
                            'Action 1',
                            tooltip='Perform action 1',
                            icon=os.path.join(os.path.dirname(__file__),
                                              'icons/brutus-32.png'))
        cmd2 = toga.Command(self.action2,
                            'Action 2',
                            tooltip='Perform action 2',
                            icon=toga.TIBERIUS_ICON)

        self.main_window.toolbar = [cmd1, toga.SEPARATOR, cmd2]

        self.main_window.content = split

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