Re: About Gtk::Bin?
- From: Simon Fuhrmann <simonfuhrmann gmx de>
- To: BC Zhu <zhubicen gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: About Gtk::Bin?
- Date: Sat, 13 Dec 2008 15:54:13 +0100
Actually, I have no idea why it does not work. Seems to be a problem
with the Gtk::Bin. I replaced it with a Box and it worked.
Simon
---
#include <gtkmm.h>
class Viewer : public Gtk::HBox
{
private:
Gtk::Table table_;
Gtk::Button button_;
public:
Viewer() : table_(2, 2), button_("ZHU")
{
table_.attach(button_, 0, 1, 0, 1);
pack_start(table_);
}
};
class Window : public Gtk::Window
{
private:
Viewer viewer_;
public:
Window()
{
add(viewer_);
show_all();
}
};
int main (int argc,char *argv[])
{
Gtk::Main kit(argc, argv);
Window win;
kit.run(win);
return 0;
}
BC Zhu wrote:
> Thanks Simon.
> I modify the code so it looks like following:
>
> ....
> Viewer():table_(2, 2), button_("ZHU"){
> add(table_);
> table_.attach(button_, 0, 1, 0, 1);
> show_all_children();
> }
> .............
> But unfortunately, it still can not work as we expeceted. It shows nothing.
> Thank you all the same.
>
>
> 2008/12/13 Simon Fuhrmann <simonfuhrmann gmx de>:
>> You have to add the table to the bin.
>> So put "add(table_);" before "show_all_children();"
>>
>> Simon
>>
>> BC Zhu wrote:
>>> I was wondering the reason why the following code cann't work? It
>>> shows nothing, i expect it can show one button.
>>> How to fix this issue?
>>> Thanks in advance.
>>>
>>> #include <gtkmm.h>
>>> #include <gtkmm/main.h>
>>> #include <gtkmm/window.h>
>>> class Viewer:public Gtk::Bin
>>> {
>>> public:
>>> Viewer():table_(2, 2), button_("ZHU"){
>>> table_.attach(button_, 0, 1, 0, 1);
>>> show_all_children();
>>> }
>>> private:
>>> Gtk::Table table_;
>>> Gtk::Button button_;
>>> };
>>> class Window:public Gtk::Window
>>> {
>>> public:
>>> Window(){
>>> add(viewer_);
>>> viewer_.show();
>>> }
>>> private:
>>> Viewer viewer_;
>>> };
>>> int main (int argc,char *argv[])
>>> {
>>> Gtk::Main kit(argc, argv);
>>> Window win;
>>> Gtk::Main::run(win);
>>> return 0;
>>> }
>>
>
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]