Re: GtkEntry



hi,
I tried resized within the Grid and did not happen. I tried to resize within this frame and within the grid and not worked. Finally I put the frame inside the box and the box on the grid and it worked.
I will put the code below:


Agenda.h

#ifndef AGENDA_H
#define AGENDA_H


#include<gtkmm-3.0/gtkmm/window.h>
#include<gtkmm-3.0/gtkmm/radiobutton.h>
#include<gtkmm-3.0/gtkmm/grid.h>
#include<gtkmm-3.0/gtkmm/enums.h>
#include<gtkmm-3.0/gtkmm/entry.h>
#include<gtkmm-3.0/gtkmm/label.h>
#include<gtkmm-3.0/gtkmm/frame.h>
#include<gtkmm-3.0/gtkmm/box.h>
#include<gtkmm-3.0/gtkmm/buttonbox.h>
#include<gtkmm-3.0/gtkmm/separator.h>
#include<gtkmm-3.0/gtkmm/button.h>
#include<gtkmm-3.0/gtkmm/calendar.h>
#include<gtkmm-3.0/gtkmm/application.h>
#include<glibmm-2.4/glibmm/refptr.h>
#include<glibmm-2.4/glibmm/ustring.h>

class Agenda : public Gtk::Window
{

public:
    Agenda();
    virtual ~Agenda();
   
protected:
  Gtk::Entry ent_nome, ent_endereco, ent_bairro, ent_horario, ent_telefone, ent_celular, ent_servico, ent_taxa;
  Gtk::Label lab_nome, lab_endereco, lab_bairro, lab_horario, lab_telefone, lab_celular, lab_servico, lab_taxa;
  Gtk::ButtonBox boxbotao;
  Gtk::Button bt_novo, bt_editar, bt_cancelar, bt_excluir, bt_fechar;
  Gtk::Frame fr_clienteB, *fr_Entry, fr_clienteG, fr_Sexo;
  Gtk::Box hbox, vbox, *hbox_entry;
  Gtk::Separator separador;
  Gtk::Grid grade;
  Gtk::RadioButton rb_sexoF, rb_sexoM;
 
   

};



Agenda.cpp

#include "agenda.h"
#include<iostream>



Agenda::Agenda(): lab_nome("Nome"), lab_endereco("Endereço"), lab_bairro("Bairro"),
lab_telefone("Telefone"), lab_celular("Celular"), lab_servico("Tipo de Serviço"), lab_horario("Horário Marcado"),
lab_taxa("Taxa de Serviço"), hbox(Gtk::ORIENTATION_HORIZONTAL, 5), vbox(Gtk::ORIENTATION_VERTICAL)

{
  set_title("Agendamento de Asteca");
  set_default_size(600,400);
 
 
 
  fr_clienteB.set_label("Clientes");
  fr_clienteB.set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
  fr_clienteB.add(grade);
 
  //Nome
  grade.attach(lab_nome, 0, 0, 1, 1);
  lab_nome.set_halign(Gtk::ALIGN_START);
  lab_nome.set_margin_top(10);
//   grade.attach(ent_nome, 0, 1, 1, 1);
//   ent_nome.set_width_chars(30);
 
  fr_Entry = new Gtk::Frame();
  fr_Entry->set_shadow_type(Gtk::SHADOW_NONE);
  hbox_entry = new Gtk::Box();
  hbox_entry->add(*fr_Entry);
  fr_Entry->add(ent_nome);
  hbox_entry->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
  ent_nome.set_width_chars(30);
  ent_nome.set_max_length(30);
  ent_nome.set_max_width_chars(30);
  grade.attach(*hbox_entry, 0,1,1,1);
 
  //sexo
  fr_Sexo.set_label("Sexo");
  fr_Sexo.set_margin_top(10);
  fr_Sexo.set_margin_left(30);
  fr_Sexo.add(hbox);
  hbox.pack_start(rb_sexoF);
  hbox.pack_start(rb_sexoM);
  rb_sexoF.set_label("Feminino");
  rb_sexoM.set_label("masculino");
  grade.attach(fr_Sexo, 2, 0, 1, 2);
 
 
  //Endereço
  grade.attach(lab_endereco, 0,2,1,1);
  lab_endereco.set_halign(Gtk::ALIGN_START);
  lab_endereco.set_margin_top(10);
  fr_Entry = new Gtk::Frame();
  fr_Entry->set_shadow_type(Gtk::SHADOW_NONE);
  hbox_entry = new Gtk::Box();
  hbox_entry->add(*fr_Entry);
  fr_Entry->add(ent_endereco);
  hbox_entry->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
  ent_endereco.set_width_chars(25);
  ent_endereco.set_max_length(25);
  ent_endereco.set_max_width_chars(25);
  grade.attach(*hbox_entry, 0,3,1,1);
 
 

 
 
 
  vbox.pack_start(fr_clienteB);
 
  vbox.pack_start(separador);
 
 /* fr_clienteG.set_label("Grade");
  fr_clienteG.add(grade);
 
 
  ent_endereco.set_margin_left(5);
//   grade.add(lab_endereco);
//   grade.add(ent_endereco);*/
 
 
  vbox.add(fr_clienteG);
 
  add(vbox);
 
  show_all_children();
 
 
}


Agenda::~Agenda()
{

}


main.cpp


#include "agenda.h"

int main(int argc, char *argv[])
{

Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "liomarhora");
  Agenda ag;
 
  return app->run(ag);




}

2016-01-30 8:53 GMT-03:00 Liomar da Hora <liomarhora gmail com>:
hi,
I tried resized within the Grid and did not happen. I tried to resize within this frame and within the grid and not worked. Finally I put the frame inside the box and the box on the grid and it worked.
I will put the code below:


Agenda.h

#ifndef AGENDA_H
#define AGENDA_H


#include<gtkmm-3.0/gtkmm/window.h>
#include<gtkmm-3.0/gtkmm/radiobutton.h>
#include<gtkmm-3.0/gtkmm/grid.h>
#include<gtkmm-3.0/gtkmm/enums.h>
#include<gtkmm-3.0/gtkmm/entry.h>
#include<gtkmm-3.0/gtkmm/label.h>
#include<gtkmm-3.0/gtkmm/frame.h>
#include<gtkmm-3.0/gtkmm/box.h>
#include<gtkmm-3.0/gtkmm/buttonbox.h>
#include<gtkmm-3.0/gtkmm/separator.h>
#include<gtkmm-3.0/gtkmm/button.h>
#include<gtkmm-3.0/gtkmm/calendar.h>
#include<gtkmm-3.0/gtkmm/application.h>
#include<glibmm-2.4/glibmm/refptr.h>
#include<glibmm-2.4/glibmm/ustring.h>

class Agenda : public Gtk::Window
{

public:
    Agenda();
    virtual ~Agenda();
   
protected:
  Gtk::Entry ent_nome, ent_endereco, ent_bairro, ent_horario, ent_telefone, ent_celular, ent_servico, ent_taxa;
  Gtk::Label lab_nome, lab_endereco, lab_bairro, lab_horario, lab_telefone, lab_celular, lab_servico, lab_taxa;
  Gtk::ButtonBox boxbotao;
  Gtk::Button bt_novo, bt_editar, bt_cancelar, bt_excluir, bt_fechar;
  Gtk::Frame fr_clienteB, *fr_Entry, fr_clienteG, fr_Sexo;
  Gtk::Box hbox, vbox, *hbox_entry;
  Gtk::Separator separador;
  Gtk::Grid grade;
  Gtk::RadioButton rb_sexoF, rb_sexoM;
 
   

};



Agenda.cpp

#include "agenda.h"
#include<iostream>



Agenda::Agenda(): lab_nome("Nome"), lab_endereco("Endereço"), lab_bairro("Bairro"),
lab_telefone("Telefone"), lab_celular("Celular"), lab_servico("Tipo de Serviço"), lab_horario("Horário Marcado"),
lab_taxa("Taxa de Serviço"), hbox(Gtk::ORIENTATION_HORIZONTAL, 5), vbox(Gtk::ORIENTATION_VERTICAL)

