LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-29-2005, 08:37 AM   #1
Jean Of mArc
LQ Newbie
 
Registered: Nov 2005
Location: Canada
Posts: 25

Rep: Reputation: 15
C Programming GUIs - What now?


I just finished an intense course in C Programming, however we never covered the topic of GUIs... it was all about creating programs for stdin/stdout. I would really like to use this knowledge to create GUI programs, however, I'm not sure how to go about it.

Does anyone know of any good online resources for learning how to use C to create GUIs? Perhaps programs that help you design them? I know of Microsoft Visual C++, but of course that is for Windows (not to mention for C++ instead of C)...

Any ideas?

Thanks!
 
Old 11-29-2005, 08:46 AM   #2
bianchi
Member
 
Registered: Nov 2005
Location: Italy
Posts: 36

Rep: Reputation: 15
have you tried books ?
you need to choose which library of widgets you want to deal with ( motif , wxwidgets ...etc...)
 
Old 11-29-2005, 09:33 AM   #3
Jean Of mArc
LQ Newbie
 
Registered: Nov 2005
Location: Canada
Posts: 25

Original Poster
Rep: Reputation: 15
Well, I was hoping to find at least an introductory tutorial online...
I don't know about "dealing with widgets"... You might have to explain a little.

Also, which books would be recommended?
 
Old 11-29-2005, 11:14 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
are you sure?
doing GUI stuff in C is boring drudgery.
 
Old 11-29-2005, 12:22 PM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally posted by Jean Of mArc
Well, I was hoping to find at least an introductory tutorial online... [/B]
Like bigearsbilly said: GUI programming in C can be tedious. Most well-known GUI widget libraries are for C++ (or easier yet: perl, python, ...), and not without a reason: Object Oriented ("OOP") does help when doing GUI's.

That said, it is very well possible to do it in C, and even to do it in Object oriented manner. The GTK widget library, which is a well-known and stable one, is a C-library and tries hard to be Object Oriented. It does require more effort than when using a programming language that is Object Oriented. And if you dont' know any OOP-language, you will have some extra difficulties understanding GTK.

A tutorial for GTK is available.
 
Old 11-30-2005, 06:53 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
sorry, I didn't mean to appear negative
I personally find it dull. Last time I needed a GUI I wrote the
back end and communicated via a socket to a tcl/tk front end.


if you are interested
try playing with tcl/tk you can also directly link to it.


e.g. create a button
Code:
billym.>wish                                                       
% pack [button .b -text press -command exit ]
how's that for neat and elegant? (or is it lazy!)
 
Old 11-30-2005, 08:46 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
And the nicest thing about bigearsbilly's solution:
If properly written, the GUI runs on mac, linux, windows and a couple of OSes more without modification (except maybe for CR/LF)

Last edited by Wim Sturkenboom; 11-30-2005 at 08:48 AM.
 
Old 11-30-2005, 05:34 PM   #8
Jean Of mArc
LQ Newbie
 
Registered: Nov 2005
Location: Canada
Posts: 25

Original Poster
Rep: Reputation: 15
Hmmm...
Thanks for the suggestions guys. I've so far learned JAVA, C and some PHP, but the only GUI work I've done was with JAVA using the Swing library (but it is so hideous and uncustomizable that I really didn't like using it)...
I'd be willing to learn the syntax of a new programming language if need be,

So I don't really understand the basis of a GUI I don't think.
Is GTK a programming language? Or is it more of a GUI representation of code in another language? Would it better for me to use a different language (other than C) to use it?

I have similar questions about tcl/tk and wish...
What are they exactly and how do you use them?
 
Old 12-01-2005, 12:00 AM   #9
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
GTK is a library of functions that can be used to write graphical applications. You use it with a higher level language (like C).
The other often used library is Qt.

TCL is a scripting language. You need an interpreter for that (tclsh). TK is an extension to TCL and is used for the GUI part of it. TK is not limited to TCL, it's also available for Perl (and maybe for other scripting languages).
Wish is the interpreter for TK applications (and is able to interprete TCL as well or pass code to tclsh if it does not understand it itself (not sure how it works)).

Below is billy's code as an application.
Code:
#! /usr/bin/wish -f
pack [button .b -text press -command exit ]
Copy it to a file, set the executable bit (under *nix) and run it.

Standard TCL has some limitations (no UDP sockets; no database connectivity). For that reason, Perl might be a better option.
But for plain GUIs it's a very good choice.

http://www.tcl.tk

Whre I use it:
GUIs for my applications
GUIs for 3rd party equipment (provided it has RS232 or TCPIP connectivity)

Last edited by Wim Sturkenboom; 12-01-2005 at 12:13 AM.
 
Old 12-01-2005, 08:28 AM   #10
Jean Of mArc
LQ Newbie
 
Registered: Nov 2005
Location: Canada
Posts: 25

Original Poster
Rep: Reputation: 15
Thank you very much for that responce, Wim Sturkenboom!

I think I'm starting to understand what's going on here. Are there examples of programs that use TK or Wish that generally tend to come install on KDE computers that I could check out?

I'd like to make something using the KDE library... I know that you can use kdialog to get a bunch of neat things.
However, this probably makes it not so portable, eh?
Although I'm using Linux, all of my friends are using Windows, and so I'd like to be able to hand off my programs to them...

Thanks again,

Jean Of mArc
 
Old 12-01-2005, 08:40 AM   #11
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally posted by Jean Of mArc
Are there examples of programs that use TK or Wish that generally tend to come install on KDE computers that I could check out?
I'm not aware of any. There are some examples on the web, but that's mostly TCL and not TK.
 
Old 12-01-2005, 01:22 PM   #12
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
http://doc.trolltech.com/4.0/index.html
Click on Tutorial and Examples
 
Old 12-01-2005, 04:33 PM   #13
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Using Tcl/Tk for writing a GUI app is not a good idea. It's just a mess. Both GTK and Qt are much easier and have good tutorials, reference manuals and examples.
 
Old 12-02-2005, 12:01 AM   #14
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally posted by Mara
It's just a mess.
Please explain with a little detail
I don't see what is messy about clicking a button resulting in message to be send over a socket or reading data from a socket, parsing it and placing it in some widgets.

Last edited by Wim Sturkenboom; 12-02-2005 at 12:10 AM.
 
Old 12-02-2005, 01:59 AM   #15
destuxor
Member
 
Registered: Oct 2005
Posts: 51

Rep: Reputation: 16
GTK is really easy is really easy if you use Glade to design your interface and do everything through the callbacks. Seriously; download/install Glade and run through some tutorials.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GUIs juvestar15 Linux - Newbie 5 09-10-2005 07:15 AM
Is it possible to use other types of GUIs? Nukem DamnSmallLinux 4 02-13-2004 09:32 AM
Different Users - Different GUIs mikefromau Slackware 3 02-06-2004 08:17 AM
any ssh guis? p0 theed Linux - Software 11 11-23-2003 10:23 PM
GUIs Jed Linux - Newbie 1 08-09-2003 05:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration