# Hbox alignment with pack\_start

**URL:** <https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671>\
**Category:** Ruby-Gnome 2\
**Created:** [January 22, 2014, 10:46pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671 "2014-01-22T22:46:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [January 22, 2014, 10:46pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/1 "2014-01-22T22:46:24Z")

</div>

Hi, I tried to make an interface like this.

[http://i.imgur.com/hwfq1n6.png](http://i.imgur.com/hwfq1n6.png)

But my interface:

[http://i.imgur.com/F6OQ1nX.png](http://i.imgur.com/F6OQ1nX.png)

I want to adjoin toolbar and gtk.entry line. How can I do this? And  
source code:

win = Gtk::Window.new  
swin = Gtk::ScrolledWindow.new  
swin\_vpaned = Gtk::Paned.new(:horizontal)  
viewport = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)  
@file\_store = Gtk::ListStore.new(String, String, TrueClass,  
Gdk::Pixbuf)  
main\_vbox = Gtk::Box.new(:vertical, 2)  
toolbar\_hbox = Gtk::Box.new(:horizontal, 0)  
menus = create\_menubar  
create\_toolbar()  
toolbar\_hbox.pack\_start(@toolbar, :expand =\> false, :fill =\> true,  
:padding =\>0)  
toolbar\_hbox.pack\_start(@file\_path\_entry, :expand =\> true, :fill =\>  
true, :padding =\> 0)

```
main_vbox.pack_start(menus, :expand => false, :fill => false,

```

:padding =\> 2)  
main\_vbox.pack\_start(toolbar\_hbox, :expand =\> true, :fill =\> true,  
:padding =\> 2)  
main\_vbox.pack\_start(swin\_vpaned, :expand =\> true, :fill =\> true,  
:padding =\> 1)  
treeview\_vbox = Gtk::Box.new(:vertical, 1)  
# devices treeview  
dev\_treeview = create\_devices\_treeview  
treeview\_vbox.pack\_start(dev\_treeview, :expand =\> false, :fill =\>  
false, :padding =\> 2)  
create\_places\_treeview

```
treeview_vbox.pack_start(@places_treeview)
swin_vpaned.pack1(treeview_vbox, :resize => true, :shrink => false)
swin_vpaned.pack2(swin, :resize => true, :shrink => false)

```

win = Gtk::Window.new  
swin = Gtk::ScrolledWindow.new  
swin\_vpaned = Gtk::Paned.new(:horizontal)  
viewport = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)  
@file\_store = Gtk::ListStore.new(String, String, TrueClass,  
Gdk::Pixbuf)  
main\_vbox = Gtk::Box.new(:vertical, 2)  
toolbar\_hbox = Gtk::Box.new(:horizontal, 0)  
menus = create\_menubar  
create\_toolbar()  
toolbar\_hbox.pack\_start(@toolbar, :expand =\> false, :fill =\> true,  
:padding =\>0)  
toolbar\_hbox.pack\_start(@file\_path\_entry, :expand =\> true, :fill =\>  
true, :padding =\> 0)

```
main_vbox.pack_start(menus, :expand => false, :fill => false,

```

:padding =\> 2)  
main\_vbox.pack\_start(toolbar\_hbox, :expand =\> true, :fill =\> true,  
:padding =\> 2)  
main\_vbox.pack\_start(swin\_vpaned, :expand =\> true, :fill =\> true,  
:padding =\> 1)  
treeview\_vbox = Gtk::Box.new(:vertical, 1)  
# devices treeview  
dev\_treeview = create\_devices\_treeview  
treeview\_vbox.pack\_start(dev\_treeview, :expand =\> false, :fill =\>  
false, :padding =\> 2)  
create\_places\_treeview

```
treeview_vbox.pack_start(@places_treeview)
swin_vpaned.pack1(treeview_vbox, :resize => true, :shrink => false)
swin_vpaned.pack2(swin, :resize => true, :shrink => false)

```

def create\_toolbar  
@toolbar = Gtk::Toolbar.new  
@toolbar.set\_size\_request(30,30)

# tool buttons

@back\_toolbut = Gtk::ToolButton.new(:stock\_id =\> Gtk::Stock::GO\_BACK)  
@next\_toolbut = Gtk::ToolButton.new(:stock\_id =\>  
Gtk::Stock::GO\_FORWARD)  
home\_toolbut = Gtk::ToolButton.new(:stock\_id =\> Gtk::Stock::HOME)  
up\_toolbut = Gtk::ToolButton.new(:stock\_id =\> Gtk::Stock::GO\_UP)

@back\_toolbut.sensitive = false  
@next\_toolbut.sensitive = false  
@back\_toolbut.signal\_connect(“clicked”){fill\_store(“back”)}  
@next\_toolbut.signal\_connect(“clicked”){fill\_store(“next”)}  
@toolbar.insert(@back\_toolbut, 0)  
@toolbar.insert(@next\_toolbut, 1)  
@toolbar.insert(up\_toolbut, 2)  
@toolbar.insert(home\_toolbut, 3)

# @toolbar.set\_size\_request(5, 5)

end

Thanks.

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 5:16pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/2 "2014-01-23T17:16:04Z")

</div>

