コード例 #1
0
    def startup(self):
        self.main_window = toga.MainWindow('main', title=self.title, size=self.size)

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

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

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

        self.main_window.content = self.split
        self.main_window.show()
コード例 #2
0
ファイル: app.py プロジェクト: CJRobey/dominion-app
    def startup(self):
        self.main_window = toga.MainWindow(title=self.name)  #, ))
        self.outer_box = toga.Box(style=Pack(flex=1))
        self.outer_box.style.update(direction=COLUMN, alignment=RIGHT)

        self.choose_button = toga.Button('Random Game',
                                         on_press=self.decide_game,
                                         style=Pack(alignment=CENTER,
                                                    flex=1,
                                                    padding=10))
        self.attack_button = toga.Button('Attack Game',
                                         on_press=self.decide_attack_game,
                                         style=Pack(alignment=CENTER,
                                                    flex=1,
                                                    padding=10))
        self.balanced_button = toga.Button('Balanced Game',
                                           on_press=self.decide_balanced_game,
                                           style=Pack(alignment=CENTER,
                                                      flex=1,
                                                      padding=10))
        self.outer_box.add(self.choose_button)
        self.outer_box.add(self.attack_button)
        self.outer_box.add(self.balanced_button)
        # initializing the space
        self.scroller = toga.ScrollContainer(content=self.outer_box)
        self.init_games()
        self.split = toga.SplitContainer()
        self.split.content = [self.scroller, self.game_dashboard]

        # image from local path
        # We set the style width/height parameters for this one
        self.main_window.content = self.split
        self.main_window.show()
コード例 #3
0
 def setUp(self):
     self.content = [
         toga.Box(style=TestStyle(), factory=toga_dummy.factory),
         toga.Box(style=TestStyle(), factory=toga_dummy.factory)
     ]
     self.split = toga.SplitContainer(style=TestStyle(),
                                      factory=toga_dummy.factory)
コード例 #4
0
    def __init__(self, data, app=None, font_size=FontSize.DEFAULT):
        """Initialize window."""
        super().__init__(size=EXPLORE_WINDOW_SIZE)
        self.app = app
        self.data = data
        self.font_size = font_size
        window_width = self.size[0]
        self.parameters_options_boxes = EddingtonBox(
            children=[self.build_parameters_options_box()],
            style=Pack(direction=COLUMN))
        self.plot_configuration_box = PlotConfigurationBox(plot_method=None,
                                                           suffix="Explore")
        self.controls_box = EddingtonBox(
            children=[
                self.parameters_options_boxes,
                toga.Box(style=Pack(flex=1)),
                self.plot_configuration_box,
                EddingtonBox(children=[
                    toga.Button("Refresh",
                                on_press=lambda widget: self.draw()),
                    SaveFigureButton("Save", plot_method=self.plot),
                ]),
            ],
            style=Pack(direction=COLUMN),
        )
        self.figure_box = FigureBox(self.plot, width=int(window_width * 0.5))
        self.content = toga.SplitContainer(
            content=[self.controls_box, self.figure_box])

        self.update_font_size()

        self.draw()
