Monday, January 31, 2011

The constrictor class

A constrictor is a class of snake- it's a pun for Python talk!

I just read my last posting from 2 months ago, and not much has changed in my opinion of Python. I thought I was taking way too big a bite to try and learn programming Python with GTK and SQLite all at the same time. But for my level of experience, maybe not? There is very little to each, after slogging thought Windows API/GUI, and later MFC, and DOG HUMPING JAVA! (I think there still might be a little bitterness there).

I want to talk about where I'm at, and comfort in that. It's kind of like I'm over the culture shock and ready to become a more responsible citizen of the city, rather than another of it's raging lunatics. However, hope blooms eternal!

Some things in Python still cause my brain to switch directly into an old time TV test pattern! And I know, I just lost a whole generation of you out there, who haven't a clue about TV station not being 24 hour machines. Think of it as the SPONSORED PROGRAMMING that does nothing, exactly like Movie Theaters before the coming attractions today, like the slide for Popcorn!

Anyway, top ten of things I really don't understand yet; Lambda. Just makes my brain hurt! So, I'm glossing over that for a while... Then there is the annoyance of SELF, as an argument to a function. Alright already, I put in self; And it seems to be happy, though my brain is having this tantrum of "this is stupid!", I'm managing to ignore that.

I'm at the point now, where I need to learn how to make a Window with functional Scrollbars. I read something about this in PyGTK tutorial, some place? But even rev-eng sample code after sample code, it wasn't until you reach Menus From ItemFactory that you're really go; BINGO! Now, I can work with this! This is the TEMPLATE I need to start with! <itemfactorexample>

Meanwhile, on the SQLite front, I've done a lot of exploring Python in immediate mode, but I haven't started wrapping it into my class yet. We're kind of at the impasse of TRY/EXCEPTION which has never been my favorite way to raise/handle errors, EVER! So I'm still toying with that in my brain, once it's a topic I like to avoid to being with. I'm a little concerned that SQLite likes to just create a database, if none exists, rather making you issue an SQL command to CREATE DATABASE ...

So here I sit, right at the point where I'm about to make a program useful. When I fucking get the flu!!! Thankfully, you are not in contact with the phlegm I just coughed out at my monitor! But let's get down the nitty gritty, anyway: I don't understand these guys that object to braces so much, in favor of indentation. Indentation can be it's own level of meaningless hell!!! For the Linux User, Gphp editor will be a nightmare to use, with it's choice of tabs instead of spaces regardless of setup options. However, Blue Fish is absolutely awesome! Edle is somewhere in between, and really not in my comfort zone, for some reason? Blue Fish, with an open terminal window is my choice. But of coarse Blue Fish is totally setup for developing HTML pages, with PHP code, so the whole editor seems rather useless in Python. But it's auto-indents work flawlessly, as does it's color coding. It was made for the Python developer too, and so far is my favorite editor.

So far, I've given you NO great tutorial about Python programming, because that's really not my thing, particularly when I'm just exploring it. I don't think I really have much to add, that you can't read yourself from pygkt.org website.

Accept for one thing. When you look at the ItemFactory method of making menus, you will instantly flash on the same subject that the Pythons would never think of in a thousand years because they are not starting from SCRATCH!!! The ItemFactory example is the perfect starting point for the experienced Windows programmer, but it will totally piss you off in documentation! The question that comes to every one's mind, right out the gate is; "HOW DO I DISABLE A MENU ITEM?" There is NO disable/enable Gobject? ???? ????! Here we have to get into X thinking (carrot / cursor) ie (mouse / ibar). Programming 101: A menu item is the same thing as a button! Which is no help for this problem, because it's all in our terminology that is the problem. What you are looking to do in PyGTK's is activate and deactivate "SENSITIVE" setting.
>>> menuitem.sensitive(False)

All of my programming friends have greeted this with exactly the same angry reaction; "WTF!??? It's no wonder you wasted a whole day on that!"