Developing Cross Platform Application using Qt, PyQt and PySide : Test Driven Development and Unit Testing - Part 3 of 5

Discipline, I say! - Mark Pilgrim in Dive Into Python 3

Discipline, I say! Smile - Mark Pilgrim in Dive Into Python 3

Throughout my articles in this site, this is the first article that started without a fancy image : I started it with a quote from Mark Pilgrim's book, Dive Into Python 3, Chapter 9 - Unit Testing. There are two things that drive the decision to include this quote:

  1. Although my bachelor's thesis was about Test Driven Development (TDD) in Extreme Programming using Java, in my professional career as a software developer, it's seldom that I really develop application using TDD in mind. Most of the time,  after the initial requirement gathering, I brutally jump to design the application GUI using current IDE being used. Not entirely a bad practice, as sometimes user really need to quickly presented with the application interface, even though  it's a dummy one. But if things are not that hectic, it's always a good idea to start with the test-first programming/TDD style, as follows:
    • Create unit test of application features about to be implemented,
    • Run it and see it fail (because the feature is not there yet!),
    • Implement the features to make the test pass,
    • Refactor it to have a cleaner code and repeat the process until all features were implemented.
    The beauty of this technique is that, the core of your application features will not get intertwined with the application GUI (imagine having a login that coded directly to the login button. What if we want the login method to be executed from behind a Web API?). A code that follow TDD best practices will be a highly isolated and independent code. Which is truly a great thing, because as the application GUI design undergo changes through out its development, the features were already safe and kept in isolation.
  2. A user in reddit, replied in my post about how to best teach kids in programming with an inspiring comment, "I think we started writing python when they were about 13. And we focused on writing code well - unit test harnesses, data validation, etc from the very beginning". Although I have this vague idea in mind, I never really come close to apply this principles in teaching kids how to code. Exploring unit testing technique in C++/Python will surely be an important skill in my passion of teaching kids how to code.

Before jumping to the topic on how to build the application GUI with Qt using Qt Designer and use the resultant *.ui file into a C++ or Python application, I would like to preface it with an important concept in software development methodology : Test Driven Development and Unit Testing using either C++ or Python. To streamlined the discussion, I have already summarized the principles of TDD in the above passage, and not about to dive any further (except by giving credit to Kent Beck who developed/rediscovered the technique). In the rest of the article we are about to have a practical hands-on in developing unit testing code using either C++ (or to be exact using QtTest) and Python.

Let's explore it!

 (More)



Developing Cross Platform Application using Qt, PyQt and PySide : First Iteration of The Overall Application Design and Hello World! - Part 2 of 5

First iteration application flow

Figure 1 - First iteration application flow

Special Note : I beg you pardon, that my subsequent Kivy article eventually must wait until after this Qt cross platform article being published. I found that, this Qt cross platform application to be somewhat challenging and interesting to discuss Smile

As the type of autodidact programmer who love to learn new programming language / framework / library by first thinking in global view of what my first application I would like to create, hereby I designed this tutorial with that principle in mind. The first application we are about to be build doesn't have to be a full blown application. But surely not a simple Hello World or an application whose its single purpose is to reflect the understanding of a one piece of this new things being learned. It should be complex enough to orchestrate many aspect of this new things, and by striving its completion, we will be in the right track of learning it fast. Surely we ought to start with the Hello World first, but while doing our Hello World application, we also have to have something rather complex application design in our mind. That's my two goals in this article : we are going to start with the overall application design and a guided Hello World application development for each of the technology : C++ Qt, PyQt and PySide.

 (More)



Developing Cross Platform Application using Qt, PyQt and PySide : Introduction - Part 1 of 5

The blend of Qt in Python

The blend of Qt in Python
(Image taken from PyQT Wikipedia article)

Before we even begin this new article series, I would like to emphasize one thing : I would love to make this blog as a great starting point for you to learn many tidbits in Python software development. For example, even though what we learn is somewhat an advance topic in Python application development, I will always start with the basic. This eventually create a vast array of article series : Flask, Django, ProgrammedMe, Kivy, etc. The reason is quite simple : if you are new to a Python topic, you can always refer to the first article in a series to be able to follow the rest of the articles. 

In this new article series, the target that I want to accomplished is to introduce you to the Python Android application development using either PySide or PyQt. Yes, previously you have been introduced to Kivy to develop Python application in Android. But, before going even further in Kivy, lets have a comparative experience on Python application development using another libray : PySide/PyQt. This come with a requirement : you must be introduced to and able to develop a PySide/PyQt application in its Desktop environment. Then, we move to its Android development.This is necessary, as differ with Kivy that directly support mobile application development in its first inception, Qt support in mobile development was gradually introduced.