コード例 #5
0
ファイル: app.py プロジェクト: yuntiaoOS/toga
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
コード例 #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.
        """
        self.license_data = SelectedLicense()

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

        self.top_container = toga.SplitContainer(
            direction=toga.SplitContainer.VERTICAL,
            style=Pack(height=320)
            )


        self.outer_container = toga.Box(
            children=[self.top_container, self.attribution_pane()],
            style=Pack(direction=COLUMN, padding=20)
            )

        self.top_container.content = [self.details_form(), self.results_pane()]

        self.main_window.content = self.outer_container
        self.main_window.show()
コード例 #7
0
    def _setup_main_content(self):
        '''
        Sets up the main content area. It is a persistent GUI component
        '''

        # Create the output/viewer area on the right frame
        # Need to create this before the option container in the left
        # frame is created.
        self._setup_right_frame()

        # Create the tree/control area on the left frame
        self._setup_left_frame()

        # Weight the split container so 66% of the screen
        # is the details panel.
        self.split_main_container = toga.SplitContainer(
            content=[
                (self.tree_notebook, 33),
                (self.right_box, 66),
            ],
            style=Pack(flex=1)
        )
        # Main content area
        self.outer_box = toga.Box(
            children=[
                self.split_main_container,
                self.statusbar
            ],
            style=Pack(direction=COLUMN)
        )
        self.content = self.outer_box
コード例 #8
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()
コード例 #9
0
def build(app):
    content_left = toga.Box(style=CSS(padding=20))
    content_right = toga.Box(style=CSS(padding=20))
    for _ in range(10):
        content_left.add(toga.Button('Button {}'.format(_)))
        content_right.add(toga.Button('Button {}'.format(_)))
    split_container = toga.SplitContainer(
        content=[content_left, content_right])
    return split_container
コード例 #10
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
コード例 #11
0
ファイル: main.py プロジェクト: pablolupo84/PokeDex-Toga
	def startup(self):
		self.main_window = toga.MainWindow('main',title=self.title,size=self.size)
	
		box=toga.Box()
		
		split=toga.SplitContainer()
		split.content=[self.table,box]

		self.main_window.content = split
		self.main_window.show()
		pass
コード例 #12
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()
コード例 #13
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()
コード例 #14
0
    def startup(self):
        self.icon_init()
        self.main_window = toga.MainWindow(title=self.name, size=(1800, 1000))

        self.tree = self.build_schedule()
        # self.tree.refresh()
        right_container = toga.ScrollContainer()

        # right_container.content = right_content
        right_container.content = self.build_settings()

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

        self.main_window.content = split
        self.main_window.show()
コード例 #15
0
    def make_maincontent():
        split = toga.SplitContainer(style=CSS(flex=1))
        left_container = toga.Box()

        tree = toga.Tree(['Fake File Navigator'])
        root1 = tree.insert(None, None, 'root1')
        tree.insert(root1, None, 'root1.1')
        root1_2 = tree.insert(root1, None, 'root1.2')
        tree.insert(root1_2, None, 'root1.2.1')
        tree.insert(root1_2, None, 'root1.2.2')
        tree.insert(root1_2, None, 'root1.2.3')

        codebox = MyApp.make_codebox()
        split.content = [tree, codebox]

        return split
コード例 #16
0
ファイル: main.py プロジェクト: natayafs/Pokedex
    def startup(self):
        self.main_window = toga.MainWindow("main",
                                           title=self.title,
                                           size=(400, 500))
        information_area = toga.Box(children=[
            self.image_view, self.pokemon_name, self.pokemon_description
        ],
                                    style=Pack(direction=COLUMN,
                                               alignment=CENTER))

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

        self.main_window.content = split
        self.main_window.toolbar.add(self.previous_command, self.next_command)
        self.main_window.show()
コード例 #17
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()
コード例 #18
0
ファイル: tutorial2.py プロジェクト: leewonmoh/macrepo1
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
コード例 #19
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()
コード例 #20
0
def build(app):
    box = toga.Box()

#make children boxes for different sections of layout
    box_a = toga.Box('box_a')
    box_b = toga.Box('box_b')

    #box = toga.Box('box', children=[box_a, box_b])

#Scrollbar stuff
    #content = toga.WebView()

    #container = toga.ScrollContainer(content=content, horizontal=True)

    #container.vertical = True

    locationBut = toga.Button('Location', on_press=locationbutton_handler)
    refreshBut = toga.Button('Refresh Crime List', on_press=refreshbutton_handler)
    locationInput = toga.TextInput()

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

    locationBut.style.padding = (0, 0, 50, 50)
    locationBut.style.flex = 0
    refreshBut.style.padding = (0, 0, 100, 100)
    refreshBut.style.flex = 0

    locationInput.style.update(flex=1, padding_bottom=0)

    box_b.add(locationBut)
    box_b.add(refreshBut)
    box_b.add(locationInput)

    split = toga.SplitContainer()

    split.content = [box_a, box_b]

    return split
コード例 #21
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.
        """

        left_content = toga.Box(
            style=Pack(direction=COLUMN, width=150) # , padding_top=50)
        )
        left_content.add(toga.Label('Left Column'))
        left_container = toga.ScrollContainer(horizontal=False)
        left_container.content = left_content

        center_content = toga.Box(
            style=Pack(direction=COLUMN) # , padding_top=50)
        )
        center_content.add(toga.Label('Center Column'))
        center_container = toga.ScrollContainer(horizontal=False)
        center_container.content = center_content

        right_content = toga.Box(
            style=Pack(direction=COLUMN, width=150) # , padding_top=50)
        )
        right_content.add(toga.Label('Right Column'))
        right_container = toga.ScrollContainer(horizontal=False)
        right_container.content = right_content

        split = toga.SplitContainer()

        split.content = [left_container, center_container, right_container]

        main_box = toga.Box(children=[split], style=Pack(direction=COLUMN))

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()
コード例 #22
0
ファイル: interface.py プロジェクト: JasonRabinowitz/rewrite
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
コード例 #23
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
コード例 #24
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()
コード例 #25
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()
コード例 #26
0
ファイル: app.py プロジェクト: fjgauthier/toga
def build(app):
    left_container = toga.Table(['Hello', 'World'], on_select=tableSelected)

    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]

    things = toga.Group('Things')

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

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

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

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

    return split
