Widgets not show()'ing



I a newbie to Gtk and Gtkmm but have previous experience with X and Motif, so it's not too foreign to me.

I wrote some C++ libraries that create data that I would like to view in a test GUI that will display the data as two plots. The plots will be a visual comparison between a "base" plot and the GUI will cycle through the rest of the data in the file and display each plot in green.

I originally wrote something using Gtk, but since my libraries were already in C++ I didn't like having to use Gtk's C interface so I tried changing it over to Gtkmm. As far as I can tell, my Gtkmm code looks like it should work, but something obviously isn't working the way I expect it.

I've tried everything I could think of by perusing the reference libraries and tutorials that I've found on the net but haven't had any luck.

What I'm hoping to have is a window with a MenuBar, a DrawingArea for the plots and an area that has various control button and sliders to view the "base" plot against the other plots.

When I start my GUI, I get the following:

With the MenuBar but no DrawingArea or viewer controls.

Here's a snippet of the code that I think should have everything show()n.
class GUI: public Gtk::Window
{
public:
    GUI ();
    virtual ~GUI ();

private:
    void addMenuBar ();
    void addPlotArea ();
    void addViewingControls ();

    virtual bool on_configure_event (GdkEventConfigure* event);
    virtual bool on_expose_event (GdkEventExpose* event);

    Table mainTable;
    MenuItem saveAsButton;
    DrawingArea plotArea;
    HScale delayScale;
    HScale trainerScale;
    HScale testScale;
    Button backwardButton;
    Gtk::Image backwardImage;
    Button prevButton;
    Gtk::Image prevImage;
    Button stopButton;
    Gtk::Image stopImage;
    Button nextButton;
    Gtk::Image nextImage;
    Button forwardButton;
    Gtk::Image forwardImage;
};


GUI::GUI ()
{
    string iconPath (getenv ("PWD"));
    if (!iconPath.empty ())
    {
        backwardImage.set (iconPath + "/icons/backward.png");
        prevImage.set (iconPath + "/icons/previous.png");
        stopImage.set (iconPath + "/icons/stop.png");
        nextImage.set (iconPath + "/icons/next.png");
        forwardImage.set (iconPath + "/icons/forward.png");
    }

    mainTable.resize (4, 6);
    mainTable.set_homogeneous (false);
    mainTable.set_col_spacings (5);

    addMenuBar ();
    addPlotArea ();
    addViewingControls ();

    mainTable.show_all_children ();
    mainTable.show ();

    add (mainTable);

    show_all_children ();
}

GUI::~GUI ()
{
}

void GUI::addMenuBar ()
{
    Glib::RefPtr actionGroup = ActionGroup::create ();

    actionGroup->add (Action::create ("MenuFile", "_File"));
    actionGroup->add (Action::create ("Open", "_Open"),
                      sigc::mem_fun (*this, &GUI::openFileDialog));
    actionGroup->add (Action::create ("SaveAs", "Save _As..."),
                      sigc::mem_fun (*this, &GUI::saveAsDialog));
    actionGroup->add (Action::create ("Exit", "E_xit"),
                      sigc::mem_fun (*this, &GUI::exit));

    Glib::RefPtr uiMgr = UIManager::create ();
    uiMgr->insert_action_group (actionGroup);
    add_accel_group (uiMgr->get_accel_group ());

    Glib::ustring ui_info = ""
        "  "
        "    "
        "      "
        "      "
        "      "
        "      "
        "    "
        "  "
        "";

    uiMgr->add_ui_from_string (ui_info);

    Widget* menuBar = uiMgr->get_widget ("/MenuBar");

    mainTable.attach (*menuBar, 0, 6, 0, 1);
}

void GUI::addPlotArea ()
{
    plotArea.set_size_request (510, 420);

    signal_configure_event().connect (sigc::mem_fun (*this,
                                                     &GUI::on_configure_event));
    signal_expose_event().connect (sigc::mem_fun (*this,
                                                  &GUI::on_expose_event));

    mainTable.attach (plotArea, 0, 6, 1, 2);
}

