How would one go about writing a VERY SIMPLE GUI for Linux?

MournSanity

Diamond Member
Feb 24, 2002
3,126
0
0
I'm willing to learn everything necessary to do this for a science fair project I will be doing next year for my AP Computer Science class. I have ZERO knowledge of Linux programing, and I'm thinking that this wold be a good way to start. I'm not a Linux pro or anything like that, so I want to learn my way around in everything and EVENTUALLY, HOPEFULLY, write some simple programs and then a simple GUI for a project I hope to do.

I'm currently very impaired because I only have Mandrake 8.1 and unfortunatly cannot get another disto because I do not hve broadband and I'm too poor to plunk down some money for a distro at Fry's. Hopefully my parents will eventually subscribe to broadband sometime next month so I can get crackin' witht he Linux community.

Ok, I got a little OT there, anyway, if you were to write a SIMPLE GUI, NOTHING like KDE or Gnome, how would you go around doing it? Learning C++, Qt(or whatever)? I'm taking a Java course in the fall if that helps.
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Certainly you wouldn't start from scratch, at least at first. You've got the source - use it. Tab Window Manager is probably as simple as it gets - that's the one included with the XFree86 package. Maybe take that, and find some simple feature to add or remove from it. Use that purpose to pick apart the meaning of the code. That will give you an idea of the basic calls that X expects. If you want to work from scratch, you could go from there.

Also, while I have no serious programming authority, my understanding is that this is a very difficult way to start programming in Linux. Xlib is notoriously difficult to program with - which is why KDE and GNOME are built on toolkits like Qt and GTK+. But if you actually want to write a window manager, then you need to know Xlib. It would be much more reasonable to write a graphical program to run within one of those existing frameworks. Both GTK+ and Qt are fairly simple to learn, and both have bindings for scripted languages like Perl and Python if you know those already.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
The 3 ones I'd recommend:

glade: VB-like drag 'n drop gtk2 widgets 'n stuff. Not my cup of tea, messy and confusing, IMO. You can use C++ or python or probably other languages to code the rest of the stuff.
python + tkinter: This would be the easiest, but it's ugly. http://starship.python.net/crew/da/Tk/objeditor.gif If you have python installed (and if you have linux installed, I bet you do), you are ready to get started.
python + wxwindows: I hear wx is nastier than tkinter, but I have almost no experience with either. You'd need to install the proper packages.


Here's a hello world-style tkinter example: http://incise.org:82/~death/tkinter.python

I'd pretty much recommend tkinter+python. Unless it's important for it to look good. :)
 

dawks

Diamond Member
Oct 9, 1999
5,071
2
81
Not much for your actual question, but I could suggest the use of a download manager or an FTP program, both of which can be/are capable of resuming, so over a period of a week or two, you could have another distro of linux downloaded :D
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Also (and perhaps this prompted the question), there was a Slashdot link to an article on cross-platform toolkits in the last day or two. That might be a good place to start reading.
 

MournSanity

Diamond Member
Feb 24, 2002
3,126
0
0
Thank you so much for all the feedback guys :) I know hae a better understanding of what's ahead of me :)
 

manly

Lifer
Jan 25, 2000
13,286
4,062
136
I'll send you a free Linux distro in the mail if you'd like, esp. if you'll take a slightly older one that I already have laying around.

As for creating a GUI, it doesn't get much easier than Java Swing, either with a RAD development tool or from scratch.

Not to say Swing is a good toolkit, or that it scales well, but it's pretty simple to whip up a Swing UI.
 

MGMorden

Diamond Member
Jul 4, 2000
3,348
0
76
Man, this is a pretty serious undertaking :). I'll be betting my BS in CompSci in December and it's not something I would be able to do very easily (note: I could do it, just not easily ;)). If you're gonna try though, learn C++, hopefully as you learn Java. The idealology of the two mesh really well (ie, if you can write Java code then you can write C++ code as soon as you learn the syntax. you don't really need to learn a new way to look at things like if you went from Java to C or BASIC or the like). As to GUI toolkits . . . hmm. Most of my GUI development I do under MS Visual Basic and Borland C++ Builder on the Windows side, and Borland Kylix on the Linux side. None of that will work for you. The only toolkit I've used in conjunction with GCC was the v toolkit, which was absolutely terrible to work with (I only used it b/c it was a requirement of the project I was working on. the class has since switched to Qt
rolleye.gif
). Out of sheer popularity I'm going to say to go with GTK2 or Qt, as those are going to be the easiest to work with. Good luck.