I tried your suggestion but still it doesn’t fix.  
[http://i.imgur.com/hwfq1n6.png](http://i.imgur.com/hwfq1n6.png)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 3:29pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/3 "2014-01-23T15:29:23Z")

</div>

Ebru A. wrote in post #1134048:

> I want to adjoin toolbar and gtk.entry line. How can I do this? And  
> source code:

> create\_toolbar()  
> toolbar\_hbox.pack\_start(@toolbar, :expand =\> false, :fill =\> true,  
> toolbar\_hbox.pack\_start(@file\_path\_entry, :expand =\> true, :fill =\> true,  
> main\_vbox.pack\_start(menus, :expand =\> false, :fill =\> false,  
> main\_vbox.pack\_start(toolbar\_hbox, :expand =\> true, :fill =\> true  
> main\_vbox.pack\_start(swin\_vpaned, :expand =\> true, :fill =\> true,

Perhaps you should expand false on packing tollbar\_hbox :  
main\_vbox.pack\_start(toolbar\_hbox, :expand =\> _false_, :fill =\> true

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 6:05pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/4 "2014-01-23T18:05:58Z")

</div>

Ebru A. wrote in post #1134151:

this intruction can trouble your toolbar :  
@toolbar.set\_size\_request(30,30)

see example at :  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-tb](http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-tb)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 6:47pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/5 "2014-01-23T18:47:27Z")

</div>

Ebru A. wrote in post #1134151:

> I tried your suggestion but still it doesn’t fix.  
> [http://i.imgur.com/hwfq1n6.png](http://i.imgur.com/hwfq1n6.png)

So sorry, I’ve sent wrong screenshot, actually it is:

[http://i.imgur.com/7bFUvfN.png](http://i.imgur.com/7bFUvfN.png)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 6:51pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/6 "2014-01-23T18:51:15Z")

</div>

Regis d’Aubarede wrote in post #1134162:

> with gtk3, this must be done :
> 
> main\_vbox.homogeneous=false  
> and  
> toolbar\_hbox..homogeneous=false

I set homogeneous=false but again it doesn’t fix. I don’t get any error.  
Source code:

win = Gtk::Window.new  
swin = Gtk::ScrolledWindow.new  
swin\_vpaned = Gtk::Paned.new(:horizontal)  
viewport = Gtk::Viewport.new(swin.hadjustment, swin.vadjustment)  
@file\_store = Gtk::ListStore.new(String, String, TrueClass,  
Gdk::Pixbuf)  
main\_vbox = Gtk::Box.new(:vertical, 2)  
toolbar\_hbox = Gtk::Box.new(:horizontal, 0)  
menus = create\_menubar  
create\_toolbar()  
toolbar\_hbox.pack\_start(@toolbar, :expand =\> false, :fill =\> true,  
:padding =\>0)  
toolbar\_hbox.pack\_start(@file\_path\_entry, :expand =\> true, :fill =\>  
true, :padding =\> 0)

```
main_vbox.pack_start(menus, :expand => false, :fill => false,

```

:padding =\> 2)  
main\_vbox.pack\_start(toolbar\_hbox, :expand =\> false, :fill =\> true,  
:padding =\> 2)  
main\_vbox.pack\_start(swin\_vpaned, :expand =\> true, :fill =\> true,  
:padding =\> 1)  
treeview\_vbox = Gtk::Box.new(:vertical, 1)  
create\_devices\_treeview()  
treeview\_vbox.pack\_start(@devices\_treeview, :expand =\> false, :fill  
=\> false, :padding =\> 2)  
create\_places\_treeview

```
main_vbox.homogeneous=false
toolbar_hbox.homogeneous=false
treeview_vbox.pack_start(@places_treeview)
swin_vpaned.pack1(treeview_vbox, :resize => true, :shrink => false)
swin_vpaned.pack2(swin, :resize => true, :shrink => false)

```

And screenshot:  
[http://i.imgur.com/0Zy1heT.png](http://i.imgur.com/0Zy1heT.png)

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 6:37pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/7 "2014-01-23T18:37:26Z")

</div>

with gtk3, this must be done :

main\_vbox.homogeneous=false  
and  
toolbar\_hbox…homogeneous=false

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 8:01pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/8 "2014-01-23T20:01:15Z")

</div>

for me, it is better : hbox (toolbar+entry) take only necessary vertical  
space.  
Toolbar display only an arrow, I do not know why…  
What append if the entry is not packed ?

---

<div class="post-metadata">

**Author:** ![ebruakagunduz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ea666f/32.png) [@ebruakagunduz](https://www.ruby-forum.com/u/ebruakagunduz)\
**Post date:** [January 23, 2014, 11:34pm UTC](https://www.ruby-forum.com/t/hbox-alignment-with-pack-start/238671/9 "2014-01-23T23:34:14Z")

</div>

Regis d’Aubarede wrote in post #1134172:

> for me, it is better : hbox (toolbar+entry) take only necessary vertical  
> space.  
> Toolbar display only an arrow, I do not know why…  
> What append if the entry is not packed ?

When I remove Gtk.entry it seems like this:  
[http://i.imgur.com/SK0AecT.png](http://i.imgur.com/SK0AecT.png)

Probably cause of hbox I think.

But I couldn’t find out how can I ensure interface that i want, I think  
I should use vbox, hbox. But it wasn’t.
