Adding and removing widgets at runtime
- From: "Daniel." <danielhilst gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Adding and removing widgets at runtime
- Date: Mon, 12 Sep 2016 11:35:22 -0300
Hi everybody,
I have a library implementing some protocol. That library is
multithread and is responsible to delivery messages to remote nodes
and retrieve it's responses. I need to visualise the whole mess
running.
To do this I wrote a simple application in Java/Swing where for each
remote node one thread is created. The thread will send a message and
wait for response in a closed loop. Each thread is represented at GUI
by a label on the screen. When it's idle the background of that label
becomes green, when is waiting for response it is yellow and if
timeouts it becomes red. All labels have the same information so that
they have exactly the same size.
Beside the request/repsonse there is events that can arrive from the
nodes too. That events need to be replied as the messages. When an
event arrives it's showed up on screen as a new label. When it's reply
is acknowledge it's removed from the screen.
In pratice there is a big container where the labels came and go and
change its background colors based on messages, replies and events
comming and going.
I've been using FlowLayout as the "big container". The labels are
added and arrange horizontally by FlowLayout. When no room is avaible
at the current row, a new row is added. When the rows exceed the
window size a scrowbar appears.
I'm looking for something silimar with GTK2 (I'll run in a embeeded
system that doesn't have GTK3).
My questions are:
1) Is there some container with equivalent behavior to the Swing's
FlowLayout? If no I think I'll need to build one from hbox+vbox, what
would be the best aproach to it.
2) How is the best way to change the background of a label?
3) What is the better aproach when adding instantiating, adding,
showing, hiding removing and freeing widgets at runtime? What can get
wrong?
References:
https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html#flow
Best regards,
--
"Do or do not. There is no try"
Yoda Master
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]