Função para Abrir uma Interface do tkinter no Centro da Tela em Python
Publicado por Mauricio Ferrari em 07/10/2021
[ Hits: 8.567 ]
Blog: https://www.youtube.com/@LinuxDicasPro
def center(win): # :param win: the main window or Toplevel window to center # Apparently a common hack to get the window size. Temporarily hide the # window to avoid update_idletasks() drawing the window in the wrong # position. win.update_idletasks() # Update "requested size" from geometry manager # define window dimensions width and height width = win.winfo_width() frm_width = win.winfo_rootx() - win.winfo_x() win_width = width + 2 * frm_width height = win.winfo_height() titlebar_height = win.winfo_rooty() - win.winfo_y() win_height = height + titlebar_height + frm_width # Get the window position from the top dynamically as well as position from left or right as follows x = win.winfo_screenwidth() // 2 - win_width // 2 y = win.winfo_screenheight() // 2 - win_height // 2 # this is the line that will center your window win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) # This seems to draw the window frame immediately, so only call deiconify() # after setting correct window position win.deiconify()
import tkinter as tk main_app = tk.Tk() main_app.attributes('-alpha', 0.0) # Opcional, para deixar a janela totalmente transparente até os ajustes serem feitos. main_app.minsize(500, 300) center(main_app) # A função main_app.attributes('-alpha', 1.0) # A interface fica visível novamente. main_app.mainloop()
Deixando o Google Chrome em modo Dark no Linux - Experimental
Claws Mail - Erro na conexão com imap.google.com: login recusado [Resolvido]
RecordMyDesktop no Slackware Funcionando no KDE Plasma 5
Exibindo o nome completo dos pacotes instalados no Debian e derivados
"RPG Maker" escrito em Python e Pygame
Hardware Project Simulator 0.1 - Simulador de montagem de computadores
Vídeo sobre como participar do Google Summer of Code
Reproduzindo vídeos em modo texto no Linux
Nenhum comentário foi encontrado.
Como agendar um backup automático do PostgreSQL no Cron evitando o problema de senha
Como preparar o Vim/Neovim para corrigir ortografia em português
Dark Web e Malwares na internet, quanto custa?
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Exportação de histórico do Brave para o Firefox
Remapear e/ou trocar teclas no Linux
to falando dnv pq deletaram o meu topico (0)
Alexabolada casa comigo por favor, larga o Fábio e o VOL e vem comigo!... (12)
synalogy servidor de arquivos (2)
Atalho ctrl + Alt + T não funciona (2)
Não consigo fazer o adptador para cabo de rede funcionar (17)