Tuesday, November 17, 2009
Sunday, July 12, 2009
Hello World in PyQt
Lately I've been looking to python as a quick way to hammer out a qt application. I find it quite nice so I have concocted as small example with my comments. Perhaps this tutorial will help make it sink in for some people. If you have any suggestions or if there is anything you are unclear about or have questions about feel free to ask in the comments section.
I called it "HelloWorld.py", but I have added a few other non-"hello world" related pieces of code to show how they work in PyQt. So without further ado I give to you: "HelloWorld.py"
I called it "HelloWorld.py", but I have added a few other non-"hello world" related pieces of code to show how they work in PyQt. So without further ado I give to you: "HelloWorld.py"
#first we have to import all of out needed librariesI hope this helps someone. Now you can get started learning pyqt/pykde so you can contribute to Kubuntu or what ever your distro of choice may be. If there is enough interest I'll post another article on here using pyKDE libraries as well, but that shouldn't be too difficult.
import sys #this is used for system arguments
from PyQt4.QtCore import *
from PyQt4.QtGui import *
# I could have left out the from and just said import PyQt4
# The main benefit is that I now don't have to type PyQt4.QtGui.QWidget()
# So I feel it improves clarity, you'll want to find what works best for you.
#setting up the application, usually this isn't the structure you would use, however I don't want to get into python classes here.
app = QApplication(sys.argv)
#here I am declaring all the widgets I will need to use later
widget = QWidget()
helloButton = QPushButton("Say Hello World!")
textEdit = QTextEdit()
label = QLabel("Hide me!")
vBoxLayout = QVBoxLayout()
#in this section I am setting up the widget layout
widget.setLayout(vBoxLayout)
vBoxLayout.addWidget(helloButton)
vBoxLayout.addWidget(label)
vBoxLayout.addWidget(textEdit)
#this next line makes it so that when the "-" button is pressed at the start of a line a bulleted list begins
textEdit.setAutoFormatting(QTextEdit.AutoBulletList)
# here I am going declare a python native function, that we will connect to "helloButton"
def sayHelloConsole():
print "Hello World!!!" # this function has changed for latest python. It will become print("Hello World")
#Now I will connect the signals
QObject.connect(helloButton, SIGNAL("clicked()"), sayHelloConsole)
QObject.connect(helloButton, SIGNAL("clicked()"), label, SLOT("hide()"))
#the main differences there is when I had a Qt slot as opposed to a python function to connect to I had to put it in the form SLOT().
#Show the widget & start the application
widget.show()
sys.exit(app.exec_())
On the Topic of Meaningless Propaganda.

