Re: Gtk2::Table widget alignment



Fred. Oger said:
 - use 'fill' instead of 'shrink'.

If I use 'fill', the problem I encounter is the Gtk2::Entry fills the
whole table cell which I don't want.

i figured, but it's worth mentioning.  :-)


 - pack the widget into a GtkAlignment, set the alignment to left or right,
and then attach the alignment to the table.

This is the solution I found rigth after posting the question. It's a bit
fastidious as I have around 20 entries in this form.

whew... been there.

[warning - coding/design style suggestions follow]

in such situations i've made a habit of rearranging things so that i can
vectorize the creation of the table rows.  this has the added benefit of
decoulpling things so that you can rearrange and replace them quite easily. 
perl is great for this sort of thing.

  # declare the row relationships as data rather than code
  @rows = (
     { label => 'foo', type => 'entry', var => \$foo_val }
     { label => 'bar', type => 'bool', var => \$bar_val }
     { label => 'baz', type => 'entry', var => \$baz_val }
  );
  foreach my $r (@rows) {
     # write the logic to create a row once
     # with different cases for different row types
  }

as you notice, you wind up creating a generic UI toolkit in the interest of
saving yourself some code.  this is similar in scope to glade, with the form
defined as data, but you can tailor it to exactly what you want.  i have some
stuff for a project at work that defines large config property sets, stored as
hashes of objects, which can be turned into an elaborate tabbed dialog
automagically with a single (recursive) function call.  the trouble is, to
make it generic enough for general use would take me into that last 10% of the
work that takes 90% of the time, so it will probably never be seen outside of
work.  c'est la vie.


Another question: How can I have a Gtk2::TextView to be edged-in like the
Entry widget ?

set the shadow type on the scrolled window into which you packed the
textview...  or the frame, if you didn't put it into a scrolled window.

http://developer.gnome.org/doc/API/2.0/gtk/GtkScrolledWindow.html#gtk-scrolled-window-set-shadow-type

-- 
muppet <scott at asofyet dot org>



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