GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 23, 2014 4:08 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: gtk tables in a scrollingregion with sticky header
PostPosted: Thu Nov 01, 2012 7:14 pm 
Offline

Joined: Thu Nov 01, 2012 6:47 pm
Posts: 1
I use GTK for many projects and I have never been able to figure out how to do the following. I want to have a table that scrolls, but has column headers that dont scroll, but do follow the column width of the scrolled table on resizing.

This is how I would do a scrolled table:
Code:
  table = gtk_table_new(10,3,FALSE);
/* fill in the table here */
  sc = gtk_scrolled_window_new( NULL, NULL );
  gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(sc), table );

I must be missing something simple.
Thanks,

Jeff Hagen
Software Engineer
Steward Observatory Mirror Lab
jhagen@as.arizona.edu


Top
 Profile  
 
 Post subject: Re: gtk tables in a scrollingregion with sticky header
PostPosted: Fri Nov 02, 2012 12:33 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
You're not missing something simple but something quite complex. There are a number of ways:
#1. Use GtkTreeView. It has the scrollable window/ unscrolled header combination by default. Never used it myself - I'm rating this one as complex because TreeView is quite a bit to learn because of its very generic nature and that they don't make it especially easy.
#2. Have a table in a scrolled window and the headers in a box and link them in your code so that the one will update the other. Sub-optimal really.
#3. Create a custom widget to do exactly what you want. Essentially the same as #2, except that the link between the two is handled internally by the widget rather than externally.

Despite having a strong aversion to learning treeview I would lean towards it unless there was also other fancy features to add in. Getting it to look the way you want might take a fair bit of work. I think it's possible but don't really have experience on this. There seems to be plenty of tutorials around on treeview and if you search the forum you should find a few examples too (e.g. a slightly old post but one I imagine similar to what you are doing is http://www.gtkforums.com/viewtopic.php?t=3362)

btw if you are moving to gtk3 you will want to use grid instead of table and box. Also ATK doesn't work with custom widgets in gtk3<3.8 whereas it's built in to treeview.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group