コード例 #27
0
    def startup(self):
        # choose a default publisher
        self.publisher = 'TOI'

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.main_window.content = box
        self.main_window.show()
コード例 #28
0
ファイル: app.py プロジェクト: hnguyen1605/Hoa-Nguyen
def build(app):
    level1_icon = "icons/chicken-level1.png"
    level2_icon = "icons/cat-level2.png"
    level3_icon = "icons/fox-level3.png"
    level4_icon = "icons/lion-level4.png"
    level5_icon = "icons/tiger-level5.png"

    data = [(
        'Question1', 'Points Receive: 3 ',
        'Which 100-mile long waterway links the Mediterranean and the Red Sea?'
    ), ('Question2', 'Points Receive: 5', 'What is the capital of Kenya?'),
            ('Question3', 'Points Receive: 7',
             'The average of first 50 natural numbers is?'),
            ('Question4', 'Points Receive: 9',
             'The number of 3-digit numbers divisible by 6?'),
            ('Question5', 'Points Receive: 11',
             'Which is the second longest river in Africa?')]

    left_container = toga.Table(
        headings=['Questions', 'Points Per Question', 'Contents'], data=data)

    right_content = toga.Box(style=Pack(direction=COLUMN, padding_top=50))
    for b in range(1, 6):
        right_content.add(
            toga.Button('Answer %s' % b,
                        on_press=button_handler,
                        style=Pack(width=200, padding=20)))
        print("Answer number", b, "is :")
    right_container = toga.ScrollContainer(horizontal=False)

    right_container.content = right_content

    split = toga.SplitContainer()

    split.content = [left_container, right_container]

    levels = toga.Group('Levels')

    cmd0 = toga.Command(level1,
                        label='Level 1',
                        tooltip='Perform level 0',
                        icon=level1_icon,
                        group=levels)
    cmd1 = toga.Command(level2,
                        label='Level 2',
                        tooltip='Perform level 1',
                        icon=level2_icon,
                        group=levels)
    cmd2 = toga.Command(level3,
                        label='Level 3',
                        tooltip='Perform level 2',
                        icon=level3_icon,
                        group=levels)
    cmd3 = toga.Command(level4,
                        label='Level 4',
                        tooltip='Perform level 3',
                        shortcut=toga.Key.MOD_1 + 'k',
                        icon=level4_icon)

    cmd4 = toga.Command(level5,
                        label='Level 5',
                        tooltip='Perform level 4',
                        icon=level5_icon)

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

    return split
コード例 #29
0
ファイル: app.py プロジェクト: xmonader/toga
    def startup(self):

        # ==== Set up main window ======================================================

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

        # Label for user instructions
        label = toga.Label(
            "Please select an example to run",
            style=Pack(padding_bottom=10),
        )

        # ==== Table with examples =====================================================

        self.examples = []

        # search for all folders that contain modules
        for root, dirs, files in os.walk(examples_dir):
            # skip hidden folders
            dirs[:] = [d for d in dirs if not d.startswith(".")]
            if any(name == "__main__.py" for name in files):
                path = Path(root)
                self.examples.append(dict(name=path.name, path=path.parent))

        self.examples.sort(key=lambda e: e["path"])

        self.table = toga.Table(
            headings=["Name", "Path"],
            data=self.examples,
            on_double_click=self.run,
            on_select=self.on_example_selected,
            style=Pack(padding_bottom=10, flex=1),
        )

        # Buttons
        self.btn_run = toga.Button(
            "Run Example", on_press=self.run, style=Pack(flex=1, padding_right=5)
        )
        self.btn_open = toga.Button(
            "Open folder", on_press=self.open, style=Pack(flex=1, padding_left=5)
        )

        button_box = toga.Box(children=[self.btn_run, self.btn_open])

        # ==== View of example README ==================================================

        self.info_view = toga.MultilineTextInput(
            placeholder="Please select example", readonly=True, style=Pack(padding=1)
        )

        # ==== Assemble layout =========================================================

        left_box = toga.Box(
            children=[self.table, button_box],
            style=Pack(
                direction=COLUMN,
                padding=1,
                flex=1,
            ),
        )

        split_container = toga.SplitContainer(content=[left_box, self.info_view])

        outer_box = toga.Box(
            children=[label, split_container],
            style=Pack(padding=10, direction=COLUMN),
        )

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

        # Show the main window
        self.main_window.show()
コード例 #30
0
 def setUp(self):
     self.content = [
         toga.Box(factory=toga_dummy.factory),
         toga.Box(factory=toga_dummy.factory)
     ]
     self.split = toga.SplitContainer(factory=toga_dummy.factory)