summaryrefslogtreecommitdiffstats
path: root/examples3/qdir.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples3/qdir.py')
-rwxr-xr-xexamples3/qdir.py90
1 files changed, 45 insertions, 45 deletions
diff --git a/examples3/qdir.py b/examples3/qdir.py
index 0da10eb..03cc5c9 100755
--- a/examples3/qdir.py
+++ b/examples3/qdir.py
@@ -57,9 +57,9 @@ home = [
]
-class PixmapView(QScrollView):
+class PixmapView(TQScrollView):
def __init__(self, parent):
- QScrollView.__init__(self, parent)
+ TQScrollView.__init__(self, parent)
self.pixmap = None
self.viewport().setBackgroundMode(self.PaletteBase)
@@ -69,36 +69,36 @@ class PixmapView(QScrollView):
self.viewport().repaint(False)
def drawContents(self, p, cx, cy, cw, ch):
- p.fillRect(cx, cy, cw, ch, self.colorGroup().brush(QColorGroup.Base))
+ p.fillRect(cx, cy, cw, ch, self.colorGroup().brush(TQColorGroup.Base))
p.drawPixmap(0, 0, self.pixmap)
-class Preview(QWidgetStack):
+class Preview(TQWidgetStack):
def __init__(self, parent):
- QWidgetStack.__init__(self, parent)
- self.normalText = QMultiLineEdit(self)
+ TQWidgetStack.__init__(self, parent)
+ self.normalText = TQMultiLineEdit(self)
self.normalText.setReadOnly(True)
- self.html = QTextView(self)
+ self.html = TQTextView(self)
self.pixmap = PixmapView(self)
self.raiseWidget(self.normalText)
def showPreview(self, url, size):
if url.isLocalFile():
path = url.path()
- fi = QFileInfo(path)
+ fi = TQFileInfo(path)
if fi.isFile() and fi.size() > size * 1000:
self.normalText.setText(
"The File\n%s\nis too large, so I don't show it!" % path)
self.raiseWidget(self.normalText)
return
- pix = QPixmap(path)
+ pix = TQPixmap(path)
if pix.isNull():
if fi.isFile():
err = False
try:
text = open(path.latin1(), "r").read()
except IOError, msg:
- text = QString(str(msg))
+ text = TQString(str(msg))
err = True
if not err and fi.extension().lower().contains("htm"):
url = self.html.mimeSourceFactory().makeAbsolute(
@@ -121,28 +121,28 @@ class Preview(QWidgetStack):
self.raiseWidget(self.normalText)
-# We can't instantiate QFilePreview directly because it is abstract. Note that
+# We can't instantiate TQFilePreview directly because it is abstract. Note that
# the previewUrl() abstract is patched in later to work around the fact that
# you can't multiply inherit from more than one wrapped class.
-class FilePreview(QFilePreview):
+class FilePreview(TQFilePreview):
pass
-class PreviewWidget(QVBox):
+class PreviewWidget(TQVBox):
def __init__(self, parent):
- QVBox.__init__(self, parent)
+ TQVBox.__init__(self, parent)
self.setSpacing( 5 )
self.setMargin( 5 )
- row = QHBox(self)
+ row = TQHBox(self)
row.setSpacing(5)
- QLabel("Only show files smaller than: ", row)
- self.sizeSpinBox = QSpinBox(1, 10000, 1, row)
+ TQLabel("Only show files smaller than: ", row)
+ self.sizeSpinBox = TQSpinBox(1, 10000, 1, row)
self.sizeSpinBox.setSuffix(" KB")
self.sizeSpinBox.setValue(128)
row.setFixedHeight(10 + self.sizeSpinBox.sizeHint().height())
self.__preview = Preview(self)
# workaround sip inability of multiple inheritance
- # create a local QFilePreview instance and redirect
+ # create a local TQFilePreview instance and redirect
# the method, which is called on preview, to us
self.preview = FilePreview()
self.preview.previewUrl = self.previewUrl
@@ -151,9 +151,9 @@ class PreviewWidget(QVBox):
self.__preview.showPreview(url, self.sizeSpinBox.value())
-class CustomFileDialog(QFileDialog):
+class CustomFileDialog(TQFileDialog):
def __init__(self, preview = False):
- QFileDialog.__init__(self, None, None, True)
+ TQFileDialog.__init__(self, None, None, True)
self.bookmarkFile = ".pybookmarks"
self.bookmarkList = []
if os.path.exists(self.bookmarkFile):
@@ -169,10 +169,10 @@ class CustomFileDialog(QFileDialog):
root.setOpen(True)
self.dirView.setFixedWidth(200)
self.addLeftWidget(self.dirView)
- p = QPushButton(self)
- p.setPixmap(QPixmap(bookmarks))
- QToolTip.add(p, "Bookmarks")
- self.bookmarkMenu = QPopupMenu(self)
+ p = TQPushButton(self)
+ p.setPixmap(TQPixmap(bookmarks))
+ TQToolTip.add(p, "Bookmarks")
+ self.bookmarkMenu = TQPopupMenu(self)
self.connect(self.bookmarkMenu, SIGNAL("activated(int)"),
self.bookmarkChosen)
self.addId = self.bookmarkMenu.insertItem("Add bookmark")
@@ -181,13 +181,13 @@ class CustomFileDialog(QFileDialog):
self.bookmarkMenu.insertItem(l)
p.setPopup(self.bookmarkMenu)
self.addToolButton(p, True)
- self.connect(self.dirView, PYSIGNAL("folderSelected(const QString &)"),
+ self.connect(self.dirView, PYSIGNAL("folderSelected(const TQString &)"),
self.setDir2)
- self.connect(self, SIGNAL("dirEntered(const QString &)"),
+ self.connect(self, SIGNAL("dirEntered(const TQString &)"),
self.dirView.setDir)
- b = QToolButton(self)
- QToolTip.add(b, "Go Home!")
- b.setPixmap(QPixmap(home))
+ b = TQToolButton(self)
+ TQToolTip.add(b, "Go Home!")
+ b.setPixmap(TQPixmap(home))
self.connect(b, SIGNAL("clicked()"), self.goHome)
self.addToolButton(b)
@@ -195,8 +195,8 @@ class CustomFileDialog(QFileDialog):
self.setContentsPreviewEnabled(True)
pw = PreviewWidget(self)
self.setContentsPreview(pw, pw.preview)
- self.setViewMode(QFileDialog.List)
- self.setPreviewMode(QFileDialog.Contents)
+ self.setViewMode(TQFileDialog.List)
+ self.setPreviewMode(TQFileDialog.Contents)
w = self.width()
h = self.height()
@@ -211,10 +211,10 @@ class CustomFileDialog(QFileDialog):
open(self.bookmarkFile, "wb").write(pickle.dumps(self.bookmarkList))
except IOError, msg:
print msg
- return QFileDialog.done(self, r)
+ return TQFileDialog.done(self, r)
def showEvent(self, e):
- QFileDialog.showEvent(self, e)
+ TQFileDialog.showEvent(self, e)
self.dirView.setDir(self.dirPath())
def setDir2(self, path):
@@ -250,7 +250,7 @@ if __name__ == '__main__':
usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [caption ...]
--any Get any filename, need not exist.
--dir Return a directory rather than a file.
- --custom Opens a customized QFileDialog with
+ --custom Opens a customized TQFileDialog with
dir browser, bookmark menu, etc.
--preview Show a preview widget.
--default f Start from directory/file f.
@@ -261,12 +261,12 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
def main():
options = ["help", "any", "dir", "custom", "preview", "default=", "filter="]
- mode = QFileDialog.ExistingFile
+ mode = TQFileDialog.ExistingFile
preview = False
custom = False
start = None
- filter = QString.null
- app = QApplication(sys.argv)
+ filter = TQString.null
+ app = TQApplication(sys.argv)
try:
optlist, args = getopt.getopt(sys.argv[1:], "h", options)
@@ -277,9 +277,9 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
if opt in ("-h", "--help"):
usage()
elif opt == "--any":
- mode = QFileDialog.AnyFile
+ mode = TQFileDialog.AnyFile
elif opt == "--dir":
- mode = QFileDialog.Directory
+ mode = TQFileDialog.Directory
elif opt == "--default":
start = par
elif opt == "--filter":
@@ -290,27 +290,27 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
custom = True
if args:
caption = " ".join(args)
- elif mode == QFileDialog.Directory:
+ elif mode == TQFileDialog.Directory:
caption = "Choose directory..."
else:
caption = "Choose file..."
if not start:
- start = QDir.currentDirPath()
+ start = TQDir.currentDirPath()
if not custom:
- fd = QFileDialog(QString.null, filter, None, None, True)
+ fd = TQFileDialog(TQString.null, filter, None, None, True)
fd.setMode(mode)
if preview:
fd.setContentsPreviewEnabled(True)
pw = PreviewWidget(fd)
fd.setContentsPreview(pw, pw.preview)
- fd.setViewMode(QFileDialog.List)
- fd.setPreviewMode(QFileDialog.Contents)
+ fd.setViewMode(TQFileDialog.List)
+ fd.setPreviewMode(TQFileDialog.Contents)
w = fd.width()
h = fd.height()
fd.resize(w + w / 3, h + h / 4)
fd.setCaption(caption)
fd.setSelection(start)
- if fd.exec_loop() == QDialog.Accepted:
+ if fd.exec_loop() == TQDialog.Accepted:
print "%s\n" % fd.selectedFile().latin1()
return 0
else: