summaryrefslogtreecommitdiffstats
path: root/examples3/mdi.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples3/mdi.py')
-rwxr-xr-xexamples3/mdi.py208
1 files changed, 104 insertions, 104 deletions
diff --git a/examples3/mdi.py b/examples3/mdi.py
index 8f1cf93..ca3d33b 100755
--- a/examples3/mdi.py
+++ b/examples3/mdi.py
@@ -77,12 +77,12 @@ fileprint = [
document = [
"12 16 6 1",
-" c #040404",
-". c None",
-"X c white",
-"o c #808304",
-"O c black",
-"+ c #f3f7f3",
+" c #040404",
+". c None",
+"X c white",
+"o c #808304",
+"O c black",
+"+ c #f3f7f3",
" .....",
" XXXXX ....",
" XXXXX X ...",
@@ -115,8 +115,8 @@ filePrintText = \
'''Click this button to print the file you are editing.<br><br>
You can also select the <b>Print</b> command from the <b>File</b> menu.'''
-True=1
-False=0
+#True=1
+#False=0
class ApplicationWindow(TQMainWindow):
def __init__(self):
@@ -132,7 +132,7 @@ class ApplicationWindow(TQMainWindow):
saveIcon = TQPixmap(filesave)
self.fileSave = TQToolButton(TQIconSet(saveIcon),'Save File',TQString.null,self.save,self.fileTools,'save file')
- printIcon = TQPixmap(fileprint)
+ printIcon = TQPixmap(fileprint)
self.filePrint = TQToolButton(TQIconSet(printIcon),'Print File',TQString.null,self.printDoc,self.fileTools,'print file')
TQWhatsThis.whatsThisButton(self.fileTools)
@@ -168,10 +168,10 @@ class ApplicationWindow(TQMainWindow):
self.menuBar().insertSeparator()
self.windows = TQPopupMenu( self )
- self.windows.setCheckable( True )
- self.connect( self.windows, SIGNAL( "aboutToShow()" ),
- self.windowsMenuAboutToShow )
- self.menuBar().insertItem( "&Windows", self.windows )
+ self.windows.setCheckable( True )
+ self.connect( self.windows, SIGNAL( "aboutToShow()" ),
+ self.windowsMenuAboutToShow )
+ self.menuBar().insertItem( "&Windows", self.windows )
self.help = TQPopupMenu(self)
self.menuBar().insertSeparator()
@@ -180,15 +180,15 @@ class ApplicationWindow(TQMainWindow):
self.help.insertItem('&About',self.about,TQt.Key_F1)
self.help.insertItem('About &TQt',self.aboutTQt)
self.help.insertSeparator()
- self.help.insertItem( "What's &This", self, SLOT("whatsThis()"), TQt.SHIFT+TQt.Key_F1)
+ self.help.insertItem( "What's &This", self, SLOT("whatsThis()"), TQt.SHIFT+TQt.Key_F1)
- self.menuBar().insertSeparator()
+ self.menuBar().insertSeparator()
- self.vb = TQVBox( self )
- self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken )
- self.ws = TQWorkspace( self.vb )
- self.ws.setScrollBarsEnabled( True )
- self.setCentralWidget( self.vb )
+ self.vb = TQVBox( self )
+ self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken )
+ self.ws = TQWorkspace( self.vb )
+ self.ws.setScrollBarsEnabled( True )
+ self.setCentralWidget( self.vb )
self.statusBar().message('Ready',2000)
#self.resize(450,600)
@@ -265,90 +265,90 @@ class ApplicationWindow(TQMainWindow):
class MDIWindow( TQMainWindow):
- def __init__(self,parent, name, wflags ):
- TQMainWindow.__init__(self,parent, name, wflags )
- self.mmovie = 0
- self.medit = TQMultiLineEdit( self )
- self.setFocusProxy( self.medit )
- self.setCentralWidget( self.medit );
-
-
- def load(self, fn ):
- self.filename = fn
- self.f=TQFile( self.filename )
- if not self.f.open( IO_ReadOnly ):
- return
-
- if fn.contains(".gif"):
- tmp=TQWidget(self)
- self.setFocusProxy(tmp)
- self.setCentralWidget(tmp)
- self.medit.hide()
- del self.medit
- qm=TQMovie(fn)
- #ifdef Q_WS_QWS // temporary speed-test hack
- #qm->setDisplayWidget(tmp);
- #endif
- tmp.setBackgroundMode(TQWidget.NoBackground)
- tmp.show()
- self.mmovie=qm
- else :
- self.mmovie = 0
- t=TQTextStream(self.f)
- s = t.read()
- self.medit.setText( s )
- self.f.close()
- self.setCaption( self.filename )
- self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 ))
-
- def save(self):
- if self.filename.isEmpty():
- self.saveAs()
- return
- text = self.medit.text()
- output=open(str(self.filename),'w')
- output.write(str(text))
- #emit message( TQString("Could not write to %1").arg(filename), 2000 );
- #return
- output.close()
- self.setCaption(self.filename)
- self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 ))
-
- def saveAs(self):
- fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self )
- if not fn.isEmpty():
- self.filename = fn
- self.save()
- else :
- self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 ))
-
- def printDoc(self,printer):
- Margin = 10
- pageNo = 1
-
- if printer.setup(self):
- self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 ))
- p = TQPainter()
- p.begin(printer)
- p.setFont(self.medit.font())
- yPos = 0
- fm = p.fontMetrics()
- metrics = TQPaintDeviceMetrics(printer)
-
- for i in range(self.medit.numLines()):
- if Margin + yPos > metrics.height() - Margin:
- pageNo = pageNo + 1
- self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 ))
- printer.newPage()
- yPos = 0
-
- p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i))
- yPos = yPos + fm.lineSpacing()
-
- p.end()
- self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 ))
- else:
- self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 ))
+ def __init__(self,parent, name, wflags ):
+ TQMainWindow.__init__(self,parent, name, wflags )
+ self.mmovie = 0
+ self.medit = TQMultiLineEdit( self )
+ self.setFocusProxy( self.medit )
+ self.setCentralWidget( self.medit );
+
+
+ def load(self, fn ):
+ self.filename = fn
+ self.f=TQFile( self.filename )
+ if not self.f.open( IO_ReadOnly ):
+ return
+
+ if fn.contains(".gif"):
+ tmp=TQWidget(self)
+ self.setFocusProxy(tmp)
+ self.setCentralWidget(tmp)
+ self.medit.hide()
+ del self.medit
+ qm=TQMovie(fn)
+ #ifdef Q_WS_QWS // temporary speed-test hack
+ #qm->setDisplayWidget(tmp);
+ #endif
+ tmp.setBackgroundMode(TQWidget.NoBackground)
+ tmp.show()
+ self.mmovie=qm
+ else :
+ self.mmovie = 0
+ t=TQTextStream(self.f)
+ s = t.read()
+ self.medit.setText( s )
+ self.f.close()
+ self.setCaption( self.filename )
+ self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 ))
+
+ def save(self):
+ if self.filename.isEmpty():
+ self.saveAs()
+ return
+ text = self.medit.text()
+ output=open(str(self.filename),'w')
+ output.write(str(text))
+ #emit message( TQString("Could not write to %1").arg(filename), 2000 );
+ #return
+ output.close()
+ self.setCaption(self.filename)
+ self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 ))
+
+ def saveAs(self):
+ fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self )
+ if not fn.isEmpty():
+ self.filename = fn
+ self.save()
+ else :
+ self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 ))
+
+ def printDoc(self,printer):
+ Margin = 10
+ pageNo = 1
+
+ if printer.setup(self):
+ self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 ))
+ p = TQPainter()
+ p.begin(printer)
+ p.setFont(self.medit.font())
+ yPos = 0
+ fm = p.fontMetrics()
+ metrics = TQPaintDeviceMetrics(printer)
+
+ for i in range(self.medit.numLines()):
+ if Margin + yPos > metrics.height() - Margin:
+ pageNo = pageNo + 1
+ self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 ))
+ printer.newPage()
+ yPos = 0
+
+ p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i))
+ yPos = yPos + fm.lineSpacing()
+
+ p.end()
+ self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 ))
+ else:
+ self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 ))
if __name__=='__main__':