def get_render_args(self) -> RenderArgs: full_layout, kwargs = super().get_render_args() win_w, win_h = self._window_size file_list_str = '\n'.join( sorted((f.path.as_posix() for f in self.files))) self.file_list = Multiline(file_list_str, key='file_list', size=((win_w - 395) // 7, 5), disabled=True) file_col = Column( [[Text(f'Files ({len(self.files)}):')], [self.file_list]], key='col::file_list') total_steps = len(self.files) * (3 if self.options['bpm'] else 2) bar_w = (win_w - 159) // 11 track_text = Text('', size=(bar_w - 12, 1)) self.prog_tracker = ProgressTracker(total_steps, text=track_text, size=(bar_w, 30), key='progress_bar') self.output = Multiline(size=self._output_size(), key='output', autoscroll=True) layout = [ [self.options.as_frame('run_clean'), file_col], [self.prog_tracker.bar], [Text('Processing:'), track_text], [self.output], ] full_layout.append( [self.as_workflow(layout, back_tooltip='Go back to view album')]) return full_layout, kwargs
def __init__(self, user): self.window = Window('Alterar senha').layout( [[Text(f'Senha atual: '), Input(key='old_password')], [Text('Nova senha: '), Input(key='password')], [Button('Voltar'), Button('Confirmar')]])
def __init__(self, user): self.window = Window('Minha conta').layout( [[Text(f'Usuário: {user.username}')], [Text(f'Senha: {user.password}')], [Text(f'Data inserção: {user.date}')], [Button('Alterar senha')], [Button('Voltar'), Button('Trocar Conta'), Button('Excluir')]])
def __init__(self): layout = [ [Text('O que você quer fazer?')], [Text('Gerenciar funcionários'), Button('0')], [Text('Gerenciar veículos'), Button('1')], [Text('Gerenciar movimentações'), Button('2')], [Button('Sair')] ] self.window = Window('Claviculário Eletrônico').Layout(layout)
def __init__(self, funcs): self.window = Window('Funcionários') layout = [ [Text('Funcionários:')], ] for func in funcs: layout.append([Text(f'{func.matricula} - {func.nome}')]) layout.append([Button('Voltar')]) self.window.layout(layout)
def __init__(self, genres): self.window = Window('Criar meta').layout( [[Text('Prazo: '), Input(key='prazo'), Text(' dias')], [Text('Objetivo: '), Input(key='objetivo'), Text(' obras')], [Text('Genero: '), Combo(genres, key='genre')], [Button('Voltar'), Button('Criar meta')]])
def __init__(self): self.window = Window('Menu movimentações').layout( [ [Text('O que você deseja fazer?')], [Text('Filtrar movimentação'), Button('0')], [Text('Obter relatório por tipo'), Button('1')], [Text('Retirar veículo'), Button('2')], [Text('Devolver veículo'), Button('3')], [Button('Voltar')] ] )
def get_metadata_row(self): info = self.track.info row = [ Text('Bitrate:'), ExtInput(info['bitrate_str'], size=(14, 1), disabled=True), Text('Sample Rate:'), ExtInput(info['sample_rate_str'], size=(10, 1), disabled=True), ] for key in ('encoder', 'codec'): if value := info.get(key): row.append(Text(f'{key.title()}:')) row.append(ExtInput(value, size=(15, 1), disabled=True))
def get_a_to_b(label: str, src_val: Union[str, Path], new_val: Union[str, Path], src: str, tag: str) -> list[Element]: src_val = src_val.as_posix() if isinstance(src_val, Path) else src_val src_kwargs = {'size': (len(src_val), 1)} if len(src_val) > 50 else {} src_ele = ExtInput(src_val, disabled=True, key=f'src::{src}::{tag}', **src_kwargs) new_val = new_val.as_posix() if isinstance(new_val, Path) else new_val new_kwargs = {'size': (len(new_val), 1)} if len(new_val) > 50 else {} new_ele = ExtInput(new_val, disabled=True, key=f'new::{src}::{tag}', **new_kwargs) if len(src_val) + len(new_val) > 200: yield [Text(label), src_ele] yield [Image(size=(len(label) * 7, 1)), Text('\u2794', font=('Helvetica', 15)), new_ele] else: yield [Text(label), src_ele, Text('\u2794', font=('Helvetica', 15)), new_ele]
def _generate_layout( self, disable_all: bool) -> Iterator[tuple[Optional[int], int, Element]]: for name, opt in self.options.items(): opt_type, col_num, row_num = opt['opt_type'], opt['col'], opt[ 'row'] val = opt.get('value', opt['default']) disabled = disable_all or opt['disabled'] common = {'key': f'opt::{name}', 'disabled': disabled} if opt_kwargs := opt.get('kwargs'): common.update(opt_kwargs) for param in COMMON_PARAMS: try: common[param] = opt[param] except KeyError: pass if opt_type == 'checkbox': yield col_num, row_num, Checkbox(opt['label'], default=val, **common) elif opt_type == 'input': yield col_num, row_num, Text(opt['label'], key=f'lbl::{name}') yield col_num, row_num, ExtInput('' if val is _NotSet else val, **common) elif opt_type == 'dropdown': yield col_num, row_num, Text(opt['label'], key=f'lbl::{name}') yield col_num, row_num, Combo(opt['choices'], default_value=val, **common) elif opt_type == 'listbox': choices = opt['choices'] yield col_num, row_num, Text(opt['label'], key=f'lbl::{name}') yield col_num, row_num, Listbox(choices, default_values=val or choices, no_scrollbar=True, select_mode=opt['select_mode'], **common) if opt['extendable']: yield col_num, row_num, Button('Add...', key=f'btn::{name}', disabled=disabled) elif opt_type == 'path': val = val.as_posix() if isinstance( val, Path) else None if val is _NotSet else val yield col_num, row_num, Text(opt['label'], key=f'lbl::{name}') yield col_num, row_num, ExtInput('' if val is None else val, **common) yield col_num, row_num, opt['button_func'](initial_folder=val) else: raise ValueError(f'Unsupported {opt_type=!r}')
def tela_cadastro(): """ Tela para cadastro de novo emprestimo. :return: uma lista contento as informações inputadas. """ layout = [[Text("Cadastrar emprestimo")], [Text("Nome", size=(15, 1)), InputText()], [Text("Telefone Fixo", size=(15, 1)), InputText()], [Text("Celular", size=(15, 1)), InputText()], [Text("E-mail", size=(15, 1)), InputText()], [Text("De onde conhece", size=(15, 1)), InputText()], [ Text("Data", size=(15, 1)), InputText("ex: dia/mês/ano", do_not_clear=False) ], [Text("Item", size=(15, 1)), InputText()], [ Button("Cadastrar", button_color=('white', 'springgreen4')), Cancel(button_text="Cancelar", button_color=('white', 'firebrick3')) ]] janela = Window( "Cadastro", disable_close=True, icon=('C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout) botao, valores = janela.Read() if botao == "Cadastrar": janela.Close() return valores elif botao == 'Cancelar' or botao is None: janela.Close()
def tela_atualizacao(informacao_antiga): """ Tela para atualizar informações de um emprestimo já cadastrado. :param informacao_antiga: um dicionário contento todas as antigas informações do emprestimo. :return: uma lista de valores, contento o conteúdo dos InputText. """ layout = [ [Text("Atualizar emprestimo")], [ Text("Nome", size=(15, 1)), InputText(default_text=informacao_antiga['nome'], do_not_clear=True) ], [ Text("Telefone Fixo", size=(15, 1)), InputText(default_text=informacao_antiga['telefone'], do_not_clear=True) ], [ Text("Celular", size=(15, 1)), InputText(default_text=informacao_antiga['celular'], do_not_clear=True) ], [ Text("E-mail", size=(15, 1)), InputText(default_text=informacao_antiga['email'], do_not_clear=True) ], [ Text("De onde conhece", size=(15, 1)), InputText(default_text=informacao_antiga['vivencia'], do_not_clear=True) ], [ Text("Data", size=(15, 1)), InputText( default_text=informacao_antiga['data'].strftime("%d/%m/%Y"), do_not_clear=True) ], [ Text("Item", size=(15, 1)), InputText(default_text=informacao_antiga['item'], do_not_clear=True) ], [ Button("Atualizar", button_color=('white', 'springgreen4')), Cancel(button_text="Cancelar", button_color=('white', 'firebrick3')) ] ] janela = Window( "Cadastro", icon=('C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout) botao, valores = janela.Read() print(valores) if botao == "Atualizar": janela.Close() return valores elif botao == 'Cancelar': janela.Close()
def get_basic_info_row(self): track = self.track tag_version = f'{track.tag_version} (lossless)' if track.lossless else track.tag_version return [ Text('File:'), ExtInput(track.path.name, size=(50, 1), disabled=True, path=self.path_str), Text('Length:'), ExtInput(track.length_str, size=(6, 1), disabled=True), Text('Type:'), ExtInput(tag_version, size=(20, 1), disabled=True), ]
def get_sync_rows(self): row = [ Text('Num', key=self.key_for('tag', 'num', WRITE_ONLY_KEY)), ExtInput(self.info.num, key=self.key_for('val', 'num'), disabled=True, size=(5, 1)), Text('Title', key=self.key_for('tag', 'title', WRITE_ONLY_KEY)), ExtInput(self.info.title, key=self.key_for('val', 'title'), disabled=True), ] rows = [row, self._rating_row('rating', self.info.rating, False)] return resize_text_column(rows)
def get_render_args(self) -> RenderArgs: full_layout, kwargs = super().get_render_args() search = Button('Search', bind_return_key=True) layout = [ [self.options.as_frame()], [ Text('Section:'), self.section_picker, self.type_picker, Text('Query:'), self.query, search ], # [], # TODO: Page chooser / back/next [self.results], ] full_layout.extend(layout) return full_layout, kwargs
def getLongInput(prompt: str, text: str) -> str: win: Window = Window(alpha_channel=0.8, finalize=True, debugger_enabled=False, resizable=True, text_justification="center", title=prompt.strip(), no_titlebar=True, keep_on_top=True, disable_close=True, disable_minimize=True, grab_anywhere=True, auto_size_text=True, layout=[ [Text(text=prompt.strip(), expand_x=True, expand_y=True, auto_size_text=True)], [Multiline( default_text='', disabled=False, expand_x=True, expand_y=True, autoscroll=True, auto_refresh=True, auto_size_text=True, focus=True, size=(64, 16) )], # Made By: TonicBoomerKewl (AKA DarkOctet) [Button(button_text=text.strip(), expand_x=True, expand_y=True, auto_size_button=True)], [Text(text="Made By: TonicBoomerKewl", expand_x=True, expand_y=True, auto_size_text=True)] ]) focus(win) res = win.read() win.close() return res[1].get(0, '').strip()
def tela_excluir(): """ Tela para confirmação da exclusão de um emprestimo. :return: um valor booleano, para confirmação ou negação da ação. """ layout = [[Text('Tem certeza que deseja excluir?')], [ Button("Sim", size=(8, 1), button_color=('white', 'springgreen4'), pad=(20, 1)), Button("Não", size=(8, 1), button_color=('white', 'firebrick3')) ]] janela = Window( 'Excluir', icon=('C:\\Loans-management\\Icon\\icon-logo.ico')).Layout(layout) botao, evento = janela.Read() if botao == 'Sim': janela.Close() return True else: janela.Close() return False
def setLayout(): layout = [[ sg.Text(' Atividades para a semana', size=(25, 1), justification='center', font=("Verdana", "10", "bold")) ], [ sg.Text('Atividade:', size=(10, 1), justification='right'), sg.I(key='-ATIVIDADE-', do_not_clear=False) ], [ sg.T('Tempo:', size=(10, 1), justification='right'), sg.I(key='-TEMPO-', do_not_clear=False) ], [ sg.T('Prioridade:', size=(10, 1), justification='right'), sg.I(key='-PRIORIDADE-', do_not_clear=False) ], [ sg.T(' ' * 5), sg.Button('Inserir'), sg.Button('Pomodoro'), sg.Button('Agendar') ], [ sg.T(key='-MESSAGE-', size=(30, 1), font=("Verdana", "9", "italic")) ]] layout += [[Text('Progresso', justification='Left', font="Verdana 10")]] # a title line t try: layout += [[Text(f'{i+1}. '), CBox(''), sg.I(data['Task'][i])] for i in range(len(data['Task'])) ] # the checkboxes and descriptions except: layout += [[Text(f'{i}. '), CBox(''), Input()] for i in range(1, 6)] # the checkboxes and descriptions window = sg.Window('Cardeal Assist', layout, font='Calibri 10', default_element_size=(25, 1)) return window
def __init__(self, field, value): self.__validator = validator self.window = Window('Atualiza funcionário') layout = [[ Text(f'Informe o/a {field} do funcionário:'), Input(key=field, default_text=value) ], [Button('Ok!'), Button('Manter')]] self.window.layout(layout)
def __init__(self, field): self.__validator = validator self.window = Window('Adiciona funcionário') layout = [[ Text(f'Informe o/a {field} do funcionário:'), Input(key=field) ], [Button('Ok!')]] self.window.layout(layout)
def showLongInfo(prompt: str, text: str) -> None: win: Window = Window(alpha_channel=0.8, finalize=True, debugger_enabled=False, resizable=True, text_justification="center", title=prompt.strip(), no_titlebar=True, keep_on_top=True, disable_close=True, disable_minimize=True, grab_anywhere=True, auto_size_text=True, layout=[ [Text(text=prompt.strip(), expand_x=True, expand_y=True, auto_size_text=True)], [Multiline( default_text=text, disabled=True, expand_x=True, expand_y=True, autoscroll=True, auto_refresh=True, auto_size_text=True, focus=True, size=(64, 16) )], [Button(button_text="Copy", expand_x=True, expand_y=True, size=(8, 1)), Button(button_text="Close", expand_x=True, expand_y=True, size=(8, 1))], [Text(text="Made By: TonicBoomerKewl", expand_x=True, expand_y=True, auto_size_text=True)] ]) focus(win) res = win.read() win.close() if res[0] == "Copy": copy(prompt=prompt.strip(), text=text)
def getList(prompt: str, items: list) -> str: win: Window = Window(alpha_channel=0.8, finalize=True, debugger_enabled=False, resizable=True, text_justification="center", title=prompt.strip(), no_titlebar=True, keep_on_top=True, disable_close=True, disable_minimize=True, grab_anywhere=True, auto_size_text=True, layout=[ [Text(text=prompt.strip(), expand_x=True, expand_y=True, auto_size_text=True)], [Listbox( values=items, select_mode=LISTBOX_SELECT_MODE_SINGLE, enable_events=True, auto_size_text=True, expand_x=True, expand_y=True, size=(32, 16) )], [Text(text="Made By: TonicBoomerKewl", expand_x=True, expand_y=True, auto_size_text=True)] ]) focus(win) res = win.read() win.close() try: return res[1][0][0] except IndexError: return ''
def as_diff_rows(self, new_track_info: TrackInfo, title_case: bool = False, add_genre: bool = False): yield [HorizontalSeparator()] new_name = new_track_info.expected_name(self.track) if self.track.path.name != new_name: yield from get_a_to_b('File Rename:', self.track.path.name, new_name, self.path_str, 'file_name') else: yield [ Text('File:'), ExtInput(self.track.path.name, disabled=True, key=f'src::{self.path_str}::file_name'), Text('(no change)'), ] if diff_rows := self.get_diff_rows(new_track_info, title_case, add_genre): yield [Column(diff_rows, key=f'col::{self.path_str}::diff')]
def get_render_args(self) -> RenderArgs: full_layout, kwargs = super().get_render_args() ele_binds = {} options_frame = self.options.as_frame('apply_changes') if self.last_view and self.last_view.name != 'album': top_side_kwargs = dict(size=(6, 1), pad=(0, 0), font=('Helvetica', 20)) edit_button = Button('\u2190 Edit', key='edit', visible=True, **top_side_kwargs) edit_col = Column([[edit_button]], key='col::edit', expand_x=True) right_spacer = Text(key='spacer::1', **top_side_kwargs) first_row = [edit_col, options_frame, right_spacer] self.binds['<Control-e>'] = 'edit' else: first_row = [options_frame] layout = [first_row, [Text()], [HSep(), Text('Common Album Changes'), HSep()], [Text()]] if diff_imgs := self.album_formatter.get_cover_image_diff(self.album_info): src_img_ele, new_img_ele = diff_imgs img_row = [src_img_ele, Text('\u2794', key='txt::cover::arrow', font=('Helvetica', 20)), new_img_ele] img_diff_col = Column([img_row], key='col::img_diff', justification='center') layout.extend([[img_diff_col], [HSep()]])
def __init__(self): self.window = Window('Menu Funcionários').layout( [ [Text('O que você deseja fazer?')], [Text('Adicionar funcionário'), Button('0')], [Text('Remover funcionário'), Button('1')], [Text('Atualizar funcionário'), Button('2')], [Text('Obter funcionários cadastrados'), Button('3')], [Text('Detalhes do funcionário'), Button('4')], [Text('Adicionar veículo à funcionário'), Button('5')], [Text('Remover veículo de funcionário'), Button('6')], [Button('Voltar')] ] )
def get_render_args(self) -> RenderArgs: full_layout, kwargs = super().get_render_args() layout = [ [HSep(), Text('Wiki Match Options'), HSep()], [Text()], [ Text('Selected Album Path:'), ExtInput(self.album.path.as_posix(), disabled=True, size=(150, 1)) ], [Text()], [self.options.as_frame('find_match')], [Text()], ] workflow = self.as_workflow(layout, back_tooltip='Cancel Changes', next_tooltip='Find Match') full_layout.append(workflow) return full_layout, kwargs
def __init__(self, movies, page): if len(movies) == 0: layout = [[Text('Não há filmes')], [Button('Página Anterior' if page != 1 else 'Ok')]] else: layout = [[ Button(movie.get('Title')) if isinstance(movie, dict) else Button(movie.title) ] for movie in movies] layout += [[Button('Página Anterior'), Button('Próxima Página')] if page != 0 else [Button('Próxima Página')]] self.window = Window('Selecionar Filme').layout(layout)
def get_render_args(self) -> RenderArgs: layout = [[Menu(self.menu)]] if self.__class__ is MainView: select_button = Button('Select Album', key='select_album', bind_return_key=True, size=(30, 5), font=('Helvetica', 20)) inner_layout = [[Text(key='spacer::2', pad=(0, 0))], [select_button], [Text(key='spacer::1', pad=(0, 0))]] as_col = Column( inner_layout, key='col::select_album', justification='center', vertical_alignment='center', pad=(0, 0), expand_y=True, ) layout.append([as_col]) kwargs = {'title': f'Music Manager - {self.display_name}'} return layout, kwargs
def ViewGUI(): sg.theme('LightGreen') col1 = Column([ [Frame('base function',[[Column([[ Text(r'VideoFile',size=(10,1)), InputText(''*15, key="VideoFile"), FileBrowse(target='VideoFile', size=(10,1)), Button('start',key='start', size=(10,1)), Button('stop',key='stop', size=(10,1)), Button('Exit',key= 'exit', size=(10,1)),]], size=(800,45), pad=(0, 0))]])], [Frame('videoplay',[[Column([[Image(filename='', key='image',)]], size=(800,500), pad=(0, 0)) ]])] ], pad=(0,0)) col2 = Column([ [Frame('results', [[Column( [ [Image(filename='', key='image1', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))], [Image(filename='', key='image2', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))], [Image(filename='', key='image3', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))], [Image(filename='', key='image4', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))], [Image(filename='', key='image5', size=(200,100)), Button('view', size=(6,1)), Button('close', size=(6,1))], ] ,size=(400,560)) ]] )] ]) layout = [[col1,col2]] # layout = [ # [sg.Text(r'机器视觉原型系统', size=(40,1), justification='center')], # [sg.Text(r'VideoFile',size=(10,1)), sg.InputText(''*30, key="VideoFile"), sg.FileBrowse(size=(10,1)), # sg.Button('start',key='start', size=(10,1)), sg.Button('stop',key='stop', size=(10,1)), sg.Button('end', key='end', size=(10,1)), # sg.Button('Exit',key= 'exit', size=(10,1))], # [sg.Image(filename='', key='image')], # ] window = sg.Window( '机器视觉', layout, location=(100,100), finalize=True ) return window
def __init__(self, func): self.__validator = validator self.window = Window('Detalhes do funcionário') layout = [ [Text('Funcionário:')], ] veics = [] for veic in func.veiculos_cadastrados: veics.append([ Text( f' Placa: {veic.placa} - Marca: {veic.marca} - Modelo: {veic.modelo} ' ) ]) fields_out_of_validator = [ [Text((f'Bloqueado : {func.bloqueado}'))], [Text('Veiculos :')], ] + veics for k in self.__validator.keys(): repres = k.title( ) if k != 'data_nascimento' else 'Data de nascimento' layout.append([Text(f'{repres} : {getattr(func, k)}')]) layout += fields_out_of_validator layout.append([Button('Voltar')]) self.window.layout(layout)