Regarding Changing Background Color of the Window

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Regarding Changing Background Color of the Window

deepak.bhujangachar
Dear All,

My name is Deepak, I have created a GUI using Glade 3.20. I want to  
change the background color of the window. I am using GTKMM 3.0. I  
accessed the widgets using derived classes. I attached the code what I  
did. I am getting errors. I am new to C++ and GTKMM. Please help me  
regarding this. Required libraries are included

int main (int argc, char **argv)
{

   auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

   //Load the Glade file and instantiate its widgets:
   auto refBuilder = Gtk::Builder::create();

   try
   {
     refBuilder->add_from_file("Functional_GUI1.glade");
   }
   catch(const Glib::FileError& ex)
   {
     std::cerr << "FileError: " << ex.what() << std::endl;
     return 1;
   }
   catch(const Glib::MarkupError& ex)
   {
     std::cerr << "MarkupError: " << ex.what() << std::endl;
     return 1;
   }
   catch(const Gtk::BuilderError& ex)
   {
     std::cerr << "BuilderError: " << ex.what() << std::endl;
     return 1;
   }

   //Get the GtkBuilder-instantiated dialog:
    mainWindow* pWindow = nullptr;
    Control_panel* pControl = nullptr;

    refBuilder->get_widget_derived("Functional_Testing", pWindow);
    refBuilder->get_widget_derived("Panel_Grid", pControl);

    pWindow->set_title("SKANRAY PRODUCTS");
    pWindow->override_background_color(Gtk.StateType.NORMAL,  
Gdk.RGBA(.5,.5,.5,.5));

   if(pWindow)
   {
     app->run(*pWindow);
   }

   delete pWindow;

   return 0;

}

Thanks
Deepak
HARVEL Systems

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Regarding Changing Background Color of the Window

Daniel Boles
  • It is no use to tell us you are getting errors without telling us what those are; few people will want to compile your code for you with no hints
  • override_background_color() et al are deprecated. It's possible your build disables deprecated symbols, but then we can't see your build file any more than we can see your mysterious errors.
  • In any case this is the kind of thing that should be done in CSS; basically any visual styling that is possible in CSS should be done there instead of in widget code. Otherwise you're increasing your pain when having to port to GTK+ 4 later.


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Loading...