Great. What are you waiting for? Lets go!

 (More)


Starting to Use Kivy : Developing "Letter of Heroes", An Android Alphabet Teaching Aid for Kids Part 2 of 2

 

"Letter of Heroes" in a Samsung Galaxy Tab 2 - Showing Captain America when you pressed the letter "K" (because we read it as Kapten Amerika in Indonesia tongue)

Previously we already have a nice installation of Kivy whether it sit in our development machine or within a pre-configured Linux Ubuntu Quantal VirtualBox machine pre-built with Python for Android environment, to ease the process of packaging Kivy into Android APK. After playing around with Kivy examples code, I found that Python programmers would not have any difficulty in doing mobile application Android development. "Why?", well, because, it simply Python! It just get runs on Android using Python for Android. The core of the problem may lies in the Android integration part of Kivy : e.g. accessing camera, using GPS, Accelerometer, etc. But thanks to Pyjnius, that issues seems to simply fade away. Sure more work must be done before a unifying API for both iOS/Android can be achieved, but from what I see from Kivy progress in the recent years, it looks very good! As for iOS implementation itself, Kivy have Pyobjus that making it easier to access iOS API. Things are pretty interesting there... Smile

In this article we are going to develop our own Python application using Kivy and deploy it in a Samsung Galaxy Tab 2 device.  Lets have a look!

 (More)



Starting to Use Kivy : Developing "Letter of Heroes", An Android Alphabet Teaching Aid Application for Kids - Part 1 of 2

Lets turn these heroes into an .. Alphabet Teaching Aid for Kids!

Lets turn these fictional superheroes into ... kids teaching aid! Laughing

As with any boys, my 3 years son is very fond of any fictional Superhero characters : whether it's coming from Marvel or DC universe (or else for that matter). Actually, I highly responsible for this : I intentionally introduce them to it by watching superhero movies every Saturday night. He loves all of them!   

After he already love them, now is the perfect time to use that love, in encouraging him learning how to read. In this article, I am going to guide you on developing a teaching aid for kids in learning alphabet using Kivy. Let see how well Kivy can support us in obtaining our goal!

 (More)



Django KFIMember Tutorial Part IV - Using South to Manage Schema Migration

The future of Django Schema Migrations, but at the current release of 1.6.1, we still have to use South as Third Party Application

The future of Django Schema Migrations, but at the current release of 1.6.1, we still have to use South as a Third Party Application

To be honest, I believe this article will have a short life. Why? It's simply because migrations is a moving target in Django. As of Django 1.6.x, we still don't have migrations feature built-in. But the good news is, Andrew Godwin, the author of South, is currently working on Kickstarter funded project, to bring migrations feature into the core of Django itself. You can read about it usage here, but you must be aware that it's targeted for Django 1.7. As of now, we still have to use South as a third party Django application. And this is what I try to introduce in this articl.

 (More)



Exploring Python Prospective Technology to Encourage Children in Loving Computer Programming

This is a television serial aired in 1995 in my country, that drive me mad toward computer programming!

Whiz Kids is a serial television show aired in 1995 in my country, that drive me mad toward computer programming!

This is a retrospective article of why I love programming so much, with the goal in mind of how can I transfer such a deep love (not an exaggeration here!) of computer programming especially to my children, but can also be applied to any parents who would like to do the same to theirs.

But, before going deep on the technology stuff, one important thing must be adhere first : our kids have their own destiny. They will learn and develop their own passion toward things that may be alien to us. Forcing them to love something that we love is not only bad, but it can create such a destructive effect. The art in parenting is, if you love something and would like your kids to love the same thing, you'll have to do it smoothly, silky and in such a way that, they will embrace it happily at their own pace without being forced to. If eventually your kids don't show likeness toward that things, well, what can we say? Nothing. We can simply conclude that it's not in their life path ... Wink

 (More)



Django KFIMember Tutorial Part III - Configure Inital PostgreSQL Database Locally and Remotely in Openshift

Configuring PostgreSQL on Openshift

Configuring PostgreSQL on Openshift

ARTICLE UPDATE : As I have unresolved problem when using Python 3.3 combined with Django 1.6 and PostgrerSQL 9.2 in Openshift, I dropped Python 3.3 requirement and rework this application using Python 2.7 instead.

