Função para Abrir uma Interface do tkinter no Centro da Tela em Python
Publicado por Mauricio Ferrari em 07/10/2021
[ Hits: 8.998 ]
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()
Métodos para a Limpeza do Terminal do Linux em C
Pacotes KDE Plasma 5 do Slackware 14.2
Instalando o IPTVnator no Slackware
Como Converter uma String em Char Array em C++
Kino 1.3.4 no Slackware 14.2 x64
Hardware Project Simulator 0.1 - Simulador de montagem de computadores
EarSketch - Aplicativo online que usa Python para criar e remixar músicas
Spyder - Excelente IDE para desenvolver em Python
Como alterar a versão default (padrão) do Python no Linux
Novo TradutorOOoNote substitui texto e envia o antigo para anotação
Nenhum comentário foi encontrado.
Atualizar o macOS no Mac - Opencore Legacy Patcher
Crie alias para as tarefas que possuam longas linhas de comando - bash e zsh
Criando um gateway de internet com o Debian
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Aprenda a criar músicas com Inteligência Artificial usando Suno AI
Instalando e usando o Dconf Editor, o "regedit" para Linux
Como instalar o navegador TOR no seu Linux
Problema no audio do GoogleMeet, Zoom e streamyard (0)
O que eu faço com o pen drive de 200mb? (9)
Não consigo conectar WiFi USB (5)
NagiosQL "quebran... ao tentar importar arquivos do Nagios Core (0)
Log: core: Interactive#t... error - IOError closed stream (1)