This is the image that seems to be circulating around on some blogs by people who are trying to say: "I don't have a problem with mono". Instead they chose a meaningless phrase, since no one is actually saying anything about people writing code they are saying people writing in C#/Mono. The main problem I have with this "campaign" is that it fails to address the issue. It's almost as if those who complain about mono are also complaining about other people who code. Which quite frankly isn't true.
If you've read my last post about mono you know I really don't care if people use mono. Now I feel I have gotten it all out of me and I will hopefully resume "meaningful" blogs, I apologize for the brief stint of information free blogs, but I did want to get my two cents in on this issue in particular.
Saturday, July 4, 2009
C#/Mono (to use or not to use)
Well, if I am late to this discussion it's because I've been away from computers for a little while (family illness and so on). I enter this discussion knowing full well it could start a firestorm which is why I will choose my words carefully, so without further ado I begin.
It doesn't matter. Let me clarify:
It doesn't matter. Let me clarify:
- No major open source desktop project that I know of uses mono by default. In fact both gnome and KDE stick to their "favorite" languages for one reason or another. Virtually all of gnome is C. All non-C based applications are not part of their default setup. I don't know of any major components of KDE that are not C++ or any applications despite plenty of amazing bindings for both environments. So all the warnings about becoming "too dependent" seem a little pre-mature. Esp. considering there has been no plan to switch to mono by any of the major DEs. Now sure, some distributions include mono by default but that's because distributions preferred the mono applications. Does that mean that Ubuntu as a distribution will fall apart if Microsoft decides to attack? No, they'll just replace tomboy with gNote and fspot with gthumb. Which takes me to my next point.
- Even if we had some really nice application in mono that far out classed all the non-mono counterparts, and "the hammer fell down" or what have you. The worst that would happen is that it would be ported to java/C++/C and within 6 months if it was that critical of an application. So all this fuss seems a bit pre-mature. The one area where this WOULD become an issue is if mono was used to make ALL of gnome or ALL of KDE. Mostly because running a VM all the time would be a terribly inefficient way to do things. Java and C# are fine for certain applications but not the whole desktop.
- I think having mono/C# is excellent for Linux in that it allows us to experiment/learn some of the latest .Net technology. I'd like to think that we run/work on Unix based environments for their technological merits and not because we (apparently) think Microsoft is the devil. I think C# is a pretty cool language. It's far from being my favorite language but it's still fairly interesting. I wouldn't use it on a KDE project for the same reasons I wouldn't use java, they require too much overhead.
- One final point, let's all keep in mind that Microsoft is a company that employees a whole lot of developers. Some of those developers work their because they need a pay check, but others are their doing things they are passionate about, just like we are here in KDE. Now obviously KDE is basically all volunteers so the level of passion on the whole is probably higher. What I'm trying to say is: Let's focus on the technology not on the "politics". If your going to reject a tool do so on technical merits. Let's face it, Microsoft, like all corporations, is about making money, so if they attack mono, it's because they think mono is sucking money away from them and I just don't see any of these mono applications as being really that threatening to Microsoft.
- Finally, has anyone actually asked Microsoft about this?
Friday, April 24, 2009
The Road to KDE Contribution
Defining KDE Contribution: work submitted to kde, for the benefit of kde. This can take the form of code, artwork, documentation, translations etc.
Calling it a "road to kde contribution" is really over-stating the matter. It's not so much a road as a sidewalk. For being such a large and complex project KDE has one of the lowest barriers for contributers I have ever seen. If you want to work on an open source project this really is the best place to start. The following is based on my experiences and observations thus far, in hopes that it may serve as a quick guide to those of you considering becoming a part of the kde project.
Step 1: Deciding where you want to contribute to kde:
Determining which opensource project to contribute to is an important matter. Think about it, you are committing time and effort into this project, so choose your investment wisely. You want to pick a project that you are passionate about and that you will use. That way you will be able to consider the application from both viewpoints, developer and user, and in effect help make it that much better.
That said, if you choose kde as your project you have at your disposal numerous applications that you could contribute to as well as quite a few backends. If this is your first time joining a large opensource project I would recommend doing what I did. Find a small application with a simpler codebase that way you can learn the ropes without getting burned. In my experience kjots was an excellent starting application. There are many others, just have a look through the kde.org site for more kde applications that you could help with. In general if it's a simple application, it will likely have a simple codebase (though exceptions probably exist). That said, it's more important to work on an application you enjoy using.
Step 2: Approaching the developers.
Once you have chosen your project it is now time to approach the developers of that project to ask them where your services would be most useful. My preference in this case is email, but email is only useful if the application is small and there is only really one main developer. If you have chosen a larger application then the relevant mailing list would be the place to start. You'll want to subscribe to the mailing list in any case.
This step is "optional" but if you intend to continue contribution on a long-term basis and your not just submitting a single patch then it's probably a good idea to introduce yourself to the people you'll be working with. My experience with this step has been very positive. You'll find that the kde developers/artists etc. are generally very kind and considerate. You'll also quickly learn that they know their stuff and thus working on kde provides you with a very good opportunity to learn from some of the best developers out there. Keep in mind these are people that are doing this because they enjoy it, so it's not just a matter of churning out code, a lot of thought and effort is put into each project. Thus passions will arise, and from that you'll see a lot of good work. (Please, understand that being passionate about something does not equal you being rude to everyone who has a different idea, argue your points respectfully. No one ever changed their opinion on something because someone called them blind or stupid).
This step is "optional" but if you intend to continue contribution on a long-term basis and your not just submitting a single patch then it's probably a good idea to introduce yourself to the people you'll be working with. My experience with this step has been very positive. You'll find that the kde developers/artists etc. are generally very kind and considerate. You'll also quickly learn that they know their stuff and thus working on kde provides you with a very good opportunity to learn from some of the best developers out there. Keep in mind these are people that are doing this because they enjoy it, so it's not just a matter of churning out code, a lot of thought and effort is put into each project. Thus passions will arise, and from that you'll see a lot of good work. (Please, understand that being passionate about something does not equal you being rude to everyone who has a different idea, argue your points respectfully. No one ever changed their opinion on something because someone called them blind or stupid).
Step 3: Miscellaneous Items
Some final items to note when starting your kde journey.
Well, I hope you found this helpful and enlightening. If you have any questions feel free to ask me, or ask on irc. If you need help finding something to do, the people on irc are very helpful for that. They helped me a lot in that regard.
- Just because your the greatest developer since RMS doesn't mean you won't make mistakes here or there. When you do, usually some one will likely try and correct you (based on my observations). It's best not to worry about your ego at this point and thank the person for their correction. It's not an ego thing, it's okay to make mistakes it's human (just as long as your not deliberately sabotaging things).
- Working on KDE is fun, don't let it get in the way of your life, or your job, or your schoolwork etc. People understand if you have to study for a test.
- If your going to be working on code, I highly recommend you spend some time reading the code at websvn.kde.org . This is an excellent way to improve your programming skills and to learn the kde framework. Also, you want to try to stick to the code-conventions of the applications your working on.
- One final note for developers: COMMENT YOUR CODE! I don't know what you were thinking at 3 a.m. four months ago. I don't know what I was thinking at 3 a.m. four nights ago! So if your doing something non-trivial please leave a quick comment explaining what this is. I don't mean that every time you declare a variable you should put in a comment stating that you are declaring a variable. But if you just added a function that involves a semi-complex algorithm let us know what that is for and what it does. This is especially useful when debugging or trying to learn new api etc.
Well, I hope you found this helpful and enlightening. If you have any questions feel free to ask me, or ask on irc. If you need help finding something to do, the people on irc are very helpful for that. They helped me a lot in that regard.
Tuesday, April 21, 2009
Thursday, April 16, 2009
Evaluate the Expression
/*below you can find references to why I'm writing this..sorta
http://www.forbes.com/2008/06/18/college-majors-lucrative-lead-cx_kb_0618majors_slide_2.html?thisSpeed=30000
http://www.bls.gov/oco/ocos267.htm
http://www.bls.gov/oco/ocos042.htm
//other important includes
#include < string >
using namespace std;
string main ()
{
string differences = blah.get_text_from_site( http://www.eng.buffalo.edu/compscie_vs_compeng.php );
if (computer_scientist == computer_software_engineer)
{
cout << "they are the same that article is lying";
}
else
{
cout << differences;
}
return your_thoughts_in_binary_please;
}
/* No, this won't compile....the reason being it's not really code. I just did it this way because it's a good way to express yourself. Try it, next time you write a letter to your close friend do it in lisp or MIPS and they will understand you more clearly and yes it's very late I am an insomniac. */
//comming soon: my "article" on the road to becoming a kde contriubutor/developer (things you should expect/do)
http://www.forbes.com/2008/06/18/college-majors-lucrative-lead-cx_kb_0618majors_slide_2.html?thisSpeed=30000
http://www.bls.gov/oco/ocos267.htm
http://www.bls.gov/oco/ocos042.htm
//other important includes
#include < string >
using namespace std;
string main ()
{
string differences = blah.get_text_from_site( http://www.eng.buffalo.edu/compscie_vs_compeng.php );
if (computer_scientist == computer_software_engineer)
{
cout << "they are the same that article is lying";
}
else
{
cout << differences;
}
return your_thoughts_in_binary_please;
}
/* No, this won't compile....the reason being it's not really code. I just did it this way because it's a good way to express yourself. Try it, next time you write a letter to your close friend do it in lisp or MIPS and they will understand you more clearly and yes it's very late I am an insomniac. */
//comming soon: my "article" on the road to becoming a kde contriubutor/developer (things you should expect/do)
Subscribe to:
Posts (Atom)