G+_Darryl Medley Posted March 7, 2014 Share Posted March 7, 2014 GUI Coding 101 - Episode 7 New Concepts Explained GUI (Graphical User Interface) programming has a couple of fundamental differences from Console coding that Lou didn't have a chance to cover in his short segment. I will attempt to explain them for those interested. The first is the use of graphical objects (buttons, text boxes, etc.). These objects have 3 main attributes: Properties, Events, and Methods. Properties are just values such as Width and Height that define the object - in this case it's size on the screen. Properties can be set at design time and also read and / or changed with code. Events allow you to write special methods (functions) called Event Handlers that run automatically in response to some action. Buttons have an OnClick event. Text boxes have events such as OnEnter, OnChange, etc., that you can attach code to. Finally, object Methods are just functions that are built in to objects that can be called to do something. For example, a grid object might have a LoadFromFile method that fills the grid with data. The second fundamental difference between console and GUI is the way code executed. A console program just runs your code from top to bottom and you the programmer have complete control over what the user can do at any moment. GUI programs are coded using Event-driven programming. Instead of the program just running from top to bottom, the program sits there waiting to respond to events, such as a button click. So the end user, not your code now determines to large extent what code runs when. This is important because Event-driven programs require a completely different approach to application design. (I hope Padre and Shannon cover design soon because good design is crucial to good code.) Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted March 8, 2014 Share Posted March 8, 2014 The event-driven vs. sequential thing is important to understand, but it's not unique to GUIs. Web servers and databases, for example, also often use an event-driven model. Link to comment Share on other sites More sharing options...
Recommended Posts