Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Alternatives to standard c input/output

  1. Aug 23, 2009 #1
    I assume we should have commandline and GUI based...like QT and GTK (in linux) right?

    So if we wanna use these i/o interface, we need to include these QT and GTK libraries (which will be most probably included in the QT/GTK-dev package) instead of stdio.h right?

    Or, is it that the alternative is completely different and I'm completely wrong above?

    If I'm right, can anyone give me a link to a tutorial teaching how to use QT/GTK/(other interfaces) libraries?...or what package are they contained in?
  2. jcsd
  3. Aug 23, 2009 #2
    It's far, far more complicated than that. For one thing, you don't need to worry about event handlers and callbacks when you're working with stdio; if you're using Qt/GTk/etc, you do. You also need to learn about the API to your graphical toolkit, which takes time, effort, and tears.

    As an example of this sort of thing, the easiest thing to do is not to consider C/C++ at all but instead to look at Python. Implementing a GUI to a program is much easier in Python than in C/C++, but there's still quite a bit of work involved. For instance, you'd implement the standard Hello, World! app in Python using something like the following.

    Code (Text):

    #!/usr/bin/env python

    print "Hello, World!"

    This is much simpler than the corresponding C/C++ version, but it does pretty much the same thing: it prints "Hello, World!" to standard output. Now consider trying to do the same thing with the wxPython toolkit.

    Code (Text):

    #!/usr/bin/env python

    from wx import *

    app = wx.PyApp()
    frame = wx.Frame(None, wx.ID_ANY, "Hello, World!")
    You do much more work here. You have to

    • Import the wxPython module.
    • Create an instance of wx.PyApp in which to hold your graphical application.
    • Create a wx.Frame object for the actual graphical output, and specify its parent widget, its identifier, and its window title.
    • Actually tell the widget to display itself.
    • Hand off control to the wx.PyApp.MainLoop method so as to handle user-generated events.

    And that's just to print Hello, World in the title bar. To have it in a text box in the app involves even more work.

    The moral of all this is to concentrate on learning the fundamentals of whatever language you're using for as long as possible; you'll have plenty of time to look at graphical toolkits later on.
  4. Aug 23, 2009 #3
    At least we don't have paradoxes and REALLY unanswerable question like in physics......

    Then what about compiz?........I think that will be tooooo heavy. :rofl:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook