How do I create a user interface program in C?
I'm very new to programming, and I've been practicing C with terminal output, but now I want to create a physical program, like a calculator, where I can place buttons and code them. I have a mac and use xCode 12.2. How do I do this? What are the steps?
I have also downloaded the SDL library via terminal as I found out this was necessary.
- 1 month ago
You wanna know about GUI. Then,
1. Set properties.
2. The source code of callback.c.
In these two lines, the program will take glade widgets into Gtk widgets.
- husoskiLv 71 month ago
If you want to write a Mac-style graphical application, you need to use the Cocoa API and libraries, but that doesn't work with C. Apple only supports Swift (recommended for all new applications) or Objective-C (still supported for legacy applications.)
You can use SDL, but it doesn't come with any support for application windows, or the buttons, text boxes, and other controls that a graphical user interface (GUI) needs. It's just a very fast way to move pixels around, and access joysticks and other game controllers.
You may want to look at one of the cross-platform graphical APIs. Probably the most common choice for C is GTK. (www.gtk.org).
If you can expand your skill set to use C++, then libraries like Qt or wxWidgets. (Qt is essentially C++ only. There's a C binding for wxWidgets, but that's mainly intended to support interfacing to functional languages like Haskell or Ocaml. You might not find a lot of support for building applications in C.)
If you've never done any GUI programming before, get ready for a big learning curve. In a console-type program, or in a background service ("daemon"), your program runs from main() and calls system functions as needed. In a GUI program, the GUI library is "the system" and it calls your functions as needed to get things done.
- How do you think about the answers? You can sign in to vote the answer.
- PearlLv 71 month ago
if you type this on the search bar it might show you how to do it