Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

Wednesday, May 19, 2010

TIPS: Python: Copying text in Clipboard using Python

following code lets you achieve that.
import win32clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(text)
win32clipboard.CloseClipboard()

Tuesday, March 9, 2010

Tips: Python: How to get the full username in Windows

import win32com,win32com.client,pythoncom

sDomain ="ES"

sUser ="johrim"

sADSPath= sDomain + sUser

oUser=win32com.client.GetObject("WinNT://%s,user" % sADSPath )

print (oUser.FullName)

Saturday, March 6, 2010

Tips: Python : wxFormBuilder v3.1.67-beta (Febuary 18, 2010) Python Update

Latest version of wxFormBuilder does not support wxAdditions fully, thus I have updated few XML files to support FlatNotebook & wx.propgrid widgets.

  1. Download wx.propgrid and install it.

  2. Download the XML.Zip folder and extract it in plugins\wxAdditions\xml folder.

  3. Restart the wxformbuilder.


I did not tried to update these files for other widgets but it should be similar.

Friday, February 19, 2010

Tips: MSI: Save differences between two msi as MST file using ruby & python

Ruby
require 'win32ole'
msiClass = WIN32OLE.new("WindowsInstaller.Installer")
msidb = msiClass.OpenDatabase("C:\\temp\\MountPointGenerator.msi",0)
newmsidb = msiClass.OpenDatabase("C:\\temp\\updatedMountPointGenerator.msi",0)
transform = newmsidb.GenerateTransform(msidb,"c:\\temp\\newtest.mst")

Python
import win32com.client
import os
import sys


msiOpenDatabaseModeReadOnly=0
msidb=r"c:\temp\MountPointGenerator.msi"
msiupdb=r"c:\temp\updatedMountPointGenerator.msi"
mstdb=r"C:\temp\MNPtrans.mst"


installer = win32com.client.Dispatch("WindowsInstaller.Installer")
database = installer.OpenDatabase(msidb, msiOpenDatabaseModeReadOnly)
updatedDB= installer.OpenDatabase(msiupdb , msiOpenDatabaseModeReadOnly)
updatedDB.GenerateTransform(database, mstdb)

Sunday, December 14, 2008

TIPS: Python: How to convert python script to executable

Python script can be converted in a standalone executable using one of the exe builder like
* py2exe (Windows)
* py2app (Mac OS)
* PyInstaller (all platforms)
* cx_Freeze (Windows and Linux)
* bbFreeze (Windows and Linux)

Thursday, July 3, 2008

recursive list files in a dir using Python

use the following code to list the files in a dir tree
import os
import sys
fileList = []
rootdir = sys.argv[1]
for root, subFolders, files in os.walk(rootdir):
for file in files:
fileList.append(os.path.join(root,file))
print fileList

Saturday, January 12, 2008

Setting ColumnWidth of wx.ListView control in python

# Get the size of listView Control
w = self.lvMountPoint.GetSize()
# Set the ColumnWidth
self.lvMountPoint.SetColumnWidth(0,w[0] * 0.81)
self.lvMountPoint.SetColumnWidth(1,w[0] * 0.19)