开发者

Fixing the size of a GTK Widget?

开发者 https://www.devze.com 2022-12-20 11:03 出处:网络
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 drawi开发者_如何

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 drawi开发者_如何学JAVAng 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.


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号