EDIT: I'm assuming by creating a GUI you were refering to creating a window manager of some sort. If you're talking about creating a simple GUI application, I suggest you grab Borland Kylix Open Edition (it's free for non-commercial use) and code away :).
 

Originally posted by: hypersonic5
Thank you so much for all the feedback guys :) I know hae a better understanding of what's ahead of me :)

if you want a newer version of linux, name the distro and ill see what I can do. I have broadband and im also about to leave for school, so my speeds should be a bit faster there.
 

MournSanity

Diamond Member
Feb 24, 2002
3,126
0
0
Hopefully my parents will finally subscribe me to a DSL service September 1st or so.


Anyways, yea, the GUI I want to make is sort of like a window manager. Actually, what I am trying to do is make a Linux based set top box for my TV :) I want the GUI to be able to display some options like DVD, GAME, INTERNET, etc. And if I click game, I get a list where I would be able to choose, say, Quake 3. Think of the Xbox dashboard but 100X more ghetto :) That's what I want to do :)
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: hypersonic5
Hopefully my parents will finally subscribe me to a DSL service September 1st or so.


Anyways, yea, the GUI I want to make is sort of like a window manager. Actually, what I am trying to do is make a Linux based set top box for my TV :) I want the GUI to be able to display some options like DVD, GAME, INTERNET, etc. And if I click game, I get a list where I would be able to choose, say, Quake 3. Think of the Xbox dashboard but 100X more ghetto :) That's what I want to do :)
You know what a window manager does, right? The little borders around windows? Dragging, resizing, maximizing, iconifying, shading, these are the things a window manager provides. It is not reasonable to expect to create one for a school project IMO.

If you're just talking about toolbars and dialog boxes and junk like that, then my previous post applies.
 

MournSanity

Diamond Member
Feb 24, 2002
3,126
0
0
I know what a window manager is. I guess you are right about how unreasonable it is for a school project, and it would not work well for a set top box I guess. I guess what I a trying to say is that I need to make a nice interface like say a DVD bonus menu or something. I'm sorry if I am not explaining it too well as English isn't my first language. I'll try to make some mock-ups of what i am trying to do in photoshop.
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
It sounds like you're basically talking about an application-launcher kind of gizmo. You don't need a new window manager for this. Just use an existing one, write your app, and have that app start automatically after bootup. Could you write a window manager or some other kind of direct interface to X11 so that your app would truly be the grapical interface rather than just ride on top of the interface? Sure. But it would be probably 50 times more difficult. I'm a teacher, and I absolutely admire your enthusiasm. But, no offense intended, if you haven't even taken a programming class yet, you don't have any concept of the magnitude of what you're asking. A very simple launcher app that takes some input via basic drop-down menus and launches external programs would be a substantial project. Achievable with a lot of work, but don't expect that an intro programming class is going to take you very far into that territory.
 

MournSanity

Diamond Member
Feb 24, 2002
3,126
0
0
Originally posted by: cleverhandle
It sounds like you're basically talking about an application-launcher kind of gizmo. You don't need a new window manager for this. Just use an existing one, write your app, and have that app start automatically after bootup. Could you write a window manager or some other kind of direct interface to X11 so that your app would truly be the grapical interface rather than just ride on top of the interface? Sure. But it would be probably 50 times more difficult. I'm a teacher, and I absolutely admire your enthusiasm. But, no offense intended, if you haven't even taken a programming class yet, you don't have any concept of the magnitude of what you're asking. A very simple launcher app that takes some input via basic drop-down menus and launches external programs would be a substantial project. Achievable with a lot of work, but don't expect that an intro programming class is going to take you very far into that territory.

