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"

#first we have to import all of out needed libraries
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_())
I 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.

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:
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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).


Step 3: Miscellaneous Items

Some final items to note when starting your kde journey.
  1. 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).
  2. 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.
  3. 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.
  4. 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)

Monday, April 13, 2009

Developer's Ethical Responsibilities

What responsibilities do developers have to the consumers of their software. That is a question I have been pondering lately. I'll use myspace as an example. This is a "social networking site" where people put up lots of information about themselves that is then basically available to anyone who happens to stumble upon it (Ok so the developers put an option for private accounts but still). This website has been in a bit of controversy in the past over the way that some of their users where using it to "abuse" other users. On the one hand, the site in so far as we know, was designed to allow people to connect with each other. However at this point it's original intent is being subverterd and it's now potentially posing a risk for it's users.

Well what does that have to do with developers? Well obviously they had to build the site and it was they who made it possible for example for you to search for other people using advanced searching criteria. Without the developers there is no website. On the other hand it is the users who put up all that information about themselves and allow others to view and comment on it.

So what my question really boils down to is this, do developers have the responsibility to consider the possible malevolent uses of their projects? Or is something like myspace really just a tool and misuse of it is really the fault of the users and not the developers. Furthermore, as members of a community, if the developers realize that this misuse is taking place what is their responsibility to the community with regards to their handiwork. This is probably a more "innocent" example but it still holds. This is really just something I like to think about as I think it poses an interesting dileema and ofcourse we can explore other types of software not just social networking, the latter is just an easy target.

I don't really know what the correct "answer" is or if there can even be one but I'd be interested in hearing people's opinions on this. I think this is an important question going forward with KDE as the desktop is seemingly becoming more and more intertwined with the internet. Thus it seems looking at these kinds of "ethics" questions is a sensible thing to do.


In other news, finals are comming, after which I will have more time; so I plan to go back to the orignial intent of this blog, which is to follow my "journey" into kde contribution. I'll try to keep this blog more "code" based as opposed to random musings such as these since I find those blogs more interesting to read anyways. I've been really interested in C# support in qt/kde so I may have a look at that in my next post.

Building KDE Svn

I am thinking of going ahead and switching to kde svn . Up till now I've only compiled the parts that I felt I needed. So I'm a bit "green" in this aspect.

My option now seem to be:
1. switch to a distro that has kde-svn packages.
2. Build it myself.

1. Pros: I don't have to recompile all the time etc.
Cons: For a lot of those distros I would be forced to use svn as my default which would not always be ideal this early on.


2. The pros and cons are just the inverse of the first option.


My preference right now is option 2 as it is less limiting. However I worry about compile times.
How long does it take you to compile a basic kde svn setup?

Right now I have a 2gb ram Core2Duo 1.66ghz anyone with a similar setup?

Any advice? Anyone know a good distro that might circumvent all this?

Tuesday, April 7, 2009

Temporary-Post-Used-For-Style-Detection-Title-225966169

Temporary-Post-Used-For-Style-Detection-Content-225966169

=-=-=-=-=
Powered by Bilbo Blogger

Sunday, April 5, 2009

Crazy Drivers

I remember four years ago, getting a wireless card to work took an act of congress. So bad an experience was it for me to get my drivers to work, that when I set out to buy my laptop I took drivers into account. I even opted for an Intel video card as opposed to the more powerful nvidia one due to the available OSS drivers (all but demolishing my gaming experience). I did a pretty good job with my selection and all but one thing worked out of box on nearly every distribution, my wireless card. Yep, I totally overlooked that it was a broadcom card, thinking all I needed was firmware. So why is it then that 2 years later my wireless driver keeps dropping the connection on jaunty? My windows partition does not have this problem at all (errm... which I keep for the sole purpose of testing kde on windows of course!).

Speaking of crazy drivers, the other day some fool with a car started turning INTO me. Yes, as in we are driving side by side, and they had no room in front of them to pass me, so they started turning INTO me. It took me 3 seconds of pure shock before I slowed down, let them pass and began furiously pressing the horn. By that time half of his car was in my lane.