void GUI::addViewingControls ()
{
    Table viewingControlTable (3, 5, true);

    Label scaleLabel ("Delay (secs):");
    viewingControlTable.attach (scaleLabel, 0, 1, 0, 1);
    scaleLabel.show ();

    Adjustment delayAdj (0.0, 0.0, 1.0, 0.05, 0.05);
    delayScale.set_adjustment (delayAdj);
    delayScale.set_digits (2);
    delayScale.set_draw_value (true);
    delayScale.set_value_pos (POS_TOP);
    delayScale.set_update_policy (UPDATE_DISCONTINUOUS);
    delayScale.signal_value_changed ().connect (sigc::mem_fun (
                                                    *this, &GUI::updateDelay));
    delayScale.show ();
    viewingControlTable.attach (delayScale, 1, 5, 0, 1);

    Table profileItrTable (2, 2, true);
    Adjustment profileAdj (0.0, 0.0, 1.0, 1.0, 1.0);

    Label trainerLabel ("Trainer");
    profileItrTable.attach (trainerLabel, 0, 1, 0, 1);
    trainerLabel.show ();

    Label testLabel ("Test");
    profileItrTable.attach (testLabel, 1, 2, 0, 1);
    testLabel.show ();

    trainerScale.set_adjustment (profileAdj);
    trainerScale.set_draw_value (false);
    trainerScale.set_update_policy (UPDATE_CONTINUOUS);
    trainerScale.signal_value_changed ().connect (sigc::mem_fun (
                                                      *this,
                                                      &GUI::updateProfileScale));
    trainerScale.show ();
    profileItrTable.attach (trainerScale, 0, 1, 1, 2);

    testScale.set_adjustment (profileAdj);
    testScale.set_draw_value (false);
    testScale.set_update_policy (UPDATE_CONTINUOUS);
    testScale.signal_value_changed ().connect (sigc::mem_fun (
                                                   *this,
                                                   &GUI::updateProfileScale));
    testScale.show ();
    profileItrTable.attach (testScale, 1, 2, 1, 2);
    profileItrTable.show_all_children ();
    profileItrTable.show ();

    viewingControlTable.attach (profileItrTable, 0, 5, 1, 2);

    backwardButton.set_image (backwardImage);
    backwardButton.signal_clicked ().connect (sigc::mem_fun (
                                                  *this,
                                                  &GUI::backwardButtonClicked));
    backwardButton.set_sensitive (false);
    backwardButton.show ();
    viewingControlTable.attach (backwardButton, 0, 1, 2, 3);

    prevButton.set_image (prevImage);
    prevButton.signal_clicked ().connect (sigc::mem_fun (
                                              *this,
                                              &GUI::prevButtonClicked));
    prevButton.set_sensitive (false);
    prevButton.show ();
    viewingControlTable.attach (prevButton, 1, 2, 2, 3);

    stopButton.set_image (stopImage);
    stopButton.signal_clicked ().connect (sigc::mem_fun (
                                              *this,
                                              &GUI::stopButtonClicked));
    stopButton.set_sensitive (false);
    stopButton.show ();
    viewingControlTable.attach (stopButton, 2, 3, 2, 3);

    nextButton.set_image (nextImage);
    nextButton.signal_clicked ().connect (sigc::mem_fun (
                                              *this,
                                              &GUI::nextButtonClicked));
    nextButton.set_sensitive (false);
    nextButton.show ();
    viewingControlTable.attach (nextButton, 3, 4, 2, 3);

    forwardButton.set_image (forwardImage);
    forwardButton.signal_clicked ().connect (sigc::mem_fun (
                                                 *this,
                                                 &GUI::forwardButtonClicked));
    forwardButton.set_sensitive (false);
    forwardButton.show ();
    viewingControlTable.attach (forwardButton, 4, 5, 2, 3);

    viewingControlTable.show_all_children ();
    viewingControlTable.show ();

    mainTable.attach (viewingControlTable, 0, 6, 2, 3);
}
Is there something obvious that I'm missing? I tried tossing in all of the show() and show_all_children() methods to see if that would help, but the window comes up the same way whether they are there or not.

View this message in context: Widgets not show()'ing
Sent from the Gtkmm mailing list archive at Nabble.com.


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