Função para Abrir uma Interface do tkinter no Centro da Tela em Python
Publicado por Mauricio Ferrari em 07/10/2021
[ Hits: 8.933 ]
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()
Ocenaudio no Slackware - uma alternativa mais simples ao Audacity
Interface gráfica para o p7zip no Linux Mint e Ubuntu
Trocando o LILO pelo GRUB no Slackware
Instalando o Aplicativo de Videoconferência Zoom no Deepin 20
Como adicionar PPA no Deepin 20
"RPG Maker" escrito em Python e Pygame
TP-1 Engine - motor para criação de jogos
Usando a função map em vez de for (Python)
Instalando o pyenv no Linux Mint e Ubuntu
Compilando e testando o Unladen Swallow no Linux
Nenhum comentário foi encontrado.
Links importantes de usuários do VOL (3)
Atenção a quem posta conteúdo de dicas, scripts e tal (2)
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
Entendendo o que é URI, URL, URN e conhecendo as diferenças entre POST e GET
Criando um Pen Drive Bootável no Linux
Instalando Discord no Fedora 40
Instalando Discord no Ubuntu 24.04 LTS
Como instalar o XFCE4-terminal na sua distribuição Linux e integrá-lo ao sistema
Como instalar o Tilix Terminal no Gnome e usá-lo como menu drop-down ao estilo Quake
Não existe o slackbuild do bash no repositório slackbuild? (1)