So people, fix your driving. Broadcom, fix your drivers to WORK PROPERLY on Linux, because you see like that foolish driver almost turned my car into a paper weight, your drivers are turning your product into a paper weight. All that effort planing and designing your chipsets and all of it is WORTHLESS if it doesn't hold a connection. How about, if I worked at the power station near your factories, and told you that if you didn't use production models designed by my friends, I couldn't guarantee full support. Then when you used your own models because presumably you found them better. I decided that I would cut your power ever 45 minutes, for 1 minute. Then when you complained about me hurting your productivity and ruining your products I told you just where I thought you should put your "ruined product". Of course you could then move your factory, but it would cost you quite a bit wouldn't it? See my point?

Having said that, does anyone know of a cheap wireless card for a laptop, that would "just work" and work well on Linux? I have a dell inspiron 640m (same as e1405).

Monday, March 30, 2009

While looking for a major I found a potential bug

Yes, I am looking for a college major. Right now I'm pre-pharmacy. I have applied, and now what I am going to study next year hangs in the balance. Since I hate leaving things up to chance (even though it's been proven that regardless of how much I plan, things happen a certain way in-spite of my best efforts). So I am choosing a major besides pre-pharmacy. I said all that to say, if you have any idea of an interesting College majors that also would help me get a job please offer the information.

Yes, I know, a shameless attempt to get non-kde adivce on a kde related blog, but here is what I am "actually" blogging to discuss.

Everyone type the following in your konsole while in an empty directory.

svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs/kdeui/tests/krichtexteditor/
Now enter the directory krichtexteditor and type

mkdir build
cd build/
cmake ../
make
Now run that application

./krichtexteditor

Now use that to open a file with bullets or an ordered list (and this may even work with any rich test at all). In fact I have added below a list you can copy in there. Make sure there are misspelled words in the document.

  • adadad
  • asd
  • adsdfas
  • adsfdaf
  • adaafa
Now that you have your document with misspelled words and a list of some sort. It's time for the exciting part! Right click to get the context menu and Click Check Spelling.

When the spell check dialog comes up click cancel. If all worked as it did for me, you should now notice that the bulleted list has been removed. YAY! Actually this seems to be an issue in other things I've used with this as well. I haven't checked around into this, but I just wanted to make sure that I wasn't hallucinating.

UPDATE:
Sadly, I wasn't hallucinating, and so here is the bug report. For those of you who have encountered this issue, you can follow it there. I'm going to try and see later this week if I can do something about this.

UPDATE2:
I forgot to post the bug report link.
https://bugs.kde.org/show_bug.cgi?id=188523

Friday, March 20, 2009

Hello KDE

Well, this isn't exactly, my first post, it's my third. The two before this adequately explain what I set out to do when I made the decision to contribute to kde. This is more background, nontechnical information.

Since I started using Linux with Fedora Core 4 & Ubuntu Breezy, I have been looking for a way to contribute. Since then I embarked on a mission to explore numerous distros, to get the feel for not only the software but the communities as well. My goal was to find a place I felt I could really contribute. However I didn't really settle anywhere and all I got out if it is a really bad habit of distro hopping. (Though I mostly stick to Fedora, Ubuntu/Debian, and Arch). Then I started looking into KDE 4 (at the time I was a gnome user). I watched the keynote speech on KDE4's frameworks and advancements, and I was hooked, because I truly saw potential in these new software frameworks. It was well integrated, and it was well thought out. On top of all that the DE looked slick and professional. Between Qt and KDE libs I saw endless possibilities. So I switched DE's and began looking for ways to contribute. I outlined some of those in earlier posts but I'll put a quick run through here. (DISCLAIMER: the above wasn't a jab at gnome, I still thinks it's a nice DE and keep track of it, I just prefer kde over gnome).

1. Development: I want to help with actual coding. Though I am new to KDE, Qt, and C++, so I hope those of you out there will help make my a better programmer. To some extent I have already embarked on this mission. Recently I submitted a patch to Stephen Kelly (who has been a great help) that added and auto decimal list feature to Kjots. It was my first code contribution to a FOSS project and I am still very proud of it, and I hope those of you out there will test it in svn.