In Part II of this article we have already have an initial working application using Django and also import it into PTVS project. That's a good start. But the application still lack a fundamental requirement for any web database application : database support. In this article we are going to configure the initial Django database and improve it even further by using database migration feature using South. One important note about this article though, it first focused itself for Windows user.  Afterward, we are going to have a look on how it's done for *nix user, especially Ubuntu.

 (More)



PyCocos2D-x : How to Properly Setup Boost.Python in Your Visual C++ 2012 Project

 

Welcome to the First Series of Tutorial on PyCocos2d-x Development

Welcome to the First Series of Tutorial on PyCocos2d-x Development!

Okay, for a quick background, you may skim on my previous article : How to Choose The Best Python 2D Game Engine?. I pointed out, "Although currently I am working with the Cocos2D python version, I am flirting Cocos2d-x due to its wider target platform". And my experience on working with Cocos2D Python was really impressive, but sadly .. it didn't satisfy my requirement. I need to develop an isometric game engine for my current Python teaching aid for kids, ProgrammedMe. And the current Cocos2D didn't support isometric map type that I longed for. I have tried to implement it actually, but as the forum itself is not that active (or may I say rather freeze?), I don't think I want to pursue my exploration in the Cocos2d Python field. Another reason is also about Cocos2D that only targeting desktop platform, which is a deal breaker for me (would love to develop for Android/iOS!). So, a natural direction would be to explore Cocos2D-x and try my best to implement a Python binding for it. Once it's settled, I can start developing ProgrammedMe using the aforementioned binding, named PyCocos2d-x

 (More)


How to Choose The Best Python 2D Game Engine?

 

Latest Indonesia Job completion trend in oDesk

Latest Indonesia Job completion trend in oDesk oConomy page

 

A very common question for newcomer when entering IT software development industry is, "Which programming language should I learn, or focus on?". Most of the time, if not all, you will get answer resemblance to, "Depend on what application you would like to built". It's true. First, you got to decide what area of software development that you really have the passion on. Or, what kind of a application that you like to build : Game? e-Commerce? Education? You can have a look at software categorization listed in Wikipedia for this. For example, once you know that you have the passion to develop your own video game, the next logical step is to do some research in what programming language does your game can be programmed with, or to be exact , what library/framework you have to use?

Answering the last question may seems rather difficult.  Why? Simply because it's a moving target. An answer for this question last year, may become obsolete in these recent days. This is the nature of software industry itself : fast paced with sometimes unpredictable momentum in the near future that will change the fate of a technology mercilessly. You simply can not bet for specific technology/platform to exist forever. You got to prepare for the worst.

 

 (More)


ProgrammedMe : Python Teaching Aid for Kids Part 1 - Using Panda3D to Create Working POC

 

From this starting Panda Tutorial, we can create a great Python teaching aid for the kids!

Figure 1 - From this Panda Tutorial, we can create an attractive Python teaching aid for the kids

To be honest, I failed in my first CoderDojo opening. Sigh.. that's the sad truth.

Yeah, the kids got excited about seeing that they can calculate area of triangle and print the result. Yeiy! But.. what's next? I kinda feeling dumb trying to explain those marvelous Python concept using just a plain black BASH console. I know I really love console (or DOS Prompt to be exact). But as I remember it, at that time of my early introduction to computer programming (circa '95) , there are not much left to explore other than console application. Thinking it further,  it's not the console actually that get me excited. But its the game! I love programming because I love seeing I can programmed .. Digger using QuickBasic.

 (More)



Django KFIMember Tutorial Part II - Creating Initial Application

 
Django online on Openshift!

Figure I-1 Our Django 1.6 application online on Openshift!

ARTICLE UPDATE : As I have unresolved problem when using Python 3.3 combined with Django 1.6 and PostgrerSQL 9.2 in Openshift, I dropped Python 3.3 requirement and rework this application using Python 2.7 instead.

Previously I had laid out the foundations of what Django application we are about to be build. Have a quick read again on what are those foundations. For now, let start with creating our application from scratch.

We will start by creating a Python 3.3 project on Openshift, prepare local Windows environment for it and then import it into a new Python Tools for Visual Studio (PTVS) project. Lastly, we will also prepare our local environment for Linux user, so that for those who prefer to use *nix environment will be able to follow along this tutorial series.

 (More)



Flask Biography Tutorial Part XI : Managing Database Migration in Production Environment Using Alembic

   

Our Openshift's application current state using the latest revision
Our Openshift's application current state using the latest revision
 

