def startup(self): self.word_input = toga.PasswordInput(style=Pack(flex=1, padding=5)) self.new_game = toga.Button('New Game', on_press=self.new_game_handler, style=Pack(width=100, padding=5)) self.give_up = toga.Button('Give Up', on_press=self.give_up_handler, style=Pack(width=100, padding=5)) self.start = toga.Button('Start', on_press=self.start_game_handler, style=Pack(width=50, padding=5)) self.buttons_box = toga.Box(children=[ self.new_game, self.give_up, self.word_input, self.start ]) self.buttons_box.remove(self.word_input) print(self.buttons_box.children) self.tree_image = toga.ImageView(toga.Image(IMAGES[0])) self.tree_image.style.update(height=400) self.tree_image.style.update(width=400) start_box = toga.Box(children=[self.tree_image, self.buttons_box]) # start_box.add(tree_image) # start_box.add(buttons_box) start_box.style.update(direction=COLUMN) start_box.style.update(alignment=CENTER) self.main_window = toga.MainWindow(title=self.name) self.main_window.content = start_box self.main_window.show()
def setUp(self): super().setUp() self.value = 'Password' self.placeholder = 'Placeholder' self.readonly = False self.password_input = toga.PasswordInput(factory=toga_dummy.factory)
def startup(self): main_box = toga.Box() w_box = toga.Box() m_box = toga.Box() f_box = toga.Box() w_input = toga.TextInput() m_input = toga.PasswordInput() f_input = toga.TextInput(readonly=True) w_label = toga.Label('Website:', style=Pack(text_align=CENTER)) m_label = toga.Label('Master Password:'******'Your Password:'******'Generate Password', on_press=genPasswd) w_box.add(w_label) w_box.add(w_input) m_box.add(m_label) m_box.add(m_input) f_box.add(f_label) f_box.add(f_input) main_box.add(w_box) main_box.add(m_box) main_box.add(f_box) main_box.add(button) main_box.style.update(direction=COLUMN, padding_top=10) w_box.style.update(direction=ROW, padding=5, padding_bottom=50) m_box.style.update(direction=ROW, padding=5, padding_bottom=50) f_box.style.update(direction=ROW, padding=5) w_input.style.update(flex=1, padding_right=10) m_input.style.update(flex=1, padding_right=10) f_input.style.update(flex=1, padding_right=10) w_label.style.update(flex=1) m_label.style.update(flex=1) f_label.style.update(flex=1) button.style.update(padding=15, flex=1) self.main_window = toga.MainWindow(title=self.formal_name, size=(446, 308)) self.main_window.content = main_box self.main_window.show()
def setUp(self): self.factory = MagicMock() self.factory.PasswordInput = MagicMock(return_value=MagicMock()) self.value = 'Password' self.placeholder = 'Placeholder' self.readonly = False self.password_input = toga.PasswordInput(factory=self.factory)
def startup(self): # Set up main window self.main_window = toga.MainWindow(title=self.name) # Labels to show responses. self.label = toga.Label( 'Enter some values and press extract.', style=Pack(padding=10) ) self.text_label = toga.Label('Ready.', style=Pack(padding=10)) self.password_label = toga.Label('Ready.', style=Pack(padding=10)) self.password_content_label = toga.Label( EMPTY_PASSWORD, style=Pack(padding_bottom=10, font_size=9) ) self.number_label = toga.Label('Ready.', style=Pack(padding=10)) # Text inputs and a button self.text_input = toga.TextInput( placeholder='Type something...', style=Pack(padding=10) ) self.password_input = toga.PasswordInput( placeholder='Password...', style=Pack(padding=10), on_change=self.on_password_change ) self.number_input = toga.NumberInput(style=Pack(padding=10)) btn_extract = toga.Button( 'Extract values', on_press=self.do_extract_values, style=Pack(flex=1) ) # Outermost box box = toga.Box( children=[ self.label, self.text_input, self.password_input, self.password_content_label, self.number_input, self.text_label, self.password_label, self.number_label, btn_extract, ], style=Pack( flex=1, direction=COLUMN, padding=10, ) ) # Add the content on the main window self.main_window.content = box # Show the main window self.main_window.show()
def build(app): password_input = toga.PasswordInput() def callback(widget): print(password_input.value) password_input.clear() btn = toga.Button('Print Password & Clear', on_press=callback) return toga.Box(style=CSS(flex=1, padding=20), children=[password_input, btn])
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(style=Pack(direction=COLUMN)) top_box = toga.Box( style=Pack(direction=ROW, padding=5, alignment='top')) middle_box = toga.Box( style=Pack(direction=ROW, padding=5, alignment='center', flex=1)) button_box = toga.Box(style=Pack(padding=5, alignment='right')) bottom_box = toga.Box(style=Pack( direction=ROW, padding=(5, 5, 20, 5), alignment='bottom')) # Padding - Top, Right, Botom, Left select_label = toga.Label('Search By', style=Pack(padding=5, alignment='center')) self.select = toga.Selection(items=['UserID', 'GistID']) self.select_input = toga.TextInput(style=Pack(padding=5, flex=1), placeholder='User or Gist ID') # Line preserved for prostarity will be using helper functions to do search with externale functions # select_button = toga.Button('Search',style=Pack(padding=5),on_press=partial(search,string = 'x')) select_button = toga.Button('Search', style=Pack(padding=5), on_press=self.search_by) self.results = toga.MultilineTextInput(style=Pack(padding=(0, 5), flex=1), readonly=True) copy_button = toga.Button('Copy to Clipboard', style=Pack(padding=5), on_press=self.copy_to_clipboard) button_box.add(copy_button) middle_box.add(self.results) middle_box.add(button_box) top_box.add(select_label) top_box.add(self.select) top_box.add(self.select_input) top_box.add(select_button) login_label = toga.Label('Username', style=Pack(padding=5, alignment='left')) self.login_input = toga.TextInput( style=Pack(padding=5, alignment='left', flex=1)) pw_label = toga.Label('Password', style=Pack(padding=5, alignment='right')) self.pw_input = toga.PasswordInput( style=Pack(padding=4, alignment='right', flex=1)) bottom_box.add(login_label) bottom_box.add(self.login_input) bottom_box.add(pw_label) bottom_box.add(self.pw_input) main_box.add(top_box) main_box.add(middle_box) main_box.add(bottom_box) self.main_window = toga.MainWindow(title=self.formal_name, size=(640, 480)) self.main_window.content = main_box self.main_window.show()
def startup(self): # agu logo image = toga.Image('resources/agu.png') self.agu_image_view = toga.ImageView(image, style=Pack(padding=10, width=300, height=300)) # username username_label = toga.Label('Username: '******'Password: '******'Login', on_press=self.home, style=Pack(padding_top=25, width=100)) login_box.add(button) self.login_main_box = toga.Box(children=[login_box], style=Pack(direction=COLUMN, padding=250, padding_top=100, alignment=CENTER, flex=1)) image1 = toga.Image('resources/RDDR.png') self.logo_image_view = toga.ImageView(image1, style=Pack(padding=10, width=300, height=300)) company_logo_box = toga.Box(style=Pack(direction=COLUMN, padding=250, padding_top=100, alignment=CENTER, flex=1)) company_logo_box.add(self.logo_image_view) self.main_window = toga.MainWindow(title="AGU") self.main_window.content = company_logo_box self.main_window.show() self.add_background_task(self.do_background_task)
def startup(self): """ Construct and show the Toga application. """ self.daw_project_name_title = toga.Label(text="Project name:", style=Pack(color="#808080")) self.daw_project_name = toga.Label('Waiting for data...') self.daw_project_name_container = toga.Box( children=[self.daw_project_name_title, self.daw_project_name], style=Pack(direction=ROW, padding=10)) hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname) self.hostname_title = toga.Label(text="Listening on:", style=Pack(color="#808080")) self.hostname = toga.Label(local_ip + ":9000") self.hostname_container = toga.Box( children=[self.hostname_title, self.hostname], style=Pack(direction=ROW, padding=10)) self.twitch_input_label = toga.Label(text="Twitch settings") # Sets initial values from environment variables TWITCH_USER TWITCH_CHAN TWITCH_OAUTH # TODO Store from user input for next launch # BUG on Mac 11.1: the input values get erased if input focus changes to another input field # WORKAROUND: focus other application window after input self.twitch_user_input = toga.TextInput(initial=environ.get( 'TWITCH_USER', None), placeholder='username') self.twitch_channel_input = toga.TextInput(initial=environ.get( 'TWITCH_CHAN', None), placeholder='channel') self.twitch_key_input = toga.PasswordInput(initial=environ.get( 'TWITCH_OAUTH', None), placeholder="auth token") self.twitch_settings_container = toga.Box( style=Pack(direction=COLUMN, padding=10), children=[ self.twitch_input_label, self.twitch_user_input, self.twitch_channel_input, self.twitch_key_input ]) self.twitch_connect_button = toga.Button('Connect', on_press=self.twitch_connect, style=Pack(flex=0.5, padding_right=5)) self.send_button = toga.Button('Send current project name', on_press=self.send_button_fuction, style=Pack(flex=1)) self.on_switch = toga.Switch('Enable automatic sending', on_toggle=self.on_switch_handler, style=Pack(flex=1, padding_left=10, padding_top=3)) self.twitch_controls_container = toga.Box( style=Pack(direction=ROW, padding=10), children=[ self.twitch_connect_button, self.send_button, self.on_switch ]) main_box = toga.Box(style=Pack(direction=COLUMN, padding=10, flex=1), children=[ self.hostname_container, self.daw_project_name_container, self.twitch_settings_container, self.twitch_controls_container ]) self.main_window = toga.MainWindow(title=self.formal_name) self.main_window.content = main_box ### HACK Running background tasks # aiosc is uses lover level functions for running the example code # self.add_background_task( Coroutine ) -> equals under the hood: # self.loop.call_soon(wrapped_handler(self, handler), self) loop = self._impl.loop # equals asyncio.get_event_loop() osc_coro = loop.create_datagram_endpoint(OscServer, local_addr=('0.0.0.0', 9000)) osc_task = loop.create_task(osc_coro, name="osc_coro") # Connect Twitch automatically if credentials are set if environ.get('TWITCH_USER', None) and environ.get( 'TWITCH_CHAN', None) and environ.get('TWITCH_OAUTH', None): self.twitch_connect(self.twitch_connect_button) ### Startup GUI self.main_window.show()