So this is part 2 in which I am going to explain controlling UI. You can find part 1 here. The coding part will be done in python in this post but you can also do the same in C
PART 2: "Being the God to your UI"
Before we go into the coding you need to understand what I mean by 'controlling'.It is how you would want the application to respond to user clicking and stuff like that. So for this what actually happens is something like this ....
Little Introduction:
There is something called an 'X server' running on your comp. Long long ago when there used to be long bearded hippie coders in front of giant sized terminals and everyone used mechanical keyboards. The main 'X server' would actually be running some place else on some main computer with lots of computing power . Now anyone who wants a window, suppose a gedit window, would request this 'Xserver' to send it a window of gedit You could have asked from any room in your university and the main computer which is running the server will send the data to your machine on how to render this window.
So your machine just renders this on the screen. When you suppose click on some place, this X server is the one which gets to know where you clicked and it will hand these events to your application so that you can control what happens when a particular event occurs. So the X events include mouse click, key-press, key-release and many more which the 'X server' captures and tells your application about it if it is relevant to it.
To summarize what I said in the last paragraph, there are things called events which you need to handle which is the final step to make UI.
Let us get started.
Select the 'Signals' tab of the button and under 'GtkButton' select the 'clicked' event and under the Handler column for this event select a function name which you would like to define soon. I chose 'on_button1_clicked' .
Some thing like this
Read more!
PART 2: "Being the God to your UI"
Before we go into the coding you need to understand what I mean by 'controlling'.It is how you would want the application to respond to user clicking and stuff like that. So for this what actually happens is something like this ....
Little Introduction:
There is something called an 'X server' running on your comp. Long long ago when there used to be long bearded hippie coders in front of giant sized terminals and everyone used mechanical keyboards. The main 'X server' would actually be running some place else on some main computer with lots of computing power . Now anyone who wants a window, suppose a gedit window, would request this 'Xserver' to send it a window of gedit You could have asked from any room in your university and the main computer which is running the server will send the data to your machine on how to render this window.
So your machine just renders this on the screen. When you suppose click on some place, this X server is the one which gets to know where you clicked and it will hand these events to your application so that you can control what happens when a particular event occurs. So the X events include mouse click, key-press, key-release and many more which the 'X server' captures and tells your application about it if it is relevant to it.
To summarize what I said in the last paragraph, there are things called events which you need to handle which is the final step to make UI.
Let us get started.
Select the 'Signals' tab of the button and under 'GtkButton' select the 'clicked' event and under the Handler column for this event select a function name which you would like to define soon. I chose 'on_button1_clicked' .
Some thing like this