![]() |
Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
Hi
I am a semi senior php programmer. I am trying to learn how to create GUI based apps for the N900. There is a lot of information, I can not find any clear step by step tutorial. Can someone please explain in a few words what are these "things" ? Python = OO programming language Cairo = Graphic library PyCairo = Is a "layer" between Cairo and Python? When should I use it? GTK = Do I need it if I use cairo? I should use it instead? It is other thing and I need both? PyGtk = same as PyCairo? Any guidance is welcome |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
If you're especially looking to develop for Maemo on the N900 (and maybe some day for MeeGo), go for PyQt instead.
Qt is the GUI library (though that term might be misleading, since Qt does a lot more than just handle the GUI part of your applications) that will be best supported on both OS, so you might want to look into that one instead of other GUI solutions. Qt is natively C++, but there's the aforementioned PyQt bindings that combine the strengths of Qt and the comfort of Python. Python - despite the obvious syntax differences - should feel pretty natural for a PHP coder, so I'd say the Python + PyQt combination should suit your needs pretty well. (Quick sidenote: Python + PyQt has some well-made classes for accessing websites, complete with full auth and cookies - so server-client based applications with a PHP server in the background are quite easy to make.) There's not much work involved with getting your workspace up and running, either. If you're on Linux, must grab the Eric Python IDE and you'll have everything you need right at your fingertips, since it already includes god-sent tools like Qt Designer and Qt Linguist. For a short intro to Python + PyQt, here's a nice little starter tutorial made by mikec. I'm totally new to the mobile app development stage myself, but if there's anything you want to know I'll try to help. Oh, and welcome to the Maemo development world... ;) |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
First of all, thank you very much for your detailed response.
I must confes that I have been reading about Qt and GTK and I have decided for GTK, canīt remember why right know because I did it a few month ago. But if Qt is the best option for Maemo and MeeGo, may be I should start with Qt. I have downloaded the "roadrunner" app, which uses cairo and gtk and managed to add some features, I think I will have to recode the whole app, which will be go practice for me. Iīll be back! Thanks |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
One more thing:
What if I decide to develop for other phone OSs like Android for example? Will I better with Qt, GTK, neither or both? |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
Hm, good question. I think Android has more emphasis on Java altogether, though. Never had an Android device, so I can't even tell how hard/easy/impossible it would be to simply port the necessary libraries over to Android.
|
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
Ok, I have everything up and running.
My fisrt Qt app worked like charm. But I donīt know why, because this: def __init__(self, parent=None): #build parent user interface QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = MyForm() myapp.show() sys.exit(app.exec_()) Is completely new and there is no explanation on the tutorial: http://talk.maemo.org/showpost.php?p...8&postcount=59 Any link or guidance? Thanks! |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
I'll try to go over that coding and explain what each line does (though, remember, I only started two weeks ago, too - so I might have gotten some of that wrong :D).
Code:
class MyForm(QtGui.QMainWindow): All of the GUI elements are created by simply subclassing one of the Qt classes. All the events will be put in here later. Code:
def __init__(self, parent=None): Code:
#build parent user interface Code:
self.ui = Ui_MainWindow() Code:
self.ui.setupUi(self) That's actually the end of the class definition (you - and the interpreter - can tell by taking a look at the indentation). So everything after this is "floating" code, not part of any function or class. Code:
if __name__ == "__main__": Code:
myapp = MyForm() Code:
myapp.show() Code:
sys.exit(app.exec_()) |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
Thank you very much. Excelent explanation! Where have you learn all this? I want to read it too! :D
|
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
Always glad to be of help... ;)
Err... well... uhm... I have to admit, most of it I got by trial&error and analysing code snippets I found on Google. :D (Also, I have found that some of my Java knowledge comes in handy from time to time, too.) Haven't found any real starter tutorials other than the one linked above, but I spend a good deal of time skimming through the PyQt class reference to get a feeling of what classes are there and which ones might be of use to me. It's not complete yet, and quite a lot of methods are more or less undocumented, but it's still a great source of information. Other than that - like I said, I just more or less camp Google whenever I hit a wall with trial&error. Python and PyQt are pretty popular by now, so chances are every question you have has already been ask in one or more forums/mailing list. |
Re: Cairo, Pythom, PyCairo, GTK, PyGtk, ahhhhhhh
Here is a nice explanation: http://zetcode.com/tutorials/pyqt4/firstprograms/
|
All times are GMT. The time now is 21:15. |
vBulletin® Version 3.8.8