@ -14,30 +14,30 @@ Dual-licensed under LGPL v2+higher and the BSD license.
import os , sys
try :
import qt
from TQt import qt
except ( ImportError ) :
raise " Failed to import the required Py Qt python module."
raise " Failed to import the required Py T Qt python module."
####################################################################################
# Samples.
class Widget ( qt . QHBox) :
class Widget ( qt . T QHBox) :
def __init__ ( self , parentwidget , label = None ) :
self . parentwidget = parentwidget
import qt
qt . QHBox. __init__ ( self , parentwidget )
from TQt import qt
qt . T QHBox. __init__ ( self , parentwidget )
self . setMargin ( 4 )
self . setSpacing ( 4 )
if label != None : qt . QLabel( label , self )
if label != None : qt . T QLabel( label , self )
def value ( self ) :
return None
class ListWidget ( Widget ) :
def __init__ ( self , parentwidget , label ) :
import qt
from TQt import qt
global Widget
Widget . __init__ ( self , parentwidget , label )
self . combo = qt . QComboBox( self )
self . combo = qt . T QComboBox( self )
self . combo . setEditable ( True )
self . setStretchFactor ( self . combo , 1 )
def value ( self ) :
@ -45,10 +45,10 @@ class ListWidget(Widget):
class EditWidget ( Widget ) :
def __init__ ( self , parentwidget , label ) :
import qt
from TQt import qt
global Widget
Widget . __init__ ( self , parentwidget , label )
self . edit = qt . QLineEdit( self )
self . edit = qt . T QLineEdit( self )
self . setStretchFactor ( self . edit , 1 )
def value ( self ) :
return self . edit . text ( )
@ -57,20 +57,20 @@ class FileWidget(Widget):
def __init__ ( self , parentwidget , label , filtermask , openfiledialog = True ) :
self . filtermask = filtermask
self . openfiledialog = openfiledialog
import qt
from TQt import qt
global Widget
Widget . __init__ ( self , parentwidget , label )
self . edit = qt . QLineEdit( self )
self . edit = qt . T QLineEdit( self )
self . setStretchFactor ( self . edit , 1 )
btn = qt . QPushButton( " ... " , self )
qt . QObject. connect ( btn , qt . SIGNAL ( " clicked() " ) , self . btnClicked )
btn = qt . T QPushButton( " ... " , self )
qt . T QObject. connect ( btn , qt . SIGNAL ( " clicked() " ) , self . btnClicked )
def btnClicked ( self ) :
import qt
from TQt import qt
text = str ( self . edit . text ( ) )
if self . openfiledialog :
filename = str ( qt . QFileDialog. getOpenFileName ( text , self . filtermask , self . parentwidget ) )
filename = str ( qt . T QFileDialog. getOpenFileName ( text , self . filtermask , self . parentwidget ) )
else :
filename = qt . QFileDialog. getSaveFileName ( text , self . filtermask , self . parentwidget )
filename = qt . T QFileDialog. getSaveFileName ( text , self . filtermask , self . parentwidget )
if filename != " " : self . edit . setText ( filename )
def value ( self ) :
return self . edit . text ( )
@ -383,8 +383,8 @@ class Samples:
}
def getCode ( self ) :
return (
' # Import the Py Qt module.' ,
' import qt' ,
' # Import the Py T Qt module.' ,
' from TQt import qt' ,
' ' ,
' def loadFile(filename): ' ,
' # Import the krosskspreadcore module. ' ,
@ -395,7 +395,7 @@ class Samples:
' xml = file.read() ' ,
' file.close() ' ,
' except IOError, (errno, strerror): ' ,
' qt. QMessageBox.critical(self," Error " , " <qt>Failed to read file %s <br><br> %s </qt> " % (filename,strerror)) ' ,
' qt. T QMessageBox.critical(self," Error " , " <qt>Failed to read file %s <br><br> %s </qt> " % (filename,strerror)) ' ,
' return ' ,
' ' ,
' # Get the current document. ' ,
@ -405,7 +405,7 @@ class Samples:
' ' ,
' # Show the openfile dialog ' ,
' filename = " {FileName} " ' ,
' openfilename = qt. QFileDialog.getOpenFileName(filename," *.xml;;* " , self) ' ,
' openfilename = qt. T QFileDialog.getOpenFileName(filename," *.xml;;* " , self) ' ,
' if str(openfilename) != " " : ' ,
' loadFile( openfilename ) ' ,
)
@ -420,8 +420,8 @@ class Samples:
}
def getCode ( self ) :
return (
' # Import the Py Qt module.' ,
' import qt' ,
' # Import the Py T Qt module.' ,
' from TQt import qt' ,
' ' ,
' def saveFile(filename): ' ,
' # Import the krosskspreadcore module. ' ,
@ -430,7 +430,7 @@ class Samples:
' try: ' ,
' file = open(filename, " w " ) ' ,
' except IOError, (errno, strerror): ' ,
' qt. QMessageBox.critical(self," Error " , " <qt>Failed to create file %s <br><br> %s </qt> " % (filename,strerror)) ' ,
' qt. T QMessageBox.critical(self," Error " , " <qt>Failed to create file %s <br><br> %s </qt> " % (filename,strerror)) ' ,
' return ' ,
' # Get the current document. ' ,
' document = krosskspreadcore.get( " KSpreadDocument " ) ' ,
@ -443,7 +443,7 @@ class Samples:
' ' ,
' # Show the savefile dialog ' ,
' filename = " {FileName} " ' ,
' savefilename = qt. QFileDialog.getSaveFileName(filename," *.xml;;* " , self) ' ,
' savefilename = qt. T QFileDialog.getSaveFileName(filename," *.xml;;* " , self) ' ,
' if str(savefilename) != " " : ' ,
' saveFile( savefilename ) ' ,
)
@ -554,9 +554,9 @@ class Samples:
####################################################################################
# Py Qt
# Py T Qt
class Py Qt:
class Py T Qt:
def __init__ ( self , parentwidget ) :
self . parentwidget = parentwidget
@ -570,8 +570,8 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt' ,
' openfilename = qt. QFileDialog.getOpenFileName(" {FileName} " , " *.txt *.html;;* " , self) ' ,
' from TQt import qt' ,
' openfilename = qt. T QFileDialog.getOpenFileName(" {FileName} " , " *.txt *.html;;* " , self) ' ,
' print " openfile= %s " % o penfilename ' ,
)
@ -585,8 +585,8 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt' ,
' savefilename = qt. QFileDialog.getSaveFileName(" {FileName} " , " *.txt *.html;;* " , self) ' ,
' from TQt import qt' ,
' savefilename = qt. T QFileDialog.getSaveFileName(" {FileName} " , " *.txt *.html;;* " , self) ' ,
' print " savefile= %s " % s avefilename ' ,
)
@ -599,18 +599,18 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt' ,
' from TQt import qt' ,
' ' ,
' class MyDialog(qt. QDialog):' ,
' class MyDialog(qt. T QDialog):' ,
' def __init__(self, parent): ' ,
' import qt' ,
' qt. QDialog.__init__(self, parent, " MyDialog " , 1, qt. Qt.WDestructiveClose)' ,
' from TQt import qt' ,
' qt. T QDialog.__init__(self, parent, " MyDialog " , 1, qt. T Qt.WDestructiveClose)' ,
' self.setCaption( " My Dialog " ) ' ,
' btn = qt. QPushButton(" Click me " ,self) ' ,
' qt. QObject.connect(btn, qt.SIGNAL(" clicked() " ), self.buttonClicked) ' ,
' btn = qt. T QPushButton(" Click me " ,self) ' ,
' qt. T QObject.connect(btn, qt.SIGNAL(" clicked() " ), self.buttonClicked) ' ,
' def buttonClicked(self): ' ,
' import qt' ,
' qt. QMessageBox.information(self, " The Caption " , " This is the message string. " ) ' ,
' from TQt import qt' ,
' qt. T QMessageBox.information(self, " The Caption " , " This is the message string. " ) ' ,
' ' ,
' dialog = MyDialog(self) ' ,
' dialog.exec_loop() ' ,
@ -627,9 +627,9 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt' ,
' from TQt import qt' ,
' ' ,
' text, ok = qt. QInputDialog.getText(" {Caption} " , " {Message} " , qt. QLineEdit.Normal, " " ) ' ,
' text, ok = qt. T QInputDialog.getText(" {Caption} " , " {Message} " , qt. T QLineEdit.Normal, " " ) ' ,
' if ok: ' ,
' print " Text defined: %s " % text ' ,
' else: ' ,
@ -651,12 +651,13 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt, tdecore, dcop, dcopext ' ,
' from TQt import qt ' ,
' import tdecore, dcop, dcopext ' ,
' dcopclient = tdecore.TDEApplication.dcopClient() ' ,
' apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith( " klipper " ) ] ' ,
' d = dcopext.DCOPApp(apps[0], dcopclient) ' ,
' result,typename,data = d.appclient.call(apps[0], " klipper " , " getClipboardContents() " , " " ) ' ,
' ds = qt. QDataStream(data, qt.IO_ReadOnly)' ,
' ds = qt. T QDataStream(data, qt.IO_ReadOnly)' ,
' print " Clipboard content: \\ n %s " % tdecore.dcop_next(ds, TQSTRING_OBJECT_NAME_STRING) ' ,
)
@ -668,7 +669,8 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt, tdecore, dcop, dcopext ' ,
' from TQt import qt ' ,
' import tdecore, dcop, dcopext ' ,
' ' ,
' dcopclient = tdecore.TDEApplication.dcopClient() ' ,
' apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith( " amarok " ) ] ' ,
@ -676,8 +678,9 @@ class Samples:
' d = dcopext.DCOPApp(app, dcopclient) ' ,
' ' ,
' def dataToList(data, types = []): ' ,
' import qt, tdecore ' ,
' ds = qt.QDataStream(data, qt.IO_ReadOnly) ' ,
' from TQt import qt ' ,
' import tdecore ' ,
' ds = qt.TQDataStream(data, qt.IO_ReadOnly) ' ,
' return [ tdecore.dcop_next(ds, t) for t in types ] ' ,
' ' ,
' for funcname in [ " totalAlbums " , " totalArtists " , " totalCompilations " , " totalGenres " , " totalTracks " ]: ' ,
@ -693,7 +696,8 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt, tdecore, dcop, dcopext ' ,
' from TQt import qt ' ,
' import tdecore, dcop, dcopext ' ,
' ' ,
' dcopclient = tdecore.TDEApplication.dcopClient() ' ,
' apps = [ app for app in dcopclient.registeredApplications() if str(app).startswith( " kopete " ) ] ' ,
@ -703,7 +707,7 @@ class Samples:
' (state,rtype,rdata) = d.appclient.call( " kopete " , " KopeteIface " , " contacts() " , " " ) ' ,
' if not state: raise " Failed to call the kopete contacts-function " ' ,
' ' ,
' ds = qt. QDataStream(rdata.data(), qt.IO_ReadOnly)' ,
' ds = qt. T QDataStream(rdata.data(), qt.IO_ReadOnly)' ,
' sl = tdecore.dcop_next (ds, TQSTRINGLIST_OBJECT_NAME_STRING) ' ,
' print " contacts= %s " % [ str(s) for s in sl ] ' ,
)
@ -716,16 +720,19 @@ class Samples:
}
def getCode ( self ) :
return (
' import qt, tdecore, dcop, dcopext ' ,
' from TQt import qt ' ,
' import tdecore, dcop, dcopext ' ,
' ' ,
' def dataToList(data, types = []): ' ,
' import qt, tdecore ' ,
' ds = qt.QDataStream(data, qt.IO_ReadOnly) ' ,
' from TQt import qt ' ,
' import tdecore ' ,
' ds = qt.TQDataStream(data, qt.IO_ReadOnly) ' ,
' return [ tdecore.dcop_next(ds, t) for t in types ] ' ,
' def listToData(listdict): ' ,
' import qt, tdecore ' ,
' ba= qt.QByteArray() ' ,
' ds = qt.QDataStream(ba, qt.IO_WriteOnly) ' ,
' from TQt import qt ' ,
' import tdecore ' ,
' ba= qt.TQByteArray() ' ,
' ds = qt.TQDataStream(ba, qt.IO_WriteOnly) ' ,
' for (typename,value) in listdict: ' ,
' tdecore.dcop_add (ds, value, typename) ' ,
' return ba ' ,
@ -758,48 +765,48 @@ class Samples:
####################################################################################
# Dialog implementations.
class SampleDialog ( qt . QDialog) :
class SampleDialog ( qt . T QDialog) :
def __init__ ( self , parent , sampleclazz , samplechildclazz ) :
import qt
qt . QDialog. __init__ ( self , parent , " SampleDialog " , 1 )
from TQt import qt
qt . T QDialog. __init__ ( self , parent , " SampleDialog " , 1 )
layout = qt . QVBoxLayout( self )
box = qt . QVBox( self )
layout = qt . T QVBoxLayout( self )
box = qt . T QVBox( self )
box . setMargin ( 4 )
box . setSpacing ( 10 )
layout . addWidget ( box )
self . scrollview = qt . QScrollView( box )
self . scrollview . setResizePolicy ( qt . QScrollView. AutoOne )
#self.scrollview.setFrameStyle(qt. QFrame.NoFrame);
self . scrollview . setResizePolicy ( qt . QScrollView. AutoOneFit ) ;
self . scrollview = qt . T QScrollView( box )
self . scrollview . setResizePolicy ( qt . T QScrollView. AutoOne )
#self.scrollview.setFrameStyle(qt. T QFrame.NoFrame);
self . scrollview . setResizePolicy ( qt . T QScrollView. AutoOneFit ) ;
self . scrollview . viewport ( ) . setPaletteBackgroundColor ( self . paletteBackgroundColor ( ) )
mainbox = qt . QVBox( self . scrollview . viewport ( ) )
mainbox = qt . T QVBox( self . scrollview . viewport ( ) )
mainbox . setMargin ( 6 )
mainbox . setSpacing ( 6 )
desclabel = qt . QLabel( mainbox )
qt . QFrame( mainbox ) . setFrameStyle ( qt . QFrame. HLine | qt . QFrame. Sunken )
desclabel = qt . T QLabel( mainbox )
qt . T QFrame( mainbox ) . setFrameStyle ( qt . T QFrame. HLine | qt . T QFrame. Sunken )
self . sample = sampleclazz ( mainbox )
self . samplechild = samplechildclazz ( self . sample )
desclabel . setText ( " <qt> %s </qt> " % self . samplechild . __doc__ )
mainbox . setStretchFactor ( qt . QWidget( mainbox ) , 1 )
mainbox . setStretchFactor ( qt . T QWidget( mainbox ) , 1 )
mainbox . show ( )
self . scrollview . addChild ( mainbox )
btnbox = qt . QHBox( box )
btnbox = qt . T QHBox( box )
btnbox . setMargin ( 6 )
btnbox . setSpacing ( 6 )
okbtn = qt . QPushButton( btnbox )
okbtn = qt . T QPushButton( btnbox )
okbtn . setText ( " Ok " )
qt . QObject. connect ( okbtn , qt . SIGNAL ( " clicked() " ) , self . okClicked )
cancelbtn = qt . QPushButton( btnbox )
qt . T QObject. connect ( okbtn , qt . SIGNAL ( " clicked() " ) , self . okClicked )
cancelbtn = qt . T QPushButton( btnbox )
cancelbtn . setText ( " Cancel " )
qt . QObject. connect ( cancelbtn , qt . SIGNAL ( " clicked() " ) , self . close )
qt . T QObject. connect ( cancelbtn , qt . SIGNAL ( " clicked() " ) , self . close )
self . setCaption ( self . samplechild . name )
box . setMinimumSize ( qt . QSize( 500 , 340 ) )
box . setMinimumSize ( qt . T QSize( 500 , 340 ) )
def okClicked ( self ) :
self . code = self . samplechild . getCode ( )
@ -816,7 +823,7 @@ class SampleDialog(qt.QDialog):
code = code . replace ( " { %s } " % widgetname , str ( value ) )
return code
class MainDialog ( qt . QDialog) :
class MainDialog ( qt . T QDialog) :
def __init__ ( self , scriptpath , parent ) :
self . scriptpath = scriptpath
if not hasattr ( __main__ , " scripteditorfilename " ) :
@ -825,118 +832,119 @@ class MainDialog(qt.QDialog):
import krosskspreadcore
self . doc = krosskspreadcore . get ( " KSpreadDocument " )
import os , qt
qt . QDialog . __init__ ( self , parent , " MainDialog " , 1 , qt . Qt . WDestructiveClose )
import os
from TQt import qt
qt . TQDialog . __init__ ( self , parent , " MainDialog " , 1 , qt . TQt . WDestructiveClose )
self . setCaption ( " Script Editor " )
layout = qt . QVBoxLayout( self )
box = qt . QVBox( self )
layout = qt . T QVBoxLayout( self )
box = qt . T QVBox( self )
box . setMargin ( 4 )
box . setSpacing ( 10 )
layout . addWidget ( box )
menu = qt . QMenuBar( box )
menu = qt . T QMenuBar( box )
splitter = qt . QSplitter( box )
splitter . setOrientation ( qt . Qt. Vertical )
splitter = qt . T QSplitter( box )
splitter . setOrientation ( qt . T Qt. Vertical )
self . scripttext = qt . QMultiLineEdit( splitter )
self . scripttext . setWordWrap ( qt . QTextEdit. NoWrap )
self . scripttext . setTextFormat ( qt . Qt. PlainText )
qt . QObject. connect ( self . scripttext , qt . SIGNAL ( " cursorPositionChanged(int,int) " ) , self . cursorPositionChanged )
self . scripttext = qt . T QMultiLineEdit( splitter )
self . scripttext . setWordWrap ( qt . T QTextEdit. NoWrap )
self . scripttext . setTextFormat ( qt . T Qt. PlainText )
qt . T QObject. connect ( self . scripttext , qt . SIGNAL ( " cursorPositionChanged(int,int) " ) , self . cursorPositionChanged )
self . console = qt . QTextBrowser( splitter )
splitter . setResizeMode ( self . console , qt . QSplitter. KeepSize )
self . console = qt . T QTextBrowser( splitter )
splitter . setResizeMode ( self . console , qt . T QSplitter. KeepSize )
statusbar = qt . QStatusBar( box )
self . messagestatus = qt . QLabel( statusbar )
statusbar = qt . T QStatusBar( box )
self . messagestatus = qt . T QLabel( statusbar )
statusbar . addWidget ( self . messagestatus , 1 )
self . cursorstatus = qt . QLabel( statusbar )
self . cursorstatus = qt . T QLabel( statusbar )
statusbar . addWidget ( self . cursorstatus )
self . cursorPositionChanged ( )
box . setMinimumSize ( qt . QSize( 680 , 540 ) )
box . setMinimumSize ( qt . T QSize( 680 , 540 ) )
filemenu = qt . QPopupMenu( menu )
filemenu = qt . T QPopupMenu( menu )
menu . insertItem ( " &File " , filemenu )
newaction = qt . QAction( " New " , qt . QKeySequence( " CTRL+N " ) , self )
qt . QObject. connect ( newaction , qt . SIGNAL ( " activated() " ) , self . newFile )
newaction = qt . T QAction( " New " , qt . T QKeySequence( " CTRL+N " ) , self )
qt . T QObject. connect ( newaction , qt . SIGNAL ( " activated() " ) , self . newFile )
newaction . addTo ( filemenu )
openaction = qt . QAction( " Open... " , qt . QKeySequence( " CTRL+O " ) , self )
qt . QObject. connect ( openaction , qt . SIGNAL ( " activated() " ) , self . openFileAs )
openaction = qt . T QAction( " Open... " , qt . T QKeySequence( " CTRL+O " ) , self )
qt . T QObject. connect ( openaction , qt . SIGNAL ( " activated() " ) , self . openFileAs )
openaction . addTo ( filemenu )
saveaction = qt . QAction( " Save " , qt . QKeySequence( " CTRL+S " ) , self )
qt . QObject. connect ( saveaction , qt . SIGNAL ( " activated() " ) , self . saveFile )
saveaction = qt . T QAction( " Save " , qt . T QKeySequence( " CTRL+S " ) , self )
qt . T QObject. connect ( saveaction , qt . SIGNAL ( " activated() " ) , self . saveFile )
saveaction . addTo ( filemenu )
saveasaction = qt . QAction( " Save as... " , qt . QKeySequence( " CTRL+A " ) , self )
qt . QObject. connect ( saveasaction , qt . SIGNAL ( " activated() " ) , self . saveFileAs )
saveasaction = qt . T QAction( " Save as... " , qt . T QKeySequence( " CTRL+A " ) , self )
qt . T QObject. connect ( saveasaction , qt . SIGNAL ( " activated() " ) , self . saveFileAs )
saveasaction . addTo ( filemenu )
filemenu . insertSeparator ( )
quitaction = qt . QAction( " Quit " , qt . QKeySequence( " CTRL+Q " ) , self )
qt . QObject. connect ( quitaction , qt . SIGNAL ( " activated() " ) , self . close )
quitaction = qt . T QAction( " Quit " , qt . T QKeySequence( " CTRL+Q " ) , self )
qt . T QObject. connect ( quitaction , qt . SIGNAL ( " activated() " ) , self . close )
quitaction . addTo ( filemenu )
editmenu = qt . QPopupMenu( menu )
editmenu = qt . T QPopupMenu( menu )
menu . insertItem ( " &Edit " , editmenu )
undoaction = qt . QAction( " Undo " , qt . QKeySequence( " CTRL+Z " ) , self )
qt . QObject. connect ( undoaction , qt . SIGNAL ( " activated() " ) , self . scripttext . undo )
undoaction = qt . T QAction( " Undo " , qt . T QKeySequence( " CTRL+Z " ) , self )
qt . T QObject. connect ( undoaction , qt . SIGNAL ( " activated() " ) , self . scripttext . undo )
undoaction . addTo ( editmenu )
redoaction = qt . QAction( " Redo " , qt . QKeySequence( " CTRL+Shift+Z " ) , self )
qt . QObject. connect ( redoaction , qt . SIGNAL ( " activated() " ) , self . scripttext . redo )
redoaction = qt . T QAction( " Redo " , qt . T QKeySequence( " CTRL+Shift+Z " ) , self )
qt . T QObject. connect ( redoaction , qt . SIGNAL ( " activated() " ) , self . scripttext . redo )
redoaction . addTo ( editmenu )
editmenu . insertSeparator ( )
cutaction = qt . QAction( " Cut " , qt . QKeySequence( " CTRL+X " ) , self )
qt . QObject. connect ( cutaction , qt . SIGNAL ( " activated() " ) , self . scripttext . cut )
cutaction = qt . T QAction( " Cut " , qt . T QKeySequence( " CTRL+X " ) , self )
qt . T QObject. connect ( cutaction , qt . SIGNAL ( " activated() " ) , self . scripttext . cut )
cutaction . addTo ( editmenu )
copyaction = qt . QAction( " Copy " , qt . QKeySequence( " CTRL+C " ) , self )
qt . QObject. connect ( copyaction , qt . SIGNAL ( " activated() " ) , self . scripttext . copy )
copyaction = qt . T QAction( " Copy " , qt . T QKeySequence( " CTRL+C " ) , self )
qt . T QObject. connect ( copyaction , qt . SIGNAL ( " activated() " ) , self . scripttext . copy )
copyaction . addTo ( editmenu )
pasteaction = qt . QAction( " Paste " , qt . QKeySequence( " CTRL+V " ) , self )
qt . QObject. connect ( pasteaction , qt . SIGNAL ( " activated() " ) , self . scripttext . paste )
pasteaction = qt . T QAction( " Paste " , qt . T QKeySequence( " CTRL+V " ) , self )
qt . T QObject. connect ( pasteaction , qt . SIGNAL ( " activated() " ) , self . scripttext . paste )
pasteaction . addTo ( editmenu )
clearaction = qt . QAction( " Clear " , qt . QKeySequence( " CTRL+Shift+X " ) , self )
qt . QObject. connect ( clearaction , qt . SIGNAL ( " activated() " ) , self . scripttext . clear )
clearaction = qt . T QAction( " Clear " , qt . T QKeySequence( " CTRL+Shift+X " ) , self )
qt . T QObject. connect ( clearaction , qt . SIGNAL ( " activated() " ) , self . scripttext . clear )
clearaction . addTo ( editmenu )
editmenu . insertSeparator ( )
selallaction = qt . QAction( " Select All " , 0 , self )
qt . QObject. connect ( selallaction , qt . SIGNAL ( " activated() " ) , self . scripttext . selectAll )
selallaction = qt . T QAction( " Select All " , 0 , self )
qt . T QObject. connect ( selallaction , qt . SIGNAL ( " activated() " ) , self . scripttext . selectAll )
selallaction . addTo ( editmenu )
scriptmenu = qt . QPopupMenu( menu )
scriptmenu = qt . T QPopupMenu( menu )
menu . insertItem ( " &Script " , scriptmenu )
compileaction = qt . QAction( " Compile " , qt . QKeySequence( " F9 " ) , self )
qt . QObject. connect ( compileaction , qt . SIGNAL ( " activated() " ) , self . compileScript )
compileaction = qt . T QAction( " Compile " , qt . T QKeySequence( " F9 " ) , self )
qt . T QObject. connect ( compileaction , qt . SIGNAL ( " activated() " ) , self . compileScript )
compileaction . addTo ( scriptmenu )
executeaction = qt . QAction( " Execute " , qt . QKeySequence( " F10 " ) , self )
qt . QObject. connect ( executeaction , qt . SIGNAL ( " activated() " ) , self . executeScript )
executeaction = qt . T QAction( " Execute " , qt . T QKeySequence( " F10 " ) , self )
qt . T QObject. connect ( executeaction , qt . SIGNAL ( " activated() " ) , self . executeScript )
executeaction . addTo ( scriptmenu )
self . samplemenu = qt . QPopupMenu( menu )
self . samplemenu = qt . T QPopupMenu( menu )
menu . insertItem ( " &Samples " , self . samplemenu )
itemid = 500
global Samples
for samplename in dir ( Samples ) :
if samplename . startswith ( " _ " ) : continue
itemid + = 1
menu = qt . QPopupMenu( self . samplemenu )
qt . QObject. connect ( menu , qt . SIGNAL ( " activated(int) " ) , self . sampleActivated )
menu = qt . T QPopupMenu( self . samplemenu )
qt . T QObject. connect ( menu , qt . SIGNAL ( " activated(int) " ) , self . sampleActivated )
self . samplemenu . insertItem ( samplename , menu , - 1 , self . samplemenu . count ( ) - 1 )
attr = getattr ( Samples , samplename )
for a in dir ( attr ) :
@ -1040,7 +1048,7 @@ class MainDialog(qt.QDialog):
def newFile ( self ) :
self . console . clear ( )
#if qt. QMessageBox.warning(self,"Remove?","Remove the selected item?",qt.QMessageBox.Yes,qt.QMessageBox.Cancel) != qt.QMessageBox.Yes:
#if qt. T QMessageBox.warning(self,"Remove?","Remove the selected item?",qt.T QMessageBox.Yes,qt.T QMessageBox.Cancel) != qt.T QMessageBox.Yes:
self . scripttext . clear ( )
def openFile ( self , filename ) :
@ -1051,12 +1059,12 @@ class MainDialog(qt.QDialog):
file . close ( )
__main__ . scripteditorfilename = filename
except IOError , ( errno , strerror ) :
qt . QMessageBox. critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( filename , strerror ) )
qt . T QMessageBox. critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( filename , strerror ) )
def openFileAs ( self ) :
import qt
from TQt import qt
self . console . clear ( )
filename = str ( qt . QFileDialog. getOpenFileName ( __main__ . scripteditorfilename , " *.py;;* " , self ) )
filename = str ( qt . T QFileDialog. getOpenFileName ( __main__ . scripteditorfilename , " *.py;;* " , self ) )
if filename == " " : return
self . openFile ( filename )
@ -1066,11 +1074,11 @@ class MainDialog(qt.QDialog):
file . write ( str ( self . scripttext . text ( ) ) )
file . close ( )
except IOError , ( errno , strerror ) :
qt . QMessageBox. critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( __main__ . scripteditorfilename , strerror ) )
qt . T QMessageBox. critical ( self , " Error " , " <qt>Failed to open script file \" %s \" <br><br> %s </qt> " % ( __main__ . scripteditorfilename , strerror ) )
def saveFileAs ( self ) :
import qt
filename = str ( qt . QFileDialog. getSaveFileName ( __main__ . scripteditorfilename , " *.py;;* " , self ) )
from TQt import qt
filename = str ( qt . T QFileDialog. getSaveFileName ( __main__ . scripteditorfilename , " *.py;;* " , self ) )
if filename == " " : return
__main__ . scripteditorfilename = filename
self . saveFile ( )
@ -1080,7 +1088,7 @@ class MainDialog(qt.QDialog):
if __name__ == " __main__ " :
scriptpath = os . getcwd ( )
qtapp = qt . QApplication( sys . argv )
qtapp = qt . T QApplication( sys . argv )
else :
scriptpath = os . path . dirname ( __name__ )
qtapp = qt . tqApp