Where to start to learn how to build Linux GUI apps based on scripts? - linux

First off, I'm looking to write GUI apps based on an interpreted language (PHP if possible--otherwise, Python). Second, I'm looking for a rapid-app GUI designer that lets me create windows, drop UI elements on it, and wire those elements up to code easily. Finally, it would be nice to have a simple way to package the whole thing up (deb, rpm, etc). Ideally my application should work on any Linux platform, and in Gnome or KDE.
I'm wondering if Glade is the way to go? And do I install just "glade" (via APT) or "glade-gnome"? (I'm on Linux Mint 10)
Bonus question: it would be cool to be able to have code that I could very easily just port over to Windows & Mac OS and work as well (UI and all). Of course, I'm thinking Python is probably the way to go as the underlying language.. if I recall correctly, Python has some way to build UIs that work on any platform? I could be wrong.
EDIT: Again, I have to say.. it is important to be able to have an interface designer of sorts. I absolutely do not want to code windows, buttons, input boxes, etc., by hand.

I'd really suggest you have a look at Qt. You have Python GPL (PyQt) bindings available or the (newer) LGPL Pyside bindings readily available:
A mature, stable, well documented and extremely rich framework
Comes with a GUI Designer for easy drag and drop UI design
Cross platform for free (Windows, Linux, Mac)

Look at PyGTK, wxPython

Related

Lowest common denominator GUI library on unix/Xserver

I want to code a primitive, DE independant application. Hence I want to be independant of Qt and GTK. What is the next lower library below Qt/GTK. I mean what is the lowest common denominator that is used by either of them and is available on every graphical linux system.
The X11/Xorg server is used by both Qt, GTK, and pretty much every GUI toolkit out there (FLTK, etc...), so it is the "lowest common denominator" you're talking about. You can use it directly with the XCB or Xlib library.
There is no such common library.
If you are writing a desktop app (i.e something you expect the user to interact with through their usual windowing system) my advice would be to use either QT or GTK - choice is yours.
There are some other reportedly simplier 'lightweight' libraries you can use such as EFL (Enlightenment) and TK (i.e. Old school tcl/tk apps haven't seen one of these for years). Or you could even use something more exotic like Motif (for that cutting edge mid 90's unix workstation CDE look and feel) - I hear that is open source now (finally).
For a full screen app like a game I believe you can use SDL or maybe ever write out directly to Linux's frame buffer device - I can't really offer anything here I have no experience.
There is no gurantee any of these libraries will be available on any given Linux installation. Thankfully package management exists to take care of this for you. Write the app publish the source and the make files. If people find it useful and want it in their distribution someone will package it for you.
If you are making a closed source binary you are left with static linking.

python3 tkinter or ncurses

I want to impliment some kind of UI for my Python programs (some simple operations, nothing advanced).
So I looked around and considered ncurses and tkinter for python. Yet I am not sure which of these two would suit best my needs for a simple interface (in the sense of easy to learn to program) with the best output possibilies. It does not have to be fancy or anything, just help me visualise my code (lets say a text based chess game).
intuitively i would take tkinter, but could you probably just summarise for me the advantages of the two UIs? (in addition ncurses does not seem to have a good tutorial for python...)
Thank you in advance!
I would like to suggest tkinter as it comes with python and compare to other GUI packages it has good tutorials. And also it will help you to improve your OOP concept for python
If you plan on using your application across platforms, Tkinter or PyQt are both good choices. If you want a GTK+ application that matches your GNOME environment and don't plan on using the application on other platforms, then I would suggest using GTK+ via gobject-introspection (from pygobject). In Fedora, you should have support for it out of the box. Other distributions may require the installation of additional packages.
For more information on the above bindings, see:
TkDocs
The Python GTK+ 3 Tutorial
(Sorry I couldn't post a link for PyQt because I don't have enough reputation to post more than 2 links.)
Additionally, it's worth noting that both PyQt and GTK+ have interface designers available so that you don't have to create your interfaces programmatically if you don't want to. For PyQt I believe Qt Creator comes with an interface designer. For GTK+ you have Glade.

What language is easiest to develop command line/simple GUI for Linux?

