Página Inicial > Gtk/Gdk, GtkLabel > Como alinhar o conteudo de um GtkLabel

Como alinhar o conteudo de um GtkLabel

Solução

Existe um método chamado set_alignment(x, y). Nele é passado 2 parâmetros, X e Y.
Os valores variam entre 0, 0.5 e 1, sendo 0 esquerda e topo, 0.5 meio, 1 direita e baixo.

Exemplo

<?php
   // Classe de testes
   class Teste
   {
      // Vetor que armazena todos os widgets da interface
      public $widgets = array();
      
      // Construtor da classe
      public function __construct()
      {
         // Cria o container
         $fixed = new GtkFixed();
         
         // Cria o Label
         $this->widgets['lblTeste'] = new GtkLabel("MEU LABEL");
         $this->widgets['lblTeste']->set_size_request(100, 50);
         $fixed->put($this->widgets['lblTeste'], 8, 8);
         
         // Seta o alinhamento
         $this->widgets['lblTeste']->set_alignment(1, 1);
         
         // Cria a janela
         $this->widgets['frmTeste'] = new GtkWindow();
         $this->widgets['frmTeste']->set_size_request(116, 66);
         $this->widgets['frmTeste']->set_resizable(FALSE);
         $this->widgets['frmTeste']->set_title("Teste");
         $this->widgets['frmTeste']->add($fixed);
         $this->widgets['frmTeste']->set_position(GTK::WIN_POS_CENTER);
         $this->widgets['frmTeste']->show_all();
         
         // Conecta o destroy
         $this->widgets['frmTeste']->connect_simple(
            "destroy",
            array("Gtk", "main_quit")
         );
      }
   }

   // Inicia a aplicação
   $teste = new Teste();
   gtk::main();
 

Explicação

Você pode utilizar as combinações para obter o melhor efeito.

Referências

http://gtk.php.net/manual/en/gtk.gtkmisc.method.set_alignment.php

Categories: Gtk/Gdk, GtkLabel Tags:
  1. Nenhum comentário ainda.
  1. Nenhum trackback ainda.