This tutorial will show you how to create custom widgets using PyQt.“Everyone who has programmed applications knows that sometimes you create a gadget that can be reused in other situations, and that code reuse is good.
In the specific case of GUI applications, often what you would want to reuse is a widget.
For example, you took one of the toolkit’s widgets and extended its functionality in a way you think has wide application, and you intend to reuse it on future work.
So, what we will try to do is figure out how we can create easy-to-reuse custom widgets using PyQt.
Our example custom widget will be a RestructuredText editor. Why? Because I need one!”
Read the tutorial at PYCS.
On other Python news, Amiga.org reports that AmigaPython 2.3.3 alpha 2 is released.
The more I use Python, the more I like it. What a fantastic language. If the OSS community really wanted get over the “script” prejudice and go for it, Python could be developed to be the next-generation platform OSS needs, and we wouldn’t have to depend on MS (.net/mono) or Sun.
Sorry to comment offtopically like this, but could you please put the link in the intro text (in general0 so I don’t have to open the article? ‘Twould be appreciated.
About the formatting: I believe there is a reason it is done that way now.
And about PyQT itself: installing PyQT packages for FreeBSD 5.1 on 5.2.1 didn’t really work, but I really want to try it out once portsupgrade is finished. And rod: what you said is what I also thought – even though I have never written one line of Python code, I can only say it looks great.
try ruby, it’s even better. similar syntax, more features, less retardedness like tab-requirements and lack of boolean, switch, blocks, lambdas, and more.
Tab requirements are a feature, not a bug Anyway, Python has a boolean type, and has the equivilent of blocks and lambdas through generators and lambdas.
But does ruby have QT and KDE bindings? Python has them, and judging from freebsd ports, Python has qt+kde+gtk+gnome, Ruby only gtk.
Now, I’m actually totally new to both Python and Linux GUI programming – is it easy to develop little GUI apps using PyQT?
check out http://raa.ruby-lang.org/
the qt bindings are not as mature as gtk bindings, no. but qt is a worse toolkit than gtk so the point is moot to me. it has fantastic ruby-gnome bindings, for everything including gtk, gconf, and all the various gnome libs.
and rayiner. ruby has had these from the beginning, not a poor afterthought. plus i’d argue that ruby’s implementations of them is better. tab requirements is stupid. it’s a sign of a poor language design. you have block beginning and ending delimeters. there’s a good reason every language before python has them in some shape or form. they aren’t just redundant characters, they DO increase readability. seeing something like this shows a good example of why:
def function:
// code
// inline code
is not nearly as intuitive as
def function:
// code
end
// inline code
not only all that, but python’s not a pure OO langauge like ruby. how do you convert negative number with abs? -1.abs how do you convert a number to a string? 1.to_s. etc. does python even have the ability to reopen classes like ruby does? does it even have multiple inheritance like ruby? what about operator overloading. ugh. i hate python
ruby has had these from the beginning, not a poor afterthought.
That’s not a proper argument, just an assertion.
tab requirements is stupid. it’s a sign of a poor language design.
http://www.nizkor.org/features/fallacies/begging-the-question.html
you have block beginning and ending delimeters. there’s a good reason every language before python has them in some shape or form.
http://www.nizkor.org/features/fallacies/appeal-to-common-practice….
seeing something like this shows a good example of why:
I don’t see it. I use indentation to distinguish blocks, even in C++, Lisp, and Dylan.
not only all that, but python’s not a pure OO langauge like ruby. how do you convert negative number with abs? -1.abs how do you convert a number to a string?
Everything in Python is an object. That is the definition of pure OO. -1.abs vs abs(-1) is a purely synactical difference. -1 in Python is an object just like everything else. There are lots of pure OO languages that don’t use the ‘.’ syntax at all. Everything is accessed via a generic method. Does that make them any less pure OO?
does python even have the ability to reopen classes like ruby does?
No, but you can dynamically add methods and fields to objects.
does it even have multiple inheritance like ruby?
Yes.
what about operator overloading.
Yes.
i give up. whatever. you will never listen rayiner
What zealotry? Its not a matter of me not listening. Its a matter of you making fallacious arguments, and then asking rhetorical questions that don’t support your point. There might be many reasons why Ruby is better than Python, but:
You haven’t provided a actual argument about the tab issue;
You seem to misunderstand what being OO really means;
All the non-syntax-suger Ruby features you pointed out are in Python too.
Omnivector either you don’t know Python at all or got this “checklist” from a very old source, because 90% of the “points against Python” you mentioned are wrong.
The only one showing any kind of zealotry here is you with the “I hate Python” thing, Rayiner just answered the questions you did! (when one writes “does it even have multiple inheritance like ruby?” it means they expect an answer, right? too bad the answer was not the one you expected!)
Just get over this kind of silly discussion. Both Ruby and Python are great, just pick your favorite one (or, even better, learn both) and be happy.
I personally find PyQt to be a very productive environment, especially when used together with Designer and pyuic (which creates Python code from Designer forms). PyQt fits in excellently with the nice OO features of Python and provide for a fine combination without any big surprises. If you know the C++ Qt and Python using PyQt is a matter of looking at a tutorial for a few minutes and you are up to speed.
I also consider PyQt very useful as a learning tool: if someone is new to GUI programming, I would recommend to learn Python/PyQT first, and once you’re comfortable with it, “upgrade” to C++ (if necessary – you may as well discover that Python/PyQt is good enough and just stick to it)
in my quest to find a good scripting language replacement for perl i tried out python first, hearing great things. i was impressed as i had come from a mostly perl background. i tried ruby too since one of my friends said it was a nice language and compared to the little bit of python i was simply blown away. say what you will about python, but if i couldn’t figure out all those things i listed then they don’t document them properly, or they don’t have any good tutorials available online.
and rayiner. give me on ADVANTAGE to requiring me to tab things using tabs over spaces, etc, and why this is a better system than begin/end blocks. posting links to definitions is just a way of being an asshole so how about giving me real sentence-based proof. god i wish this forum had ignore functions for people like you.
It´s simple. Requiring proper indentation is an advantage, because it makes the code´s look reflect its function.
Call it WYSIWYG coding.
tried ruby too since one of my friends said it was a nice language and compared to the little bit of python i was simply blown away
….so?
What I can’t understand why you have to think in terms of “Ruby VERSUS Python”. Just choose what’s better for you and get on with your life!! Remember, “free software” is about _free choice_, so just choose whatever is best for you and chill.
That’s my last post for you, I feel I’m wasting my time already.
Too bad the latest PyKDE version can’t be used with the newest PyQT version…
And then I have a license question: can you place software which uses PyQt under another free license than GPL? QT’s QPL allows this, but does PyQt too?
Afaik, the newest versions of PyKDE and PyQt work together. If not, then PyKDE CVS works with the newest version of PyQt.
I’ve used Python for various projects for about a year now, and I wish I could just use it for everything. I started out writing a little PyGTK text editor, just to understand GUI application design and learn python at the same time. 6 months later, I started learning Qt and a week after that began (yet another) project; a slackware package manager; You just pick up things so easily, its really just delightful to use.
Its not that I think any clearer or I put down more lines faster, its just that the language seems to be catered to the way a programmer (or maybe just this one) thinks. Objects, Inheritance, Overloading; these things never quite made sense in other languages, partly because the internals were too quirky to hide effectively, and party because using them fluently required muscling through awkward and heavily punctuated syntax. Python seems to get it right 95% of the time, with very few things that I want to do seeming harder than they should be.
But I think the best thing about Python is the way it so fluidly maps over the various graphical toolkits; mostly because of its sane object model. You get your choice of 4 toolkits, each one with its pluses and minuses; and you have 2 extremely excellent RAD environments in PyGTK and PyQt. Most of the functionality of your programs will merely be inheriting or overloading classes (not sure if thats the right term) for the toolkit objects and then getting right to the signal handlers; Pyuic and Libglade handle setting up your interface by parsing UI files created in Qt Designer and Glade, respectively.
From what I hear, Ruby is similar in the comments made for it to Python. For now, I’ll stick to python because its finaly growing the binding support that I’d want for any application I develop (for instance: I know anyone running fedora/redhat will have PyGTK, and as PyQt progresses it too should become a standard binding set with KDE).
ut does ruby have QT and KDE bindings? Python has them, and judging from freebsd ports, Python has qt+kde+gtk+gnome, Ruby only gtk.
KDE release 3.2 has ruby bindings in the kdebindings module, called qtruby and korundum. There is also a korundum site on RubyForge.
For more info see here:
http://developer.kde.org/language-bindings/ruby/index.html
Omnivector wrote:
check out http://raa.ruby-lang.org/
the qt bindings are not as mature as gtk bindings, no. but qt is a worse toolkit than gtk so the point is moot to me. it has fantastic ruby-gnome bindings, for everything including gtk, gconf, and all the various gnome libs.
I not sure what mature means in the context of the QtRuby/Korudum bindings as they use the language independent SMOKE library (based on dynamic message passing OOP). The library is autogenerated as part of the kdebindings configure, and it’s been used by the PerlQt bindings for over a year.
The Qt/KDE korundum ruby apis are probably the largest most complex libraries ever wrapped in ruby, it has over 950 classes and 29000 methods available in the Smoke runtime.
— Richard