def _setup_left_frame(self): ''' The left frame mostly consists of the tree widget ''' self.all_tests_tree = toga.Tree( ['Test'], accessors=['label'], data=self.test_suite, multiple_select=True ) self.all_tests_tree.on_select = self.on_test_selected self.problem_tests_tree = toga.Tree( ['Test'], accessors=['label'], data=TestSuiteProblems(self.test_suite), multiple_select=True ) self.problem_tests_tree.on_select = self.on_test_selected self.tree_notebook = toga.OptionContainer( content=[ ('All tests', self.all_tests_tree), ('Problems', self.problem_tests_tree) ], on_select=self.on_tab_selected )
def __init__(self, **kwargs) -> None: super().__init__(title="Folder Selection", **kwargs) self.tree = toga.Tree( headings=["Name", "Included"], accessors=["name", "included"], style=Pack(flex=1), multiple_select=True, ) self.dialog_buttons = DialogButtons( labels=["Update", "Cancel"], style=Pack(padding=(0, 20, 20, 20)), ) self.dialog_buttons["Update"].enabled = False # Outermost box self.outer_box = toga.Box( children=[ toga.Label( "Please select which files and folders to sync.", style=Pack(padding=20), ), self.tree, self.dialog_buttons, ], style=Pack(direction=COLUMN, flex=1, alignment=RIGHT), ) # Add the content on the main window self.content = self.outer_box
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name) self.fs_source = FileSystemSource(Path.cwd()) self.tree = toga.Tree(headings=['Name', 'Date Modified'], data=self.fs_source, style=Pack(flex=1), multiple_select=True, on_select=self.selection_handler, on_double_click=self.double_click_handler) self.label = toga.Label('A view of the current directory!', style=Pack(padding=10)) # Outermost box outer_box = toga.Box(children=[ self.label, self.tree, ], style=Pack(flex=1, direction=COLUMN)) # Add the content on the main window self.main_window.content = outer_box # Show the main window self.main_window.show()
def setUp(self): self.factory = MagicMock() self.factory.Tree = MagicMock(return_value=MagicMock( spec=toga_dummy.widgets.tree.Tree)) self.heading = ['Heading {}'.format(x) for x in range(3)] self.tree = toga.Tree(headings=self.heading, factory=self.factory)
def build_schedule(self): self.tree = toga.Tree([ 'Время (День/Часы)', 'Номер события', 'Название события', 'Помещение', 'Периодичность', 'Участники' ], style=schedule_style) return self.tree
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name) # Label to show responses. self.label = toga.Label('Ready.') self.tree = toga.Tree(headings=['Year', 'Title', 'Rating', 'Genre'], data=DecadeSource(), on_select=self.on_select_handler, style=Pack(flex=1)) # Buttons btn_style = Pack(flex=1) btn_insert = toga.Button('Insert Row', on_press=self.insert_handler, style=btn_style) btn_box = toga.Box(children=[btn_insert], style=Pack(direction=ROW)) # Outermost box outer_box = toga.Box(children=[btn_box, self.tree, self.label], style=Pack( flex=1, direction=COLUMN, padding=10, )) # Add the content on the main window self.main_window.content = outer_box # Show the main window self.main_window.show()
def setUp(self): self.tree = toga.Tree(headings=("one", "two")) # make a shortcut for easy use self.gtk_tree = self.tree._impl self.window = Gtk.Window() self.window.add(self.tree._impl.native)
def test_multiselect_getter(self): super().setUp() self.headings = ['Heading {}'.format(x) for x in range(3)] self.data = None self.tree = toga.Tree(headings=self.headings, data=self.data, multiple_select=True, factory=toga_dummy.factory) self.assertEqual(self.tree.multiple_select, True) self.tree = toga.Tree(headings=self.headings, data=self.data, multiple_select=False, factory=toga_dummy.factory) self.assertEqual(self.tree.multiple_select, False)
def setUp(self): super().setUp() self.headings = ['Heading {}'.format(x) for x in range(3)] self.data = None self.tree = toga.Tree(headings=self.headings, data=self.data, factory=toga_dummy.factory)
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
def startup(self): self.main_window = toga.MainWindow(self.name) self.main_window.app = self tree = toga.Tree(['Navigate']) tree.insert(None, None, 'root1') root2 = tree.insert(None, None, 'root2') tree.insert(root2, None, 'root2.1') root2_2 = tree.insert(root2, None, 'root2.2') tree.insert(root2_2, None, 'root2.2.1') tree.insert(root2_2, None, 'root2.2.2') tree.insert(root2_2, None, 'root2.2.3') self.main_window.content = tree self.main_window.show()
def startup(self): # Set up main window self.main_window = toga.MainWindow(self.name) # Label to show responses. self.label = toga.Label('Ready.') self.tree = toga.Tree( headings=['Year', 'Title', 'Rating', 'Genre'], on_select=self.on_select_handler, style=Pack(flex=1) ) self.decade_1940s = self.tree.data.append(None, year='1940s', title='', rating='', genre='') self.decade_1950s = self.tree.data.append(None, year='1950s', title='', rating='', genre='') self.decade_1960s = self.tree.data.append(None, year='1960s', title='', rating='', genre='') self.decade_1970s = self.tree.data.append(None, year='1970s', title='', rating='', genre='') self.decade_1980s = self.tree.data.append(None, year='1980s', title='', rating='', genre='') self.decade_1990s = self.tree.data.append(None, year='1990s', title='', rating='', genre='') self.decade_2000s = self.tree.data.append(None, year='2000s', title='', rating='', genre='') # Buttons btn_style = Pack(flex=1) btn_insert = toga.Button('Insert Row', on_press=self.insert_handler, style=btn_style) btn_box = toga.Box(children=[btn_insert], style=Pack(direction=ROW)) # Outermost box outer_box = toga.Box( children=[btn_box, self.tree, self.label], style=Pack( flex=1, direction=COLUMN, padding=10, ) ) # Add the content on the main window self.main_window.content = outer_box # Show the main window self.main_window.show()
def startup(self): # Set up main window self.main_window = toga.MainWindow(self.name) self.main_window.app = self # Label to show responses. self.label = toga.Label('Ready.') self.tree = toga.Tree( headings=['Year', 'Title', 'Rating', 'Genre'], data=DecadeSource(), on_select=self.on_select_handler, style=CSS(flex=1) ) # Buttons btn_style = CSS(flex=1) btn_insert = toga.Button('Insert Row', on_press=self.insert_handler, style=btn_style) btn_box = toga.Box(children=[btn_insert], style=CSS(flex_direction='row')) # Outermost box outer_box = toga.Box( children=[btn_box, self.tree, 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()
def build(app): box = toga.Box(style=CSS(flex=1, padding=0)) root = {'root': []} data_source = toga.DictionaryDataSource(dict({'root': []})) # for _ in range(10): # data_source.insert(root, None, 'text {}'.format(_)) tree = toga.Tree(['Name'], data=data_source, style=CSS(flex=1)) root_node = data_source.root(0) root_node.icon = 'icons/cricket-72.png' for _ in reversed(range(100)): node = data_source.insert(parent=data_source.root(0), index=0, data=['Job_{}'.format(_)], icon='icons/cricket-72.png') if _ % 2 == 0: data_source.insert(parent=node, index=0, data='data', icon='icons/cricket-72.png') else: for _ in range(3): node2 = data_source.insert(parent=node, index=0, data='child', icon='icons/cricket-72.png') for x in range(3): node3 = data_source.insert(parent=node2, index=0, data='child', icon='icons/cricket-72.png') root_node.expanded = True box.add(tree) # box.add(toga.Button('Button')) return box
def startup(self): # Create main window self.main_window = toga.MainWindow(self.name) icons = os.path.join(os.path.dirname(__file__), 'icons') # dice number window self.roll_dice = '' self.die_window = toga.Window('die_num', title='How many dice to roll', closeable=False, minimizable=False) self.dice_number = toga.Slider(range=(1,10), window=self.die_window) # Character Attributes on the left self.left_content = toga.Slider() self.left_container = toga.ScrollContainer(content=self.left_content, horizontal=False) # Other attributes on the right self.right_container = toga.OptionContainer() self.right_table = toga.Table(headings=['Throws', 'Values']) self.right_tree = toga.Tree(headings=['Spells', 'Equipment']) self.right_container.add('Table', self.right_table) self.right_container.add('Tree', self.right_tree) # Split left and right boxes formed above self.split = toga.SplitContainer() self.split.content = [self.left_container, self.right_container] # Make dice toolbar cmd4 = toga.Command(self.dice4, 'Roll D4', tooltip='Roll a four sided die', icon=os.path.join(icons, 'd4.png'), order=1) cmd6 = toga.Command(self.dice6, 'Roll D6', tooltip='Roll a six sided die', icon=os.path.join(icons, 'd6.png'), order=2) cmd8 = toga.Command(self.dice8, 'Roll D8', tooltip='Roll a eight sided die', icon=os.path.join(icons, 'd8.png'), order=3) cmd10 = toga.Command(self.dice10, 'Roll D10', tooltip='Roll a 10 sided die', icon=os.path.join(icons, 'd10.png'), order=4) cmd12 = toga.Command(self.dice12, 'Roll D12', tooltip='Roll a twelve sided die', icon=os.path.join(icons, 'd12.png'), order=5) cmd20 = toga.Command(self.dice20, 'Roll D20', tooltip='Roll a twenty sided die', icon=os.path.join(icons, 'd20.png'), order=6) # Show main window self.main_window.toolbar.add(cmd4, cmd6, cmd8, cmd10, cmd12, cmd20) self.main_window.toolbar.add(die_slider) self.main_window.content = self.split self.main_window.show()
def build(app): tree = toga.Tree(headings=['First Heading', 'Second Heading']) tree._impl.insert(None, 10, 'first', 'second') return tree
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()
def startup(self): self.main_window = toga.MainWindow(self.name, size=(800, 800)) l1 = toga.Label('Эксперимент Автосервис', style=Pack(text_align=CENTER, width=800, height=25)) lelf_label1 = toga.Label('Число рабочих К', style=Pack(text_align=LEFT, width=300, height=25)) self.left_input1 = toga.TextInput(style=Pack(text_align=LEFT, width=250, height=25), placeholder='3') lelf_label2 = toga.Label('Шаг времени М (в часах)', style=Pack(text_align=LEFT, width=300, height=25)) self.left_input2 = toga.TextInput(style=Pack(text_align=LEFT, width=250, height=25), placeholder='1') lelf_label3 = toga.Label('Вероятность появления авто (от 0 до 1)', style=Pack(text_align=LEFT, width=300, height=25)) self.left_input3 = toga.TextInput(style=Pack(text_align=LEFT, width=250, height=25), placeholder='0.5') self.left_button1 = toga.Button('Шаг', style=Pack(text_align=CENTER, width=83, height=25), on_press=self.make_step) self.left_button2 = toga.Button('До конца', style=Pack(text_align=CENTER, width=83, height=25), on_press=self.to_end) self.left_button3 = toga.Button('Сначала', style=Pack(text_align=CENTER, width=83, height=25), on_press=self.restart) button_box = toga.Box(style=Pack(direction=ROW, width=250, height=25), children=[ self.left_button1, self.left_button2, self.left_button3, ]) left1 = toga.Box(style=Pack(direction=COLUMN, width=300, height=200), children=[ lelf_label1, self.left_input1, lelf_label2, self.left_input2, lelf_label3, self.left_input3, button_box, ]) self.right_label1 = toga.Label('Общая прибыль на текущий момент 0', style=Pack(text_align=LEFT, width=500, height=40)) self.right_label2 = toga.Label('День Понедельник', style=Pack(text_align=LEFT, width=500, height=40)) self.right_label3 = toga.Label('Время 8:00', style=Pack(text_align=LEFT, width=500, height=40)) self.right_label4 = toga.Label('Число свободных рабочих 0', style=Pack(text_align=LEFT, width=500, height=40)) right1 = toga.Box(style=Pack(direction=COLUMN, width=300, height=200), children=[ self.right_label1, self.right_label2, self.right_label3, self.right_label4 ]) inner_box1 = toga.Box(style=Pack(direction=ROW, width=600), children=[ left1, right1, ]) headings = ['id', 'Поломка', 'Осталось', 'Люди'] self.table1 = toga.Table( headings=headings, data=[], style=Pack(width=250, height=150), # on_select=self.on_select_handler ) self.table2 = toga.Table( headings=headings, data=[], style=Pack(padding_left=25, width=250, height=150), # on_select=self.on_select_handler ) self.table3 = toga.Table( headings=headings, data=[], style=Pack(padding_left=25, width=250, height=150), # on_select=self.on_select_handler ) inner_box3 = toga.Box(style=Pack(direction=ROW, width=800), children=[ self.table1, self.table2, self.table3, ]) inner_box2 = toga.Box(style=Pack(direction=ROW, width=800), children=[ toga.Label('Цех 1 (покрасочная)', style=Pack(text_align=CENTER, width=250, height=25)), toga.Label('Цех 2 (ремонт)', style=Pack(padding_left=25, text_align=CENTER, width=250, height=25)), toga.Label('Цех 3 (замена)', style=Pack(padding_left=25, text_align=CENTER, width=250, height=25)) ]) self.workers1 = toga.Label('Число свободных рабочих: ', style=Pack(text_align=LEFT, width=250, height=25)) self.workers2 = toga.Label('Число свободных рабочих: ', style=Pack(padding_left=25, text_align=LEFT, width=250, height=25)) self.workers3 = toga.Label('Число свободных рабочих: ', style=Pack(padding_left=25, text_align=LEFT, width=250, height=25)) inner_box4 = toga.Box(style=Pack(direction=ROW, width=800), children=[ self.workers1, self.workers2, self.workers3, ]) self.profit1 = toga.Label('Прибыль: 0', style=Pack(text_align=LEFT, width=250, height=25)) self.profit2 = toga.Label('Прибыль: 0', style=Pack(padding_left=25, text_align=LEFT, width=250, height=25)) self.profit3 = toga.Label('Прибыль: 0', style=Pack(padding_left=25, text_align=LEFT, width=250, height=25)) inner_box5 = toga.Box(style=Pack(direction=ROW, width=800), children=[ self.profit1, self.profit2, self.profit3, ]) l2 = toga.Label('Очередь заявок', style=Pack(padding_top=25, text_align=CENTER, width=800, height=25)) self.tree = toga.Tree( headings=[ 'id', 'Марка авто', 'Цех', 'Поломка/Работа', 'Стоимость', 'Люди', 'Время работы (в часах)' ], data=[], style=Pack(width=800, height=300), # on_select=self.on_select_handler ) # Create the outer box with 2 rows outer_box = toga.Box(style=Pack(direction=COLUMN, height=10, padding=25), children=[ l1, inner_box1, inner_box2, inner_box3, inner_box4, inner_box5, l2, self.tree ]) self.world = World() self.main_window.content = outer_box self.main_window.show()
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()
def __init__(self, app: toga.App) -> None: # noinspection PyTypeChecker super().__init__( title="Maestral Setup", size=(self.WINDOW_WIDTH, self.WINDOW_HEIGHT), resizeable=False, minimizable=False, app=app, ) # FIXME: remove private API access self._impl.native.titlebarAppearsTransparent = True self._impl.native.titleVisibility = 1 self._impl.native.styleMask |= NSFullSizeContentViewWindowMask self._impl.native.movableByWindowBackground = True self.current_page = 0 # ==== welcome page ============================================================ # noinspection PyTypeChecker self.image0 = toga.ImageView( self.app.icon, style=Pack(width=128, height=128, alignment=CENTER, padding=(40, 0, 40, 0)), ) self.label0 = Label( text="Welcome to Maestral, an open source Dropbox client.", style=Pack(width=self.WINDOW_WIDTH, padding_bottom=40, text_align=CENTER), ) self.btn_start = toga.Button("Link Dropbox Account", style=Pack(width=180)) self.welcome_page = toga.Box( children=[ self.image0, self.label0, self.btn_start, Spacer(COLUMN) ], style=self.page_style, ) # ==== link page =============================================================== # noinspection PyTypeChecker self.image1 = toga.ImageView(self.app.icon, style=Pack(width=64, height=64, padding=(40, 0, 40, 0))) self.label1 = Label( text=( "To link Maestral to your Dropbox account, please retrieve an " "authorization token from Dropbox and enter it below."), linebreak_mode=WORD_WRAP, style=Pack(width=self.CONTENT_WIDTH * 0.9, text_align=CENTER, padding_bottom=10), ) self.btn_auth_token = FollowLinkButton("Retrieve Token", style=Pack(width=125, padding_bottom=35)) self.text_field_auth_token = toga.TextInput( placeholder="Authorization Token", style=Pack( width=self.CONTENT_WIDTH * 0.9, text_align=CENTER, background_color=TRANSPARENT, ), ) self.spinner_link = toga.ActivityIndicator( style=Pack(width=32, height=32)) self.dialog_buttons_link_page = DialogButtons(labels=("Link", "Cancel"), style=self.btn_box_style) self.dialog_buttons_link_page["Link"].enabled = False self.link_page = toga.Box( children=[ self.image1, self.label1, self.btn_auth_token, self.text_field_auth_token, Spacer(COLUMN), self.spinner_link, Spacer(COLUMN), self.dialog_buttons_link_page, ], style=self.page_style, ) # ==== dbx location page ======================================================= # noinspection PyTypeChecker self.image2 = toga.ImageView(self.app.icon, style=Pack(width=64, height=64, padding=(40, 0, 40, 0))) self.dbx_location_label = Label( text= ("Maestral has been successfully linked with your Dropbox account.\n\n" "Please select a local folder for your Dropbox. If the folder is not " "empty, you will be given the option to merge its content with your " "remote Dropbox. Merging will not transfer or duplicate any identical " "files.\n\n" "In the next step, you will be asked to choose which folders to sync." ), linebreak_mode=WORD_WRAP, style=Pack( width=self.CONTENT_WIDTH, height=90, padding_bottom=20, text_align=CENTER, ), ) self.combobox_dbx_location = FileSelectionButton( initial=get_home_dir(), select_files=False, select_folders=True, show_full_path=True, style=Pack(width=self.CONTENT_WIDTH * 0.9, padding_bottom=20), ) self.dialog_buttons_location_page = DialogButtons( labels=("Select", "Cancel & Unlink"), style=self.btn_box_style) self.dbx_location_page = toga.Box( children=[ self.image2, self.dbx_location_label, self.combobox_dbx_location, Spacer(COLUMN), self.dialog_buttons_location_page, ], style=self.page_style, ) # ==== selective sync page ===================================================== self.label3 = Label( text= ("Please select which files and folders to sync below. The initial " "download may take some time, depending on the size of your Dropbox." ), linebreak_mode=WORD_WRAP, style=Pack(width=self.CONTENT_WIDTH, padding=(20, 0, 20, 0)), ) self.dropbox_tree = toga.Tree( headings=["Name", "Included"], accessors=["name", "included"], data=[], style=Pack(width=self.CONTENT_WIDTH, padding_bottom=20, flex=1), multiple_select=True, ) self.dialog_buttons_selective_sync_page = DialogButtons( labels=["Select", "Back"], style=self.btn_box_style, ) self.selective_sync_page = toga.Box( children=[ self.label3, self.dropbox_tree, self.dialog_buttons_selective_sync_page, ], style=self.page_style, ) # ==== done page =============================================================== # noinspection PyTypeChecker self.image4 = toga.ImageView( self.app.icon, style=Pack(width=128, height=128, alignment=CENTER, padding=(40, 0, 40, 0)), ) self.label4 = Label( text= ("You have successfully set up Maestral. Please allow some time for the " "initial indexing and download of your Dropbox before Maestral will " "commence syncing."), linebreak_mode=WORD_WRAP, style=Pack(width=self.CONTENT_WIDTH, text_align=CENTER, padding_bottom=50), ) self.close_button = toga.Button("Close", style=Pack(width=100), on_press=lambda s: self.close()) self.done_page = toga.Box( children=[ self.image4, self.label4, self.close_button, Spacer(COLUMN) ], style=self.page_style, ) self.pages = ( self.welcome_page, self.link_page, self.dbx_location_page, self.selective_sync_page, self.done_page, ) self.content = toga.Box(children=[self.pages[0]])
import toga container = toga.OptionContainer() table = toga.Table(['Hello', 'World']) tree = toga.Tree(['Navigate']) container.add('Table', table) container.add('Tree', tree) def build(app): return container toga.App('First App', 'org.pybee.helloworld', startup=build).main_loop()