Although I never marked our live Bio Application as published, actually at the current state it shouldn't be treated as a production quality application. The main reason is simple : up until now, our database will always be recreated when application started, discarding any data already entered by our users. We do this to allow us focusing our work on perfecting application features than to manage our own database migration script.

Today we are going to have a look on how exactly a database migration technique is implemented. It will allow our application to be stamped as Production Quality application, as it will allow users to registered safely into our application. Whatever development changes we introduce, our users data will not just get thrown to the void. The database schema will be upgraded and existing data will be merged to the new schema.

In our beloved Python world there are plenty of database migration tools available. But as we use SQLAlchemy, well, don't you think that the author of SQLAlchemy should be the  the legitimate author to write its database migration tool? Well then, introducing Alembic!

 (More)



Django KFIMember Tutorial Part I - Deciding Application Scope, Production and Technology Stacks

If this is your first encounter with PTVS, I bet you haven't imagine this kind of screenshot, even in your wildest dreams.

If this is your first encounter with PTVS, I bet you haven't imagine this kind of screenshot, even in your wildest dreams... Cool

ARTICLE UPDATE : As I have unresolved problem when using Python 3.3 combined with Django 1.6 and PostgrerSQL 9.2 in Openshift, I dropped Python 3.3 requirement and rework this application using Python 2.7 instead.

Yes, I know. I haven't finished my Flask Biography Tutorial yet. But I thought I would like to start an initial post of what my next tutorial series would be like. I have several ideas actually, popping from my head of what Python topic (library or framework to be exact) I would like to explore more, which are:

  1. Django : "The Web framework for perfectionists with deadlines". I am pretty much sure, no software developers were not intrigued by that tagline! Before diving into Python, I evaluate Ruby on Rails previously. And I got the sense that Django is Python answer to RoR, which is not that untrue.
  2. Pyramid, mainly because previously I got offered for Pyramid based remote job.
  3. Isometric traffic control simulation game build using (probably) XNA + Python for scripting. Why? Because in one occasion where I explained to my 6 years old daughter of what is an Isometric image (after I saw her to be so enthusiast looking at an isometric pixel-art image), she and also her 3 years old brother seems to be interested on it.

    It's so addicted!
    It's so addicted! Try to find Batman in that beautiful pixel art image taken from nasc

  4. Twisted, to be able to develop a large scale of network event-driven application. It may be just a chat server for the aforementioned Isometric traffic control simulation game, or a more complex multiplayer server for it.

Eventually, as I also have been offered a job to develop membership website for our Koperasi Freelancer Indonesia (KFI), I thought the timing is perfect if I blog my experience in developing it as my next tutorial series in this blog. With one interesting twist of plot : we are going to add another development platform, Python Tools for Visual Studio + Windows Azure. But still not forgetting those  who use *nix. In this series, we are going to see how well Windows Azure match up with Openshift in context of deploying Python web application.

Hence, welcome to the first installment of Pythonthusiast's Django Tutorial!

 (More)



Flask Biography Tutorial Part X : Building Portfolio Form Modal Dialog using Flask-WTF, Bootstrap 3, Bootbox, Bootstrap Tags Input and jQuery

 

 

I got to admit something : I really have fun writing this current article! It shows concise way for new comer in Python web development area to truly understand how to integrate Bootstrap and its extensions, jQuery and Flask to build feature that increase user experience in interacting with the application.

Previously we haven't utilize jQuery and many Bootstrap extensions there exist in the web, making our application solely depends on what Flask community gave us (which is great!). But, as we already choose to leverage Bootstrap 3 in our application, this decision bring great advantage : we can easily tap to plethora of Bootstrap extension built by community and add it in our own application to gain benefit of its functionality. Specifically we are going to maximize the use of this open source products to our application:

  1. jQuery, especially its .getJSON and .post method to allow our Portfolio form live as a modal dialog box complete with Ajax validation and Ajax form submission. I got to beg you pardon for this, for thinking in the previous post that we have to use jQuery client side validation. Turn out what I really want is an Ajax based validation technique. I will explain later what are the differences. But one important thing is, we don't have to double our validation mechanism complexity by also implementing it in client-side.
  2. Bootstrap Tags Input, making entering tags as comma separated value is a pleasant experience.
  3. Bootbox that lets our application utilize a popup confirmation dialog easily.

Ready? Let's start!

 (More)




Copyright(c) 2014 - PythonBlogs.com
By using this website, you signify your acceptance of Terms and Conditions and Privacy Policy
All rights reserved