2. Documentation: I am very big on this. I know it can be tedious even hard to write good documentation, but with all the new frameworks (not to mention improved language support) with kde 4 I think we can do better on the documentation end. I really hope to get started on this end sometime soon. (For those of you who are part of the "inner circle" for developer documentation in kde, please let me know where much of the discussion takes place etc.

3. Any other way I can really (with time considerations of course).

One thing I have to say is that KDE's community is one of the most friendly open minded communities I've seen in FOSS. If you are considering helping out with kde, there are tons of different ways to do so, whether it be code, art work, documentation or anything else you can think of. If you would like to ask any question regarding this, please feel free to ask me I'd be more than happy to help.

I look forward to working with all of you in the future. Here's to happy KDE 4.3 release.

Saturday, January 17, 2009

Plasma and what it means for the future:

This originally started as a post about bindings documentation but I decided to instead focus on plasma. You see by making plasma applets such a major part of the kde4 ecosystem the kde developers were in a way providing for a method for programmers of almost any level to get involved. This is further enhance by the bindings to other languages. See, not everyone likes C++ or even knows it well enough to make a decent application with it. But there is a host of people with javascript knowledge. In fact this inclusion of javascript support not only lowers barriers to involvement but it also enables us a lot of web2.0 features/ideas etc. and bring them back from the web to the desktop.

My hope is that plasma development will really come together and get a whole lot of people excited and joining in. We've seen what enabling users to make custom little apps in various Internet sites can do (facebook apps etc. although I'll admit a lot of those applications were annoying and I would like to think that people developing for kde will have a lot more sense in their development models and interfaces).
What I am mostly referring to is the user involvement. Where you can blurr that line between users and developers just a little bit, because if the users are are spending their valuable time working on these applets then they will feel they have more of a stake in the platform and by extension they are more likely to bounce ideas off the main kde developers. This I hope will lead to a platform that is both easier and more intuitive for developers and users. One that is more flexible and more capable of accomplishing the users goals.

I think we have just begun to scratch the surface of plasma. In order to get to the next level I think we need to have more complete documentation for all the various languages like python, C#, java, javascript etc. Right now I see a lot of really good tutorials at techbase.kde.org for C++, but only a few for python ruby, c# etc. There are also some good tutorials scattered around the web on various blogs, mailing lists etc. However for someone starting out it's much nicer if you have a one stop resource for learning how to make really nice plasmoids. I really think we need to get as many of the people that really understand these technologies as we can to write some really good tutorials and explanations of the apis. Especially for the bindings.

The reason I am so insistent on the bindings tutorial is not that I dislike C++. To the contrary it's one of my favorite languages, but the fact that a plasmoid written in C++ has to be re-compiled is a little annoying. I think the scripting languages like python, ruby, javascript are then better suited to this sort of tasks. Granted I think something like systray or the panel and other applets that are going to be packaged with the distro won't have to wrestle with the issue of compilation as much. As for the various weather plasmoids that you find on kde-look they are quite nice, but if I have to compile these then I feel less inclined to bother with adding them. Not to mention I don't think" get hot new stuff" has accommodations for re-compiling plasmoids as they come in. (Disclaimer: it is entirely possible that I missed something and you don't really have to recompile these when moving from distro to distro etc.)

One more thing, more than just tutorials, and apis, we need lots of documented examples. I don't know about most of you but when I am trying to learn a new library or programming language I learn a lot more from examples then from tutorials. Only when I am really comfortable with the basics of library will I start to jump straight to the api.

So here's to hoping that others will take up the call, and that I too will learn enough to be able to write great tutorials and examples.

edit: ya I wrote this when I was completly out of it so my grammer (and in some places logic) are a little screwy...

Friday, January 16, 2009

Hello

I am starting this blog because I intend to use it to relay information about my journey into KDE development/participation. In some ways it will be a case study of what it's like for someone to jump into to work on a project such as KDE. In that context, I will also be using this to show case my work/efforts as well as to discuss various issues reguarding the software industry, particularly in regards to ecosystem that revolves around GNU/Linux.