GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 22, 2014 2:12 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: gtkmm help with exposing window
PostPosted: Sun Mar 01, 2009 7:01 pm 
Offline
Familiar Face

Joined: Thu Nov 06, 2008 3:43 pm
Posts: 22
So I have only been messing around with gtk/gtkmm only for three months and it has only been the drawing area part. What I am trying to do is create an interface for my senior design project where we are utilizing cairo's vector drawing skills to to draw gauges that will be manipulated with the data received from out data logger hardware.

The one problem out of a couple problems that I am having right now is that when I want my objec to display the window and the initialized drawing then enter the main loop that checks the data logger for data and draws it to the screen. I tried to draw the window while i was still in the constructor and then enter the onject's main loop while in the constructor. When I do this the window is not displayed and it stays in the main loop forever. I realized its because I never left the constructor

I know in int main to get the program running you have to added it to gtkmm's main loop. so my question is: how would I be able to enter into my main loop after the window has been created.

Evan


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 9:45 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello.

For updating display with new data, I usually use timeout function.

First, I create my GUI components. Just before calling gtk_main(), I add my timeout function with g_timeout_add call. From that timeout function I update my GUI according to the data.

Another solution would be to use Glib's IO channels. Then you can watch your channel with g_io_add_watch.

Hope you'll find some useful information in this.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 10:03 pm 
Offline
Familiar Face

Joined: Thu Nov 06, 2008 3:43 pm
Posts: 22
I would use Glib's io_signals but the serial library (libserial) we're using does ntoo return a file descriptor. Yea a timeout function sounds like that is the best way to go. We're aiming to update our display about 20 times a second so I should probably set the timeout faster than that. the timeout signal would act like a mina loop for me and I should have it point to my update function that checks the queue for data from the hardware.

Also, if i was in the middle of a process the timeout signal wouldn't activate and take me out of that process would it or does it activate when it detects that there is nothing going on.


Evan


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 10:27 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
While you're inside timeout function, main loop is blocked, so nothing happens while you're in the middle of the data reading process.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 01, 2009 11:48 pm 
Offline
Familiar Face

Joined: Thu Nov 06, 2008 3:43 pm
Posts: 22
ok thanks I'll try it out


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group