Pysimplegui - Button Alignment in Columns

Asked

Viewed 73 times

0

Good night,

I am trying a problem with the alignment of 2 columns, what happens is that the second column has a button and I would like to leave it aligned to the right (as in the second image) remaining with the contents of the first column aligned to the left (as in the first image).

I’ve tried using the Column(element_justification='right') but it didn’t work, however if I use the Column(justification='right') everything goes to the right, including the previous column. I tried other things but nothing worked.

Currently:

inserir a descrição da imagem aqui

Using the Column(justification='right')

inserir a descrição da imagem aqui

import PySimpleGUI as sg
from webbrowser import open
gitLink = 'https://github.com/DiegoAL'
sg.theme('DefaultNoMoreNagging')
# Elementos da janela

cbox_layout = [[sg.Checkbox('Iniciar o Profitchart após limpeza', True, enable_events=True, key='start')],
               [sg.Checkbox('Fechar após limpeza', enable_events=True, key='close')],
               [sg.Checkbox('Escolher um executável especifico', enable_events=True, key='newPath')]]

btn_layout = [[sg.Button('Limpar!', size=(10, 4), enable_events=True, key='clear')]]

layout = [[sg.Column(cbox_layout),
          sg.Column(btn_layout)],
          [sg.In(), sg.FileBrowse()],
          [sg.Text('Idealizado por: Diego Alves'),
           sg.Text('Link do Projeto', size=(24, 0),
           justification='right', enable_events=True, key='link',
           text_color='blue', font='underline')]] #[FIX] font não esta funcionando
# Criacao e demais configuracoes da janela
window = sg.Window('Profitchart Cleaner', layout)

# Leitura dos dados e eventos
while True:
    event, values = window.read()
    # Fechar aplicacao
    if event == sg.WINDOW_CLOSED:
        break
    # Acessar a pagina do Projeto
    if event == 'link':
        open(gitLink)

window.close()

1 answer

0

An alternative I found to solve your alignment problem is to add an empty column between the selections boxes and the button and adjust the size with size=:

layout = [[sg.Column(cbox_layout),
           sg.Column([[sg.Text('',size=(2,0))]]),
           sg.Column(btn_layout)],

Here I used size=(2, 0) and was well adjusted to the right side, result:

inserir a descrição da imagem aqui

Your complete code:

import PySimpleGUI as sg
from webbrowser import open
gitLink = 'https://github.com/DiegoAL'
sg.theme('DefaultNoMoreNagging')
# Elementos da janela

cbox_layout = [[sg.Checkbox('Iniciar o Profitchart após limpeza', True, enable_events=True, key='start')],
               [sg.Checkbox('Fechar após limpeza', enable_events=True, key='close')],
               [sg.Checkbox('Escolher um executável especifico', enable_events=True, key='newPath')]]

btn_layout = [[sg.Button('Limpar!', size=(10, 4), enable_events=True, key='clear')]]

layout = [[sg.Column(cbox_layout),
           sg.Column([[sg.Text('',size=(2,0))]]),
          sg.Column(btn_layout)],
          [sg.In(), sg.FileBrowse()],
          [sg.Text('Idealizado por: Diego Alves'),
           sg.Text('Link do Projeto', size=(24, 0),
           justification='right', enable_events=True, key='link',
           text_color='blue', font='underline')]] #[FIX] font não esta funcionando
# Criacao e demais configuracoes da janela
window = sg.Window('Profitchart Cleaner', layout)

# Leitura dos dados e eventos
while True:
    event, values = window.read()
    # Fechar aplicacao
    if event == sg.WINDOW_CLOSED:
        break
    # Acessar a pagina do Projeto
    if event == 'link':
        open(gitLink)

window.close()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.