I need to develop a large set of tools to be run from the server command line (i.e. not client-server architecture). The systems does not have to be high-performance; I just want something that is easy to develop with.
Which technologies are out there I can use to build simple GUI to be run from the command line? I need only menus where I can select a line/check-box/enter free text in a dialog.
Edit: forgot to add, access to Mysql (i.e. drivers available) is essential.
Shell, with dialog, the old stand-by - http://www.linuxjournal.com/article/2807
EDIT- If it's MySQL-related, take a look at PERL-Tk and DBI.
python + ncurses would be a good combo here.
i like using perl's re.pl from the Devel::REPL library for quickie cli interfaces. read on a bit for my rationale before downvoting!
in this type of app it sounds like you will be doing query-type operations. these naturally lend themselves to a "repl" style interraction. re.pl gives you all of the goodies, namely command editing and history. all you need to write are the functions that users will call. the nice thing is that users who know perl will realize they can use any installed module to extend the functionality of your system on their own. i my case, i used re.pl to create a mysqlclient-like tool to access and display data that was being compressed in a way that the standard mysqlclient couldn't deal with.
i cite perl because it's DBI is the best database abstraction and it is what i have used....but the rationale can be extended to other tools. python's repl or any other would provide the same benefit.
You could use Mono for Linux and write your program in C# .NET, then make it work for Linux, since Mono allows so.
As far as graphic command line interfaces go, one of the best frameworks is ncurses. It abstracts away most of the ugliness associated with graphic command line applications.
I have to say, use Python, because I like it.
But text-based interfaces are pretty much not worth it, because they seem like a good idea until you look at the details:
There isn't really a standard keyboard navigation model for text-UIs; they all use their own scheme
How is unicode supported? (Hint: this is nontrivial)
What about different keyboard layouts? What key does someone press if their keyboard doesn't have, say, a "home", "end", or "Escape" ?
ncurses does not provide a widget set, only low-level operations. The answers to the above questions aren't easy.
It really shows that nobody has put much thought into keyboard-and-text-driven terminal-based UIs recently, or these would all have been solved.
Web interfaces have them solved, in fact, you can use a text-mode web browser if you like.
Modern devices like i(phone|pad)s and even cheap mobile phones have a web browser which is good enough.
It is easy to write a web application which uses a very simple style (few images, little Javascrfipt) and have it work without much effort on a variety of devices.
So I would say go with dmckee's comment "go with what you know".
By building your own terminal-based interface, you are going to box yourself into a corner in the long term.

How is scrolling supported in Linux graphical environments like GNOME and KDE?

I'm curious to know: is scrolling (such as in Firefox, Nautilus, etc.) handled be each application separately? Or is it done by the environment? Or by the widget toolkit?
What confuses me, is that it is possible to change to "smooth scrolling" in Firefox, which makes it seem like each application handles its scrolling separately. However, when writing software for Linux, you don't really need to specify and it seems like GTK takes care of it on its own.
The reason I'm curious is because I wanted to know if Linux could have it's own "accelerated" scrolling, much like OS X. I know this is possible by app, because Google Picasa has its own built in.
To make this possible for the entire system, does GTK need to be modified? Or something else?
Most applications rely on their toolkit for scrolling behaviors.
Firefox does a lot of stuff by itself, partly because it runs on various platforms with various toolkits (not just GTK), and partly because it has advanced needs that aren't always met by whatever toolkit it happens to be using.
GTK is far from the only toolkit used on Linux. There is also Qt (which is used in KDE), wxWidgets, Tk, FLTK, Motif clones, Xt, and you can even build applications on Xlib itself without a toolkit.
You're using two different terms, "smooth scrolling" and "accelerated scrolling". These are not the same thing, and the latter is technically ambiguous.
There is absolutely nothing preventing Linux (really X) applications from having any particular scrolling behavior. It's up to the application and/or its toolkit, if it relies on one.
Regardless of the above, keep in mind that not everyone agrees that the scrolling behaviors you allude to are good.

Linux programming - getting started, how?

