Archive for the ‘pygtk’ Category

Making a button inactive using PYGTK + GLADE

Sunday, October 2nd, 2005

I have been working on a little app in my spare time. It is for calculating your GPA. Its nothing special, I have even made a similar app in Java as an assignment in class. This app has (at the time of this writting) only 3 buttons. An “add” button, a “calculate” button, and a “quit” button. I decided I wanted to make it so once you hit calculate you could not press add or calculate again, this will prevent you from adding the same info to the display once it has been calculated (with out selecting something from the file menu to reset the form). I searched all over the net and couldnt find anything on how to make this happen but some of the wonderful people in #pygtk were able to help me so I thought I would pass that info along for anyone else.

I made a really simple example to show how this is done with pygtk and glade2. You can d/l the example here. If you have any questions, comments, or suggestions on how I could/should/needed to do this please feel free to comment. I do have moderation enabled for comments so it might take a day or so for it to show but I will allow (and will be open to) any comments that are not spam.

Commenting your code

Thursday, September 29th, 2005

Ok I have been reading and writting a lot of code lately, and one thing that is really pissing me off when I start reading other peoples code is the massive lack of commenting that is going on. It really drives me insane. Whats wrong with taking 1 min of your time as you are writting code to pause and

// this is a comment
/* or maybe this is a comment */
# and maybe this is a comment…
! Maybe even this. Whats it take to get people to comment!?!?!

It doesnt make you cool to not add comments to your code, no one thinks youre a great programmer because you managed to write 1200 lines and not 1 comment in it, it makes you a bit of an a-hole. Im not talking to any one person out there, and if you do comment your code good woot for you, keep it up.

I have been running into a whole mess of uncommented code in the UT2004 video game. It has all this open source stuff where you can make mods etc etc, and thats great and all, but when youre doing code for public projects such as a game mod like this; even if you dont think anyone will look at the code; better guess again, we will reverse compile your code and look what you did to see how it happened so we can make a mod thats similar or maybe even fix a bug in your mod (yep you might have a bug in your mod I know its hard to believe) and reading through 1261 lines of code to find 10 lines that have a comment on them and then only 4 of those 10 are even the slightest bit like a comment (the others are who evers name and date etc) makes it harder to fix your code, or see what youre doing/trying to do. Moral of this rant is to comment your code no matter what your doing!!!!!