@ -16,7 +16,7 @@ import os, sys
try :
try :
from TQt import qt
from TQt import qt
except ( ImportError ) :
except ( ImportError ) :
raise " Failed to import the required PyTQt python module. "
raise Exception ( " Failed to import the required PyTQt python module. " )
####################################################################################
####################################################################################
# Samples.
# Samples.
@ -113,13 +113,13 @@ class Samples:
return (
return (
' import krosskexidb ' ,
' import krosskexidb ' ,
' drivermanager = krosskexidb.DriverManager() ' ,
' drivermanager = krosskexidb.DriverManager() ' ,
' print " drivernames: %s " % d rivermanager.driverNames( )' ,
' print ( " drivernames: %s " % d rivermanager.driverNames( ) )' ,
' ' ,
' ' ,
' driver = drivermanager.driver( \" {DriverName} \" ) ' ,
' driver = drivermanager.driver( \" {DriverName} \" ) ' ,
' print " driver: {DriverName} " ' ,
' print ( " driver: {DriverName} " ) ' ,
' print " version= %s . %s " % (driver.versionMajor(),driver.versionMinor()) ' ,
' print ( " version= %s . %s " % (driver.versionMajor(),driver.versionMinor()) ú ' ,
' print " mimetype= %s " % d river.fileDBDriverMimeType() ' ,
' print ( " mimetype= %s " % d river.fileDBDriverMimeType() ú ' ,
' print " filedriver= %s " % d river.isFileDriver( )' ,
' print ( " filedriver= %s " % d river.isFileDriver( ) )' ,
)
)
class ConnectWithFile :
class ConnectWithFile :
@ -137,7 +137,7 @@ class Samples:
' ' ,
' ' ,
' # Get the connectiondata from the project file. ' ,
' # Get the connectiondata from the project file. ' ,
' connectiondata = drivermanager.createConnectionDataByFile( " {ProjectFile} " ) ' ,
' connectiondata = drivermanager.createConnectionDataByFile( " {ProjectFile} " ) ' ,
' print " Connectiondata: %s " % c onnectiondata.serverInfoString( )' ,
' print ( " Connectiondata: %s " % c onnectiondata.serverInfoString( ) )' ,
' ' ,
' ' ,
' # Create the driver for the database backend. ' ,
' # Create the driver for the database backend. ' ,
' driver = drivermanager.driver( connectiondata.driverName() ) ' ,
' driver = drivermanager.driver( connectiondata.driverName() ) ' ,
@ -146,19 +146,19 @@ class Samples:
' connection = driver.createConnection(connectiondata) ' ,
' connection = driver.createConnection(connectiondata) ' ,
' if not connection.isConnected(): ' ,
' if not connection.isConnected(): ' ,
' if not connection.connect(): ' ,
' if not connection.connect(): ' ,
' raise " Failed to connect " ' ,
' raise Exception( " Failed to connect " ) ' ,
' ' ,
' ' ,
' # Open the database for usage. ' ,
' # Open the database for usage. ' ,
' print " Databases: %s " % c onnection.databaseNames( )' ,
' print ( " Databases: %s " % c onnection.databaseNames( ) )' ,
' if not connection.isDatabaseUsed(): ' ,
' if not connection.isDatabaseUsed(): ' ,
' if not connection.useDatabase( connectiondata.databaseName() ): ' ,
' if not connection.useDatabase( connectiondata.databaseName() ): ' ,
' if not connection.useDatabase( connectiondata.fileName() ): ' ,
' if not connection.useDatabase( connectiondata.fileName() ): ' ,
' raise " Failed to use database " ' ,
' raise Exception( " Failed to use database " ) ' ,
' ' ,
' ' ,
' # Print some infos. ' ,
' # Print some infos. ' ,
' print " All tables: %s " % c onnection.allTableNames( )' ,
' print ( " All tables: %s " % c onnection.allTableNames( ) )' ,
' print " Tables: %s " % c onnection.tableNames( )' ,
' print ( " Tables: %s " % c onnection.tableNames( ) )' ,
' print " Queries: %s " % c onnection.queryNames( )' ,
' print ( " Queries: %s " % c onnection.queryNames( ) )' ,
)
)
class IterateThroughTable :
class IterateThroughTable :
@ -177,7 +177,7 @@ class Samples:
' ' ,
' ' ,
' # Get the connectiondata from the project file. ' ,
' # Get the connectiondata from the project file. ' ,
' connectiondata = drivermanager.createConnectionDataByFile( " {ProjectFile} " ) ' ,
' connectiondata = drivermanager.createConnectionDataByFile( " {ProjectFile} " ) ' ,
' print " Connectiondata: %s " % c onnectiondata.serverInfoString( )' ,
' print ( " Connectiondata: %s " % c onnectiondata.serverInfoString( ) )' ,
' ' ,
' ' ,
' # Create the driver for the database backend. ' ,
' # Create the driver for the database backend. ' ,
' driver = drivermanager.driver( connectiondata.driverName() ) ' ,
' driver = drivermanager.driver( connectiondata.driverName() ) ' ,
@ -186,13 +186,13 @@ class Samples:
' connection = driver.createConnection(connectiondata) ' ,
' connection = driver.createConnection(connectiondata) ' ,
' if not connection.isConnected(): ' ,
' if not connection.isConnected(): ' ,
' if not connection.connect(): ' ,
' if not connection.connect(): ' ,
' raise " Failed to connect " ' ,
' raise Exception( " Failed to connect " ) ' ,
' ' ,
' ' ,
' # Open the database for usage. ' ,
' # Open the database for usage. ' ,
' if not connection.isDatabaseUsed(): ' ,
' if not connection.isDatabaseUsed(): ' ,
' if not connection.useDatabase( connectiondata.databaseName() ): ' ,
' if not connection.useDatabase( connectiondata.databaseName() ): ' ,
' if not connection.useDatabase( connectiondata.fileName() ): ' ,
' if not connection.useDatabase( connectiondata.fileName() ): ' ,
' raise " Failed to use database " ' ,
' raise Exception( " Failed to use database " ) ' ,
' ' ,
' ' ,
' # Get the table and create a query for it. ' ,
' # Get the table and create a query for it. ' ,
' table = connection.tableSchema( \" {TableName} \" ) ' ,
' table = connection.tableSchema( \" {TableName} \" ) ' ,
@ -201,14 +201,14 @@ class Samples:
' # Create a cursor to walk through the records. ' ,
' # Create a cursor to walk through the records. ' ,
' cursor = connection.executeQuerySchema( query ) ' ,
' cursor = connection.executeQuerySchema( query ) ' ,
' if not cursor: ' ,
' if not cursor: ' ,
' raise " Failed to create cursor. " ' ,
' raise Exception( " Failed to create cursor. " ) ' ,
' ' ,
' ' ,
' # Iterate through the records. ' ,
' # Iterate through the records. ' ,
' if not cursor.moveFirst(): ' ,
' if not cursor.moveFirst(): ' ,
' raise " The cursor has no records to read from. " ' ,
' raise Exception( " The cursor has no records to read from. " ) ' ,
' while not cursor.eof(): ' ,
' while not cursor.eof(): ' ,
' for i in range( cursor.fieldCount() ): ' ,
' for i in range( cursor.fieldCount() ): ' ,
' print " %s " % c ursor.value(i )' ,
' print ( " %s " % c ursor.value(i ) )' ,
' cursor.moveNext() ' ,
' cursor.moveNext() ' ,
)
)
@ -232,7 +232,7 @@ class Samples:
except :
except :
import traceback
import traceback
trace = " " . join ( traceback . format_exception ( sys . exc_info ( ) [ 0 ] , sys . exc_info ( ) [ 1 ] , sys . exc_info ( ) [ 2 ] ) )
trace = " " . join ( traceback . format_exception ( sys . exc_info ( ) [ 0 ] , sys . exc_info ( ) [ 1 ] , sys . exc_info ( ) [ 2 ] ) )
print trace
print ( trace )
class _CellsWidget ( ListWidget ) :
class _CellsWidget ( ListWidget ) :
def __init__ ( self , parentwidget ) :
def __init__ ( self , parentwidget ) :
@ -279,13 +279,13 @@ class Samples:
' # Get the sheet defined by the sheetname. ' ,
' # Get the sheet defined by the sheetname. ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' if not sheet: ' ,
' if not sheet: ' ,
' raise " No such sheet {SheetName} %s " % d ocument.sheetNames( )' ,
' raise Exception( " No such sheet {SheetName} %s " % d ocument.sheetNames( ) )' ,
' ' ,
' ' ,
' ( (col1,row1),(col2,row2) ) = {Cells} ' ,
' ( (col1,row1),(col2,row2) ) = {Cells} ' ,
' for c in range(col1,col2): ' ,
' for c in range(col1,col2): ' ,
' for r in range(row1,row2): ' ,
' for r in range(row1,row2): ' ,
' cell = sheet.cell(c,r) ' ,
' cell = sheet.cell(c,r) ' ,
' print " cell c= %s r= %s v= %s " % (c,r,cell.value( ))' ,
' print ( " cell c= %s r= %s v= %s " % (c,r,cell.value( ) ))' ,
' cell.setText( \" {Value} \" ) ' ,
' cell.setText( \" {Value} \" ) ' ,
)
)
@ -311,7 +311,7 @@ class Samples:
' # Get the sheet defined by the sheetname. ' ,
' # Get the sheet defined by the sheetname. ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' if not sheet: ' ,
' if not sheet: ' ,
' raise " No such sheet {SheetName} %s " % d ocument.sheetNames( )' ,
' raise Exception( " No such sheet {SheetName} %s " % d ocument.sheetNames( ) )' ,
' ' ,
' ' ,
' ( (col1,row1),(col2,row2) ) = {Cells} ' ,
' ( (col1,row1),(col2,row2) ) = {Cells} ' ,
' for c in range(col1,col2): ' ,
' for c in range(col1,col2): ' ,
@ -340,12 +340,12 @@ class Samples:
' # Get the sheet defined by the sheetname. ' ,
' # Get the sheet defined by the sheetname. ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' if not sheet: ' ,
' if not sheet: ' ,
' raise " No such sheet {SheetName} %s " % d ocument.sheetNames( )' ,
' raise Exception( " No such sheet {SheetName} %s " % d ocument.sheetNames( ) )' ,
' ' ,
' ' ,
' # Iterate through the cells that have content (aka that are not empty). ' ,
' # Iterate through the cells that have content (aka that are not empty). ' ,
' cell = sheet.firstCell() ' ,
' cell = sheet.firstCell() ' ,
' while cell: ' ,
' while cell: ' ,
' print " col= %s row= %s value= %s " % (cell.column(),cell.row(),cell.value( ))' ,
' print ( " col= %s row= %s value= %s " % (cell.column(),cell.row(),cell.value( ) ))' ,
' cell = cell.nextCell() ' ,
' cell = cell.nextCell() ' ,
)
)
@ -367,10 +367,10 @@ class Samples:
' # Get the sheet defined by the sheetname. ' ,
' # Get the sheet defined by the sheetname. ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' sheet = document.sheetByName( \" {SheetName} \" ) ' ,
' if not sheet: ' ,
' if not sheet: ' ,
' raise " No such sheet {SheetName} %s " % d ocument.sheetNames( )' ,
' raise Exception( " No such sheet {SheetName} %s " % d ocument.sheetNames( ) )' ,
' ' ,
' ' ,
' print " name= %s " % s heet.name( )' ,
' print ( " name= %s " % s heet.name( ) )' ,
' print " maxcolumns= %s maxrows= %s " % (sheet.maxColumn(),sheet.maxRow( ))' ,
' print ( " maxcolumns= %s maxrows= %s " % (sheet.maxColumn(),sheet.maxRow( ) ))' ,
)
)
class LoadDocFromNativeXML :
class LoadDocFromNativeXML :
@ -464,10 +464,10 @@ class Samples:
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
' # Get the source sheet. ' ,
' # Get the source sheet. ' ,
' fromsheet = document.sheetByName( " {SourceSheet} " ) ' ,
' fromsheet = document.sheetByName( " {SourceSheet} " ) ' ,
' if not fromsheet: raise " No such sheet {SourceSheet} %s " % d ocument.sheetNames( )' ,
' if not fromsheet: raise Exception( " No such sheet {SourceSheet} %s " % d ocument.sheetNames( ) )' ,
' # Get the target sheet. ' ,
' # Get the target sheet. ' ,
' tosheet = document.sheetByName( " {TargetSheet} " ) ' ,
' tosheet = document.sheetByName( " {TargetSheet} " ) ' ,
' if not fromsheet: raise " No such sheet {TargetSheet} %s " % d ocument.sheetNames( )' ,
' if not fromsheet: raise Exception( " No such sheet {TargetSheet} %s " % d ocument.sheetNames( ) )' ,
' # Copy the cells. ' ,
' # Copy the cells. ' ,
' fromcell = fromsheet.firstCell() ' ,
' fromcell = fromsheet.firstCell() ' ,
' while fromcell: ' ,
' while fromcell: ' ,
@ -492,13 +492,13 @@ class Samples:
' # Get the current document and the sheet. ' ,
' # Get the current document and the sheet. ' ,
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
' sheet = document.sheetByName( " {Sheet} " ) ' ,
' sheet = document.sheetByName( " {Sheet} " ) ' ,
' if not sheet: raise " No such sheet {Sheet} %s " % d ocument.sheetNames( )' ,
' if not sheet: raise Exception( " No such sheet {Sheet} %s " % d ocument.sheetNames( ) )' ,
' ' ,
' ' ,
' filename = " {FileName} " ' ,
' filename = " {FileName} " ' ,
' try: ' ,
' try: ' ,
' file = open(filename, " r " ) ' ,
' file = open(filename, " r " ) ' ,
' except IOError: ' ,
' except IOError: ' ,
' raise " Failed to open CSV File: %s " % f ilename ' ,
' raise Exception( " Failed to open CSV File: %s " % f ilename ) ' ,
' ' ,
' ' ,
' import csv ' ,
' import csv ' ,
' csvparser = csv.reader(file) ' ,
' csvparser = csv.reader(file) ' ,
@ -530,7 +530,7 @@ class Samples:
' try: ' ,
' try: ' ,
' file = open(filename, " w " ) ' ,
' file = open(filename, " w " ) ' ,
' except IOError: ' ,
' except IOError: ' ,
' raise " Failed to write CSV File: %s " % f ilename ' ,
' raise Exception( " Failed to write CSV File: %s " % f ilename ) ' ,
' # Prepare CSV-writer ' ,
' # Prepare CSV-writer ' ,
' import csv ' ,
' import csv ' ,
' csvwriter = csv.writer(file) ' ,
' csvwriter = csv.writer(file) ' ,
@ -539,7 +539,7 @@ class Samples:
' # Get the current document and the sheet. ' ,
' # Get the current document and the sheet. ' ,
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
' sheet = document.sheetByName( " {Sheet} " ) ' ,
' sheet = document.sheetByName( " {Sheet} " ) ' ,
' if not sheet: raise " No such sheet {Sheet} %s " % d ocument.sheetNames( )' ,
' if not sheet: raise Exception( " No such sheet {Sheet} %s " % d ocument.sheetNames( ) )' ,
' # Iterate over the cells. ' ,
' # Iterate over the cells. ' ,
' cell = sheet.firstCell() ' ,
' cell = sheet.firstCell() ' ,
' record = [] ' ,
' record = [] ' ,
@ -572,7 +572,7 @@ class Samples:
return (
return (
' from TQt import qt ' ,
' from TQt import qt ' ,
' openfilename = qt.TQFileDialog.getOpenFileName( " {FileName} " , " *.txt *.html;;* " , self) ' ,
' openfilename = qt.TQFileDialog.getOpenFileName( " {FileName} " , " *.txt *.html;;* " , self) ' ,
' print " openfile= %s " % o penfilename ' ,
' print ( " openfile= %s " % o penfilename ) ' ,
)
)
class SaveFileDialog :
class SaveFileDialog :
@ -587,7 +587,7 @@ class Samples:
return (
return (
' from TQt import qt ' ,
' from TQt import qt ' ,
' savefilename = qt.TQFileDialog.getSaveFileName( " {FileName} " , " *.txt *.html;;* " , self) ' ,
' savefilename = qt.TQFileDialog.getSaveFileName( " {FileName} " , " *.txt *.html;;* " , self) ' ,
' print " savefile= %s " % s avefilename ' ,
' print ( " savefile= %s " % s avefilename ) ' ,
)
)
class CustomDialog :
class CustomDialog :
@ -631,9 +631,9 @@ class Samples:
' ' ,
' ' ,
' text, ok = qt.TQInputDialog.getText( " {Caption} " , " {Message} " , qt.TQLineEdit.Normal, " " ) ' ,
' text, ok = qt.TQInputDialog.getText( " {Caption} " , " {Message} " , qt.TQLineEdit.Normal, " " ) ' ,
' if ok: ' ,
' if ok: ' ,
' print " Text defined: %s " % text ' ,
' print ( " Text defined: %s " % text ) ' ,
' else: ' ,
' else: ' ,
' print " Dialog aborted. " ' ,
' print (" Dialog aborted. " ) ' ,
)
)
####################################################################################
####################################################################################
@ -658,7 +658,7 @@ class Samples:
' d = dcopext.DCOPApp(apps[0], dcopclient) ' ,
' d = dcopext.DCOPApp(apps[0], dcopclient) ' ,
' result,typename,data = d.appclient.call(apps[0], " klipper " , " getClipboardContents() " , " " ) ' ,
' result,typename,data = d.appclient.call(apps[0], " klipper " , " getClipboardContents() " , " " ) ' ,
' ds = qt.TQDataStream(data, qt.IO_ReadOnly) ' ,
' ds = qt.TQDataStream(data, qt.IO_ReadOnly) ' ,
' print " Clipboard content: \\ n %s " % tdecore.dcop_next(ds, TQSTRING_OBJECT_NAME_STRING )' ,
' print ( " Clipboard content: \\ n %s " % tdecore.dcop_next(ds, TQSTRING_OBJECT_NAME_STRING ) )' ,
)
)
class AmarokCollectionInfos :
class AmarokCollectionInfos :
@ -685,7 +685,7 @@ class Samples:
' ' ,
' ' ,
' for funcname in [ " totalAlbums " , " totalArtists " , " totalCompilations " , " totalGenres " , " totalTracks " ]: ' ,
' for funcname in [ " totalAlbums " , " totalArtists " , " totalCompilations " , " totalGenres " , " totalTracks " ]: ' ,
' result,replytype,replydata = d.appclient.call( " amarok " , " collection " , " %s () " % f uncname, " " ) ' ,
' result,replytype,replydata = d.appclient.call( " amarok " , " collection " , " %s () " % f uncname, " " ) ' ,
' print " %s : %s " % ( funcname, dataToList(replydata,[ " int " ])[0] )' ,
' print ( " %s : %s " % ( funcname, dataToList(replydata,[ " int " ])[0] ) )' ,
)
)
class KopeteContacts :
class KopeteContacts :
@ -705,11 +705,11 @@ class Samples:
' d = dcopext.DCOPApp(app, dcopclient) ' ,
' d = dcopext.DCOPApp(app, dcopclient) ' ,
' ' ,
' ' ,
' (state,rtype,rdata) = d.appclient.call( " kopete " , " KopeteIface " , " contacts() " , " " ) ' ,
' (state,rtype,rdata) = d.appclient.call( " kopete " , " KopeteIface " , " contacts() " , " " ) ' ,
' if not state: raise " Failed to call the kopete contacts-function " ' ,
' if not state: raise Exception( " Failed to call the kopete contacts-function " ) ' ,
' ' ,
' ' ,
' ds = qt.TQDataStream(rdata.data(), qt.IO_ReadOnly) ' ,
' ds = qt.TQDataStream(rdata.data(), qt.IO_ReadOnly) ' ,
' sl = tdecore.dcop_next (ds, TQSTRINGLIST_OBJECT_NAME_STRING) ' ,
' sl = tdecore.dcop_next (ds, TQSTRINGLIST_OBJECT_NAME_STRING) ' ,
' print " contacts= %s " % [ str(s) for s in sl ] ' ,
' print ( " contacts= %s " % [ str(s) for s in sl ] ) ' ,
)
)
class KWordSelectedText :
class KWordSelectedText :
@ -740,26 +740,26 @@ class Samples:
' # Get the KWord DCOP client. ' ,
' # Get the KWord DCOP client. ' ,
' dcopclient = tdecore.TDEApplication.dcopClient() ' ,
' dcopclient = tdecore.TDEApplication.dcopClient() ' ,
' apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith( " kword " ) ] ' ,
' apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith( " kword " ) ] ' ,
' if len(apps) < 1: raise " No KWord instance is running. Please start KWord before! " ' ,
' if len(apps) < 1: raise Exception( " No KWord instance is running. Please start KWord before! " ) ' ,
' appname = apps[0] ' ,
' appname = apps[0] ' ,
' d = dcopext.DCOPApp(appname, dcopclient) ' ,
' d = dcopext.DCOPApp(appname, dcopclient) ' ,
' ' ,
' ' ,
' # Call the getDocuments() function. ' ,
' # Call the getDocuments() function. ' ,
' (state,rtype,rdata) = d.appclient.call(appname, " KoApplicationIface " , " getDocuments() " , " " ) ' ,
' (state,rtype,rdata) = d.appclient.call(appname, " KoApplicationIface " , " getDocuments() " , " " ) ' ,
' if not state: raise " %s : Failed to call getDocuments-function " % a ppname ' ,
' if not state: raise Exception( " %s : Failed to call getDocuments-function " % a ppname ) ' ,
' documents = dataToList(rdata,[ " QValueList<DCOPRef> " ])[0] ' ,
' documents = dataToList(rdata,[ " QValueList<DCOPRef> " ])[0] ' ,
' print " documents= %s " % [ str( doc.obj() ) for doc in documents ] ' ,
' print ( " documents= %s " % [ str( doc.obj() ) for doc in documents ] ) ' ,
' document = documents[0] # Let \' s just take the first document. ' ,
' document = documents[0] # Let \' s just take the first document. ' ,
' ' ,
' ' ,
' # Get the frameset. ' ,
' # Get the frameset. ' ,
' ba = listToData( [ ( " int " ,0) ] ) ' ,
' ba = listToData( [ ( " int " ,0) ] ) ' ,
' (state,rtype,rdata) = d.appclient.call(appname, document.obj(), " textFrameSet(int) " , ba) ' ,
' (state,rtype,rdata) = d.appclient.call(appname, document.obj(), " textFrameSet(int) " , ba) ' ,
' if not state: raise " %s : Failed to call frameSet-function " % a ppname ' ,
' if not state: raise Exception( " %s : Failed to call frameSet-function " % a ppname ) ' ,
' frameset = dataToList( rdata,[ " DCOPRef " ] )[0] # Let \' s just take the first textframe. ' ,
' frameset = dataToList( rdata,[ " DCOPRef " ] )[0] # Let \' s just take the first textframe. ' ,
' ' ,
' ' ,
' # Get the selected text. ' ,
' # Get the selected text. ' ,
' (state,rtype,rdata) = d.appclient.call(appname, frameset.obj(), " selectedText() " , " " ) ' ,
' (state,rtype,rdata) = d.appclient.call(appname, frameset.obj(), " selectedText() " , " " ) ' ,
' print " Selected Text: %s " % d ataToList( rdata,[TQSTRING_OBJECT_NAME_STRING] )[0] ' ,
' print ( " Selected Text: %s " % d ataToList( rdata,[TQSTRING_OBJECT_NAME_STRING] )[0] ) ' ,
)
)
####################################################################################
####################################################################################
@ -815,8 +815,8 @@ class SampleDialog(qt.TQDialog):
def getCode ( self ) :
def getCode ( self ) :
if not hasattr ( self , " code " ) : return None
if not hasattr ( self , " code " ) : return None
code = " \n " . join ( self . code )
code = " \n " . join ( self . code )
for widgetname in self . samplechild . widgets . keys ( ) :
for widgetname in list ( self . samplechild . widgets . keys ( ) ) :
print " .............. %s " % widgetname
print ( " .............. %s " % widgetname )
widget = self . samplechild . widgets [ widgetname ]
widget = self . samplechild . widgets [ widgetname ]
value = widget . value ( )
value = widget . value ( )
if value != None :
if value != None :
@ -991,9 +991,9 @@ class MainDialog(qt.TQDialog):
self . scripttext . append ( code )
self . scripttext . append ( code )
def execCode ( self , function ) :
def execCode ( self , function ) :
import sys , StringIO
import sys , io
codeOut = StringIO . StringIO ( )
codeOut = io . StringIO ( )
codeErr = StringIO . StringIO ( )
codeErr = io . StringIO ( )
sys . stdout = codeOut
sys . stdout = codeOut
sys . stderr = codeErr
sys . stderr = codeErr
@ -1009,7 +1009,7 @@ class MainDialog(qt.TQDialog):
while hasattr ( tb , " tb_next " ) and tb . tb_next :
while hasattr ( tb , " tb_next " ) and tb . tb_next :
tb = tb . tb_next
tb = tb . tb_next
lineno = tb . tb_lineno
lineno = tb . tb_lineno
print " EXCEPTION: lineno= %s " % lineno
print ( " EXCEPTION: lineno= %s " % lineno )
self . scripttext . setCursorPosition ( lineno - 1 , 0 )
self . scripttext . setCursorPosition ( lineno - 1 , 0 )
except :
except :
pass
pass
@ -1019,12 +1019,12 @@ class MainDialog(qt.TQDialog):
s = codeErr . getvalue ( )
s = codeErr . getvalue ( )
if s :
if s :
print " ERROR: \n %s \n " % s
print ( " ERROR: \n %s \n " % s )
self . console . append ( s )
self . console . append ( s )
s = codeOut . getvalue ( )
s = codeOut . getvalue ( )
if s :
if s :
print s
print ( s )
self . console . append ( s )
self . console . append ( s )
codeOut . close ( )
codeOut . close ( )
@ -1042,7 +1042,7 @@ class MainDialog(qt.TQDialog):
self . console . clear ( )
self . console . clear ( )
def doexecute ( self ) :
def doexecute ( self ) :
code = str ( self . scripttext . text ( ) )
code = str ( self . scripttext . text ( ) )
exec code in globals ( ) , locals ( )
exec ( code , globals ( ) , locals ( ) )
self . execCode ( doexecute )
self . execCode ( doexecute )
self . console . append ( " <b>Execution done!</b> " )
self . console . append ( " <b>Execution done!</b> " )
@ -1058,7 +1058,8 @@ class MainDialog(qt.TQDialog):
self . scripttext . setText ( str ( file . read ( ) ) )
self . scripttext . setText ( str ( file . read ( ) ) )
file . close ( )
file . close ( )
__main__ . scripteditorfilename = filename
__main__ . scripteditorfilename = filename
except IOError , ( errno , strerror ) :
except IOError as xxx_todo_changeme :
( errno , strerror ) = xxx_todo_changeme . args
qt . TQMessageBox . critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( filename , strerror ) )
qt . TQMessageBox . critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( filename , strerror ) )
def openFileAs ( self ) :
def openFileAs ( self ) :
@ -1073,7 +1074,8 @@ class MainDialog(qt.TQDialog):
file = open ( __main__ . scripteditorfilename , " w " )
file = open ( __main__ . scripteditorfilename , " w " )
file . write ( str ( self . scripttext . text ( ) ) )
file . write ( str ( self . scripttext . text ( ) ) )
file . close ( )
file . close ( )
except IOError , ( errno , strerror ) :
except IOError as xxx_todo_changeme1 :
( errno , strerror ) = xxx_todo_changeme1 . args
qt . TQMessageBox . critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( __main__ . scripteditorfilename , strerror ) )
qt . TQMessageBox . critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( __main__ . scripteditorfilename , strerror ) )
def saveFileAs ( self ) :
def saveFileAs ( self ) :