I've taken the plunge and installed Linux (Linux Mint 9 if that's important) on one of the boxes - and I'd like to start some small-time programming... but where to start.
My background:
Mostly LOB-applications in C#/WPF
Some XAL-basic
A wee bit of VB/VBA and SilverLight
I would like to turn to a new programming language - but still focused on desktop applications.
What I need:
An editor - preferably with good intellisense
A programming languages and the resources to get started
If anyone can point me in the right direction, I'd be happy for a little push...
EDIT:
Thanks for all the advice - I've come up with the following:
I'll start out with Python - and use Vim for the editor
I'll definetly try out Vala and Perl later and have MonoDevelop as backup editor - and if all else fails, I'll turn to C++. I've upvoted all answers as they all helped me.
EDIT2:
Okay - Vim was a bit too hardcore... Installed Cream on top.
Unlike the Windows world, where everything is designed to be Windows-only, I think it is quite typical to find that the rest of the world designs software to specifications, not to implementations. If you are developing in Java, then it doesn't matter what platform you intend to use, and Eclipse and NetBeans provide excellent tooling for Java on all platforms, Linux included. If you are developing in C++, then Boost and Qt provide excellent cross-platform support. If you need to go outside of Boost or Qt, then before delving into Linux-specific features, it is best to target the Single UNIX Specification also known as IEEE Std. 1003.1 POSIX, which will ensure that your application not only runs on Linux, but also on any UNIX-compliant operating system (including Mac OS X, FreeBSD, Solaris, and others).
As for IDEs and other editors... I think most programmers on UNIX platforms build from the commandline (using CMake, Make, scons, or some other standard build tool); however, there are plenty of IDEs with support for those that can run such tools automatically. Anjuta C++ and KDevelop are probably the easiest IDEs to use on Linux. Emacs (emacs, emacs-gtk, xemacs) and Vim (vim, gvim) provide a great deal of power and flexibility, but take a little bit more time to get used to. You might also want to consider a basic text editor such as GEdit (Gnome) or Kate (KDE); GEdit, though billed as a simple text editor, supports some more advanced coding features via a number of plugins. I don't recall whether it supports autocompletion, but it does support line numbers, automatic indenting, using spaces instead of tabs, commenting a block of code en-masse, and executing a Makefile with a shortcut.
Depends on how much you want to learn (from the easiest option to the hardest one):
Just use C# via Mono - that gives you access to most of the POSIX interfaces via Mono.UNIX, access to GTK# so you can do desktop apps, access to many linux libraries, so you can do more advanced stuff / integrate better. (you can program in Monodevelop - it's a Sharpdevelop clone, kind of VS-ish)
Learn Vala - it's a language compiled down to C, very similar to C# but closer to the bare minimum. It's gathers anti-MS people who wanted a response to C# IMHO. (never really used it, but apparently there's a Vala plugin for Monodevelop and the language itself is becoming more popular)
Learn Python - it's a scripting language. It's got bindings to most popular libraries (also GTK and QT) (IDE: anything that can edit text - you won't get good intellisense from a dynamic language anyways)
Learn C++ and QT, or C and GTK - although those are very low level languages where you will spend a lot of time just getting used to the environment. (IDE: Anjuta, Kdevelop, Monodevelop with C++ plugin, Eclipse+CDT, emacs, vim, etc. - anything goes really)
If you want "something new", but don't want to spend loads of time learning a completely new environment, I'd recommend trying out Vala. If you're more curious about different styles, go for Python, which I think has a very good tutorial for new people (but not new to programming): Tutorial or Beginner's Guide. With Python you also have an advantage of having the whole environment available in packages in any distribution, no such luck with Vala (yet).
Try perl and python and see what appeals to you. Learn bash to get around happily at the command-line. If you're feeling adventurous, give C/C++ a shot.
As for editors, this will probably spark up a holy war, but if you're using at the command line, check out vim and emacs, pick one, and lament never making friends of those in the "enemy camp." :-)
I say Python + Emacs or gEdit (what ever suits you)
Linux Mint is a KDE environment, right? That would make it pretty convenient for you to get started writing KDE apps in C++. The Qt toolkit which KDE is based on is widely considered to be relatively developer-friendly, which should make it easy for you to get started.
If you want to go on that route, I'd suggest downloading KDevelop, which is KDE's IDE (optimized for developing KDE programs, but it can handle several different languages). Alternatively, you could use Eclipse, which has C++ capability. You can find tutorials on how to develop KDE apps at http://techbase.kde.org/Development/Tutorials. (Unfortunately I think those are not as good as the documentation they used to have before KDE 4 came out, but it should be enough to get you started.)
EDIT: Come to think of it, you may want to try your hand at writing some C++ console (non-GUI) applications first, since it's probably easier to get comfortable with basic C++ before you jump into GUI programming. Given your experience, it shouldn't be too hard to pick up. Unfortunately I don't know of any particularly good resources to learn C++ with, but I'm sure that information is somewhere on this site, and KDevelop or Eclipse would work fine as an IDE for simple C++ console apps as well.
Weird that nobody suggested ALP, even if it is a bit outdated, it teached me a lot of things regarding the UNIX way of programming.
First, Learning C is a MUST!
Perl is underused for most stuff and you'll want to learn BASH Shell Scripting instead.
Grock the C code of existing (stable, well-written software) example is the Linux kernel itself! Google "Linux LXR"
Once you learn the basics to C (in Linux) the manpages are an invaluable resource. Just do man printf for information on writing characters to the screen, for example.
If you are talking GRAPHICAL GUI Programs, you need to learn GTK+ or one of the many cross-platform GUI toolkits (e.g. wxWidgets). Do not learn to program the X Windows System directly unless you are crazy.
For text editors, I like Komodo Edit and SciTE.

Resources