Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6217189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:22:57+00:00 2026-05-24T07:22:57+00:00

I have a Window with three Entry widgets and one Button. I use the

  • 0

I have a Window with three Entry widgets and one Button. I use the button to remove one of the widgets programmatically. The problem is that the main window doesn’t change it’s size to fit the new layout after it’s been removed.

I can imagine that I need to send some Signal or Event to the main loop which would cause the recalculation but I’ve been unable to find such functionality.

Here is some example code:

import Graphics.UI.Gtk
import Data.IORef
import qualified Graphics.UI.Gtk as G hiding (Point)
import qualified Graphics.UI.Gtk.Gdk.EventM as E
import qualified Graphics.UI.Gtk.Abstract.Widget as W
import qualified Graphics.Rendering.Cairo as C


makeEntry :: String -> IO Entry
makeEntry str = do e <- entryNew
                   entrySetText e str
                   return e

main :: IO ()
main = do
  initGUI
  window <- windowNew
  box <- vBoxNew False 0
  G.on window G.keyPressEvent $ E.tryEvent $ do
    "Escape" <- E.eventKeyName
    C.liftIO $ G.widgetDestroy window

  set window [ containerChild := box ]

  e1 <- makeEntry "e1"
  boxPackStart box e1 PackNatural 0

  e2 <- makeEntry "e2"
  boxPackStart box e2 PackNatural 0

  e3 <- makeEntry "e3"
  boxPackStart box e3 PackNatural 0

  button <- buttonNew
  set button [ buttonLabel := "Remove" ]
  boxPackStart box button PackNatural 0

  onClicked button (containerRemove box e2)
  onDestroy window mainQuit
  widgetShowAll window
  mainGUI
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:22:57+00:00Added an answer on May 24, 2026 at 7:22 am

    You can ask your top-level window how big it wants to be, and make it be that big:

    refresh window = do
        Requisition w h <- widgetSizeRequest window
        windowResize window w h
    

    To use this, stick it in the button’s click-handler:

    onClicked button (containerRemove box e2 >> refresh window)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent window for entry transaction that havs customer ID field input.
In VB.net 3.5 SP1 I have a Windows Form with three DataGridView controls. One
In Java, is there a way to have a window that is Always on
I have a borderless Windows Forms application. The main window creates other forms (simple
I have a user control that is nested inside a window that is acting
I have a website that grabs a random entry from a database and displays
I have three Windows Server 2003 with 2 GB RAM. Server1 tomcat 5.5.25 jvm
Is there a way for me to have the Window of my WPF application
I have a three-tier Windows Forms DB application in VB.NET. I'm using VS 2005.
suppose, we have a Mozilla Prism like XULRunner app. There is a XUL window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.