{
  set_title("Agendamento de Asteca");
  set_default_size(600,400);
 
 
 
  fr_clienteB.set_label("Clientes");
  fr_clienteB.set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
  fr_clienteB.add(grade);
 
  //Nome
  grade.attach(lab_nome, 0, 0, 1, 1);
  lab_nome.set_halign(Gtk::ALIGN_START);
  lab_nome.set_margin_top(10);
//   grade.attach(ent_nome, 0, 1, 1, 1);
//   ent_nome.set_width_chars(30);
 
  fr_Entry = new Gtk::Frame();
  fr_Entry->set_shadow_type(Gtk::SHADOW_NONE);
  hbox_entry = new Gtk::Box();
  hbox_entry->add(*fr_Entry);
  fr_Entry->add(ent_nome);
  hbox_entry->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
  ent_nome.set_width_chars(30);
  ent_nome.set_max_length(30);
  ent_nome.set_max_width_chars(30);
  grade.attach(*hbox_entry, 0,1,1,1);
 
  //sexo
  fr_Sexo.set_label("Sexo");
  fr_Sexo.set_margin_top(10);
  fr_Sexo.set_margin_left(30);
  fr_Sexo.add(hbox);
  hbox.pack_start(rb_sexoF);
  hbox.pack_start(rb_sexoM);
  rb_sexoF.set_label("Feminino");
  rb_sexoM.set_label("masculino");
  grade.attach(fr_Sexo, 2, 0, 1, 2);
 
 
  //Endereço
  grade.attach(lab_endereco, 0,2,1,1);
  lab_endereco.set_halign(Gtk::ALIGN_START);
  lab_endereco.set_margin_top(10);
  fr_Entry = new Gtk::Frame();
  fr_Entry->set_shadow_type(Gtk::SHADOW_NONE);
  hbox_entry = new Gtk::Box();
  hbox_entry->add(*fr_Entry);
  fr_Entry->add(ent_endereco);
  hbox_entry->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
  ent_endereco.set_width_chars(25);
  ent_endereco.set_max_length(25);
  ent_endereco.set_max_width_chars(25);
  grade.attach(*hbox_entry, 0,3,1,1);
 
 

 
 
 
  vbox.pack_start(fr_clienteB);
 
  vbox.pack_start(separador);
 
 /* fr_clienteG.set_label("Grade");
  fr_clienteG.add(grade);
 
 
  ent_endereco.set_margin_left(5);
//   grade.add(lab_endereco);
//   grade.add(ent_endereco);*/
 
 
  vbox.add(fr_clienteG);
 
  add(vbox);
 
  show_all_children();
 
 
}


Agenda::~Agenda()
{

}


main.cpp


#include "agenda.h"

int main(int argc, char *argv[])
{

Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "liomarhora");
  Agenda ag;
 
  return app->run(ag);




}











2016-01-29 18:14 GMT-03:00 Ian Martin <martin_id vodafone co nz>:
Hi,
Posting the code that isn't working would be helpful.  

Have you tried to resize it using the other methods available to an entry- set_size_request()? set_max_length()?  The online documentation states that set_max_length_chars()  "Sets the desired maximum width in characters of entry. ".  If it only sets the desired width, then I'd be looking for another option that sets the maximum width more definitively.

HTH,

Ian


On 30/01/16 01:01, Liomar da Hora wrote:
Yes, but I can not resize the Gtk :: Entry.

2016-01-29 9:01 GMT-03:00 Liomar da Hora <liomarhora gmail com>:
sim, mas não consegui redimencionar o Gtk::Entry.

2016-01-28 19:29 GMT-03:00 Ian Martin <martin_id vodafone co nz>:
Hi,
Have you looked at Grid::get_column_homogeneous ()  and Grid::set_column_homogeneous (bool homogeneous=true)?

Ian.


On 28/01/16 06:52, Liomar da Hora wrote:
Hello guys,
I am inserting GtkEntry within a column of GtkGrid.
the first GtkEntry has max_width_char (30).
the second has max_width_char (5).
But the two are staying with size 30, despite being in different lines.
the second is on the width of the first in the same column.
How can I fix this?


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]