lundi 24 juin 2013

Create windows GUI executable using Python & QtCreator & PyQt & cx_Freeze

Requirements

- QtCreator
- Python 3.3
- PyQt 4.1 (pyuic4 under linux / pyuic4.bat under windows)
- cx_Freeze 4.3.1 for Python 3.3


Step-by-step for a HelloWorld.exe


Step1: Create the ui form with a pushbutton named: btnHelloWorld


Step 2: Convert .ui to .py
Under windows:  pyuic4.bat -o mainwindow.py mainwindow.ui
Under linux:

Step 3: Implement Handlers.
Now create a helloworld.py file with following content:
import re   #Strange, but I do need this import to make the executable able to find QtCore
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from mainwindow import *

class Handlers(object):   
    def btnHelloWorld_Clicked(self):       
        if QMessageBox.question(None, '', "HelloWorld, would you say goodbye ?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes:
            sys.exit(app.exec_())

    def installHandlers(self, uimw):
        self.uimw = uimw
        uimw.MainWindow.connect(uimw.btnHelloWorld, SIGNAL("clicked()"), self.btnHelloWorld_Clicked)       
               
if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("QPlastiqueStyle"))

    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    ui.MainWindow = MainWindow

    handlers = Handlers()
    handlers.installHandlers(ui)

    MainWindow.show()
    sys.exit(app.exec_())
 Step 4: Create setup.py file with following content
 from cx_Freeze import setup, Executable
setup(
    name = "HelloWorld",
    version = "0.1",
    description = "PyQt4 Hellworld",
    executables = [Executable("helloworld.py")]
    )
Step 5: Open a command line, change to the source directory (setup.py, helloworld.py, mainwindow.py) and issue the command to compile the executable:
python.exe setup.py build

Step 6: Now the exefile can be found in the build directory, launch the exe
It works like a charm !!!




jeudi 20 juin 2013

The Code Sheriff: Xcode vs. AppCode

The Code Sheriff: Xcode vs. AppCode: Some Background (mostly some personal info about me - skip if you're only interested in the comparison): I've always been an Ec...

Installing Mercurial Eclipse Plugin


Source: https://bitbucket.org/mercurialeclipse/main/wiki/Installation_and_Configuration.wiki#!installation-and-configuration


Install from update site


Update Site URL
Stable Releases:http://mercurialeclipse.eclipselabs.org.codespot.com/hg.wiki/update_site/stable
Development Snapshots:http://mercurialeclipse.eclipselabs.org.codespot.com/hg.wiki/update_site/snapshots

Generally only use the stable update site. Use the development snapshots update site to try out the latest features or to help test the next version.

In Eclipse add the update site "Help"->"Install New Software...". Exact screens may vary depending on Eclipse version.
r1051_Eclipse-Softwareupdates.jpg

To add the site click on the Available software tab. I'm using another link from javaforge.
You should see something like the following screenshot:



mercredi 19 juin 2013

Installing Eclipse Juno & CDT & Visual C++ Express 2010

1. Installing Eclipse Juno - Eclipse Classic 4.x (4.3)
Link: http://download.eclipse.org/eclipse/downloads/
In this package: the Eclipse Platform, Java Development Tools, and Plug-in Development Environment, including source and both user and programmer documentation.


2. Installing Eclipse IDE for C/C++ Developers
Link: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/junosr1
This package includes:
  • C/C++ Development Tools
  • Eclipse EGit
  • Mylyn Task List
  • Remote System Explorer


3. Installing Visual C++ 2010 Express 
Link: https://www.microsoft.com/visualstudio/fra#downloads

4. Launching
Remember to launch the vcvarsall.bat of Visual Studio before launching eclipse.exe
This allows Eclipse finding out the VC compiler & VC linker when the VC tool chain is used for the project.

For example, create a shortcut for eclise and prepend the call to vcvarsall.bat as following:
"C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 & "C:\My Downloads\eclipse-SDK-4.3RC3-win32\eclipse\eclipse.exe"

Other References:
http://eclipsebook.in/appendix/installing-toolchains/
http://www.ibm.com/developerworks/library/os-ecl-vscdt/