Not so productive days.
Down with fever.
Way too much of sleeping and idleness, its sick.
Symposium Gang Split with friends on both side.
Time to get myself busy.
I’m surprised its taking a lot of time ( hell a lot! ), to fix things and get the script to work as intended. The script to fetch cover pic from fb, and mask it with Symposium’s Poster.
Learn’t how image files can be converted to strings to store it in a db, or just use it without storing at all, just toggling them vice versa.
Lazily written bad code , chains up a train of bugs as reward.
It takes me an entire night to get, atleast to a working version of a relatively simpler application. Damn ! I have to upgrade my Intelligence Quotient or I die of insomnia.
This is a collection of steps for building the app, Since I had to digg them from an awful lot of sources scattered around the Web, Just to put them together and make it easy for me to refer tomorrow.
Trying to write an Application that will generate a fb cover pic for my College’s Symposium promoters. First I needed to learn how PIL processed images, and yes, I got it. The Story goes like this,
- And in the beginning there were two images and they were good :-)
- One which the user uploads(Generating a common cover, would have been easier, but using user uploaded images give it a personal touch), and another image that will be designed by me to mask the user’s image.
- A bit of editing of user’s pic. Increase brightness
- Then a desaturated effect with
- Then, a blurry touch with
- Thats it, Now
blendedImage = Image.blend(MyPic, UserPic, 0.5) will give me a masked and merged image.
- Then comes the slogan or tag whatever you call it. For this I have to use ImageDraw Class.
canvas = ImageDraw.Draw(MaskedImage) This wil write my text on the image, in programmer’s green :-)
- Image ready to be stamped with our Symposium’s Seal. Stuff that can be done later, when the name gets finalised.
Instead of my friends uploading their pic, which is actually a boring part, why not let them enter their fb profile link and let my app fetch their current cover picture as ‘UserPic’.
That would be a bit more elegant way.
But it holds a problem. ‘Smart’ facebook coders have hidden all personal data from being read by any pre-programmed script.
This is the part where geeks have their role.
A bit of a hacking had to be done, after I came to know the intentionally placed
"" had to be removed before parsing the html source.
hackedHtml = re.sub('<!--', ' ', SecuredText)
That tiny piece of code did the thing.
So, Now I get hold of the user’s Cover and we all live happily ever after…
This will be of no use to you. This is just a log of how QuickPress came into life.
- Had to install the tools required- PyQt4, PyKDE4(Linux),pyuic4,python-wordpress-xmlrpc,lxml
- Designed the user interface in QtDesigner which generated the .ui file. This could have been coded, but I hate diving into documentation for reasonably trivial thingies. The greatest advantage was by looking at the code generated, I learnt GUI Programming and learning from code is far better than any of the best books. Sort of Reverse Engineering
- Generated the python script from ui file using pyuic4.
- Wrote the main handler script which imports the designed GUI Object and wrote a thin wrapper to modify its properties. This is where my actual code goes.
- Time to turn it into an executable that runs on multiple platforms. Why else could anybody choose Qt for?
- Used PyInstaller. The process was way too smooth for windows. In Linux there were bugs, in hooks for importing modules. Worked it out by hardcoding the buggy import statement in the raw Python Script.
- Everything else, pyinstaller and its long schezophrenic log messages took care.
- For Gnome, KDE I had to write a QuickPress.desktop configuration file, that took care of linux specific stuff.
- …..and Finally, It was done. I anticipated a slower performance, since it was written with a scripting language, but to my surprise, the app responded exceptionally perfect.
- My First GUI app, a Greeting card Application, written in Java was responding a little bit faster than a turtle walk, to the GUI events! That should be so, because it had to draw its own interface using its swing or awt classes.
- But in QuickPress, Qt was just a binding to the OS’s native GUI elements. that made it faster and better. Even, its looks gently morphed with the OS’s native looks and gives a homely touch.
- And here comes Sunday Morn! Time to sleep.
Test Post from Linux:
QuickPress turned into an executable Application from being a python script!
Successfully shipped QuickPress from linux to Windows. So, Lets ‘hurray’ for that!
Its time to thank.
Thanks Qt, and your excellent cross platform support.
Thanks PyInstaller for doing the actual porting work.
Last, but not the Least, thank you pyQt4 and Qt Documentation, without you it would never have been possible. Thankyou, Once again.
Hey, I thought I was a bad orator! :-P
I’m trying to port QuickPress to Windows.
Updated from Windows.
A Handy GUI Tool to publish my posts to WordPress, Wouldn’t it be cool?
GTK was lacking updated Documentation, Well, atleast for me, I didn’t find any up-to-date content. Thanks, lazy me.
Qt on the otherhand, had extremely wide set of resources, and it helped.
My App, its just a QMainWindow that displays a QTextEdit Object and QLineText Object, a Kpushbutton that listens for the “clicked()” SIGNAL and executes the “post” SLOT. Ultra Simple. Way more to go.
Code @ github
This is my first post with my newly designed gui app! Lets name it …huh….. WordPress Quick.
If you can see this, it worked!