def test_already_running(self): # Creating a new progress bar with running=True so it is already running self.activityindicator = toga.ActivityIndicator(factory=toga_dummy.factory, running=True) # Asserting that start() function is invoked on the underlying widget self.assertActionPerformed(self.activityindicator, 'start ActivityIndicator') # Asserting is_running to be True self.assertTrue(self.activityindicator.is_running)
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name) self.spinner = toga.ActivityIndicator(style=Pack(padding_left=10, height=16)) self.button = toga.Button('Start', on_press=self.do_stuff, style=Pack(padding_right=10)) box = toga.Box( children=[ self.button, self.spinner ], style=Pack(direction=ROW, height=20, padding=20, alignment=CENTER, flex=1) ) # Add the content on the main window self.main_window.content = box self.main_window.size = (200, 200) # Show the main window self.main_window.show()
def __init__( self, title: str = "Alert", message: str = "", button_labels: Iterable[str] = ("Ok",), default: str = "Ok", accessory_view: toga.Widget = toga.Box(), icon: toga.Icon | None = None, callback: Callable | None = None, app: toga.App | None = None, ): super().__init__( resizeable=False, closeable=False, minimizable=False, title=" ", is_dialog=True, app=app, ) if not callback: def callback(sender): self.close() self.resizeable = True self.size = (self.WINDOW_WIDTH, self.WINDOW_MIN_HEIGHT) if not icon: if self.app: icon = self.app.icon else: icon = Icon("") self.msg_title = Label( text=title, style=Pack( width=self.CONTENT_WIDTH, padding_bottom=self.TITLE_PADDING_BOTTOM, font_weight=BOLD, font_size=13, background_color=TRANSPARENT, ), ) self.image = toga.ImageView( icon, style=Pack( width=self.ICON_SIZE[0], height=self.ICON_SIZE[1], padding_right=self.ICON_PADDING_RIGHT, background_color=TRANSPARENT, ), ) self.msg_content = Label( text=message, linebreak_mode=WORD_WRAP, style=Pack( width=self.CONTENT_WIDTH, padding_bottom=10, font_size=11, flex=1, background_color=TRANSPARENT, ), ) self.spinner = toga.ActivityIndicator( style=Pack(width=16, height=16, background_color=TRANSPARENT) ) self.dialog_buttons = DialogButtons( labels=button_labels, default=default, on_press=callback, style=Pack( width=self.CONTENT_WIDTH, padding=0, alignment=CENTER, background_color=TRANSPARENT, ), ) self.dialog_buttons.children.insert(0, self.spinner) self.accessory_view = accessory_view self.content_box = toga.Box( children=[ self.msg_title, self.msg_content, self.accessory_view, self.dialog_buttons, ], style=Pack( direction=COLUMN, background_color=TRANSPARENT, ), ) self.outer_box = toga.Box( children=[self.image, self.content_box], style=Pack( direction=ROW, padding=( self.PADDING_TOP, self.PADDING_RIGHT, self.PADDING_BOTTOM, self.PADDING_LEFT, ), background_color=TRANSPARENT, ), ) self.content = self.outer_box self.center()
def setUp(self): super().setUp() self.activityindicator = toga.ActivityIndicator( factory=toga_dummy.factory)
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]])