Question

I am attempting to fix the size of a widget in GTK+, specifically using Gtk2hs with Haskell.

I have drawn an image in a DrawingArea and I would like to specify the exact size of this drawing area. I do not want other widgets or the user to make this widget larger or smaller. Is this possible?

Note, I am using ghc version 6.10.4 under Ubuntu 9.10. Gtk2hs version 0.10.1.

Was it helpful?

Solution

You can call gtk_widget_set_size_request() to cause a widget to request a fixed height and width. You'll have to determine the Haskell equivalent.

Note that this is generally a Bad Idea(TM) and you should arrange your containers and child packing properties such that your controls are sized appropriately. For example, changing the size of your image will require code changes if you're hardcoding size request values.

OTHER TIPS

The Gtk2Hs function to fix a widget size is :

widgetSetSizeRequest 
  :: WidgetClass self    
  => self    
  -> Int    
  -> Int    
  -> IO ()

with as arguments :

  1. The widget
  2. Width of the Widget
  3. Height of the Widget
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top