It's not an intro programming class. It's AP Computer Science. Eh, I guess you could call it intro though :p But you are correct, I am making everything harder for myself. But you must understand, I am willing to work on this for a couple of years, if need be. It's not just a project for school. It is a project for myself mainly. I want to accomplish something and add something to the Linux community as well.

Here's the thing: I need to make the operating system so that when it loads up, it goes straight to the
main menu, no logging in, no choosing a window manager(I know I could always choose one to always load up as default). The thing is, most window managers are really bloaty, and would lower gaming performance on the machine I presume. Is there any way I could replace a window manager like KDE with something like my mock up gui?
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: hypersonic5
Originally posted by: cleverhandle
It sounds like you're basically talking about an application-launcher kind of gizmo. You don't need a new window manager for this. Just use an existing one, write your app, and have that app start automatically after bootup. Could you write a window manager or some other kind of direct interface to X11 so that your app would truly be the grapical interface rather than just ride on top of the interface? Sure. But it would be probably 50 times more difficult. I'm a teacher, and I absolutely admire your enthusiasm. But, no offense intended, if you haven't even taken a programming class yet, you don't have any concept of the magnitude of what you're asking. A very simple launcher app that takes some input via basic drop-down menus and launches external programs would be a substantial project. Achievable with a lot of work, but don't expect that an intro programming class is going to take you very far into that territory.

It's not an intro programming class. It's AP Computer Science. Eh, I guess you could call it intro though :p But you are correct, I am making everything harder for myself. But you must understand, I am willing to work on this for a couple of years, if need be. It's not just a project for school. It is a project for myself mainly. I want to accomplish something and add something to the Linux community as well.

Here's the thing: I need to make the operating system so that when it loads up, it goes straight to the
main menu, no logging in, no choosing a window manager(I know I could always choose one to always load up as default). The thing is, most window managers are really bloaty, and would lower gaming performance on the machine I presume. Is there any way I could replace a window manager like KDE with something like my mock up gui?

It would be pretty trivial to get it to boot up to X and to your specific app. I've found that almost no window managers are bloaty. KDE and Gnome are bloaty, but they're not window managers, and, their respective window managers (kwin, and metacity, respectively), are pretty light in my experience. There's only so much bloat you can accomplish in a 20px window border. :p Ok, I take that back. Enlightenment is bloated. But that's the only one I can think of, and arguably a desktop environment, not just a window manager. Bloaty window managers or even KDE or Gnome should not affect gaming performance, as long as running out of ram is not an issue. CPU-cycle-wise, they mostly sit around and do nothing, when you're not interacting with them. Bring up a terminal and run "top", and then sit back and do nothing. You'll see top taking up maybe 1% cpu (and obviously won't be running when you're gaming), and X taking up a fraction of a percent of cpu, refreshing the xterm that you're watching top in. You probably won't see KDE or Gnome or their related apps, or your window manager, taking up any CPU.

BTW - since your interface is totally image-based, perhaps pygame would be a good idea. It almost seems like overkill to use a gaming framework for what is basically an app launcher, but I don't know how well the standard toolkits support using images in such an extensive way, if at all. Pygame is super simple, here's a simple example of an image bouncing around a window. You could even add sounds and make things slide around and look all flashy and stuff. :p I imagine it acting basically like a flash thingie on a webpage, but.. you know, not on a webpage. ;)
 

tyanni

Senior member
Sep 11, 2001
608
0
76
enlightenment is bloated? If so, why can I run it very fast on a PII 366 with 64MB of ram? It may not be as clean as others, but bloated is a gross exaggeration.

Tim
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: tyanni
enlightenment is bloated? If so, why can I run it very fast on a PII 366 with 64MB of ram? It may not be as clean as others, but bloated is a gross exaggeration.

Tim

Bloat does not always directly correlate to CPU and memory utilization. Enlightenment is visually (although you can configure it not to be) and functionally bloated. But I'm not bashing it, that's what its users want.

If it's just a window manager, then yes, it is bloated beyond belief. If it is a desktop environment, then it's not bad at all. I'm not sure which one it claims to be.
 

Flatline

Golden Member
Jun 28, 2001
1,248
0
0
I guess it kind of straddles the line. That's probably why a lot of people who start using it end up in fluxbox or blackbox eventually.