diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /lib/kross/python/scripts/gui.py | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/kross/python/scripts/gui.py')
-rwxr-xr-x | lib/kross/python/scripts/gui.py | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/lib/kross/python/scripts/gui.py b/lib/kross/python/scripts/gui.py index 8891714a..b8edbe9c 100755 --- a/lib/kross/python/scripts/gui.py +++ b/lib/kross/python/scripts/gui.py @@ -43,43 +43,43 @@ class TkDialog: self.widget = mainframe.widget class Widget: - def __init__(self, dialog, parent): + def __init__(self, dialog, tqparent): self.dialog = dialog - self.parent = parent + self.tqparent = tqparent #def setVisible(self, visibled): pass #def setEnabled(self, enabled): pass class Frame(Widget): - def __init__(self, dialog, parent): - #TkDialog.Widget.__init__(self, dialog, parent) + def __init__(self, dialog, tqparent): + #TkDialog.Widget.__init__(self, dialog, tqparent) import Tkinter - self.widget = Tkinter.Frame(parent) + self.widget = Tkinter.Frame(tqparent) self.widget.pack() class Label(Widget): - def __init__(self, dialog, parent, caption): - #TkDialog.Widget.__init__(self, dialog, parent) + def __init__(self, dialog, tqparent, caption): + #TkDialog.Widget.__init__(self, dialog, tqparent) import Tkinter - self.widget = Tkinter.Label(parent, text=caption) + self.widget = Tkinter.Label(tqparent, text=caption) self.widget.pack(side=Tkinter.TOP) class CheckBox(Widget): - def __init__(self, dialog, parent, caption, checked = True): - #TkDialog.Widget.__init__(self, dialog, parent) + def __init__(self, dialog, tqparent, caption, checked = True): + #TkDialog.Widget.__init__(self, dialog, tqparent) import Tkinter self.checkstate = Tkinter.IntVar() self.checkstate.set(checked) - self.widget = Tkinter.Checkbutton(parent, text=caption, variable=self.checkstate) + self.widget = Tkinter.Checkbutton(tqparent, text=caption, variable=self.checkstate) self.widget.pack(side=Tkinter.TOP) def isChecked(self): return self.checkstate.get() class List(Widget): - def __init__(self, dialog, parent, caption, items): - #TkDialog.Widget.__init__(self, dialog, parent) + def __init__(self, dialog, tqparent, caption, items): + #TkDialog.Widget.__init__(self, dialog, tqparent) import Tkinter - listframe = Tkinter.Frame(parent) + listframe = Tkinter.Frame(tqparent) listframe.pack() Tkinter.Label(listframe, text=caption).pack(side=Tkinter.LEFT) @@ -94,10 +94,10 @@ class TkDialog: self.variable.set( self.items[index] ) class Button(Widget): - def __init__(self, dialog, parent, caption, commandmethod): - #TkDialog.Widget.__init__(self, dialog, parent) + def __init__(self, dialog, tqparent, caption, commandmethod): + #TkDialog.Widget.__init__(self, dialog, tqparent) import Tkinter - self.widget = Tkinter.Button(parent, text=caption, command=self.doCommand) + self.widget = Tkinter.Button(tqparent, text=caption, command=self.doCommand) self.commandmethod = commandmethod self.widget.pack(side=Tkinter.LEFT) def doCommand(self): @@ -114,10 +114,10 @@ class TkDialog: #self.dialog.root.destroy() class Edit(Widget): - def __init__(self, dialog, parent, caption, text): - #TkDialog.Widget.__init__(self, dialog, parent) + def __init__(self, dialog, tqparent, caption, text): + #TkDialog.Widget.__init__(self, dialog, tqparent) import Tkinter - self.widget = Tkinter.Frame(parent) + self.widget = Tkinter.Frame(tqparent) self.widget.pack() label = Tkinter.Label(self.widget, text=caption) label.pack(side=Tkinter.LEFT) @@ -129,8 +129,8 @@ class TkDialog: return self.entrytext.get() class FileChooser(Edit): - def __init__(self, dialog, parent, caption, initialfile = None, filetypes = None): - TkDialog.Edit.__init__(self, dialog, parent, caption, initialfile) + def __init__(self, dialog, tqparent, caption, initialfile = None, filetypes = None): + TkDialog.Edit.__init__(self, dialog, tqparent, caption, initialfile) import Tkinter self.initialfile = initialfile @@ -187,27 +187,27 @@ class QtDialog: import qt class Dialog(qt.QDialog): - def __init__(self, parent = None, name = None, modal = 0, fl = 0): - qt.QDialog.__init__(self, parent, name, modal, fl) + def __init__(self, tqparent = None, name = None, modal = 0, fl = 0): + qt.QDialog.__init__(self, tqparent, name, modal, fl) qt.QDialog.accept = self.accept - self.layout = qt.QVBoxLayout(self) - self.layout.setSpacing(6) - self.layout.setMargin(11) + self.tqlayout = qt.QVBoxLayout(self) + self.tqlayout.setSpacing(6) + self.tqlayout.setMargin(11) class Label(qt.QLabel): - def __init__(self, dialog, parent, caption): - qt.QLabel.__init__(self, parent) - self.setText("<qt>%s</qt>" % caption.replace("\n","<br>")) + def __init__(self, dialog, tqparent, caption): + qt.QLabel.__init__(self, tqparent) + self.setText("<qt>%s</qt>" % caption.tqreplace("\n","<br>")) class Frame(qt.QHBox): - def __init__(self, dialog, parent): - qt.QHBox.__init__(self, parent) + def __init__(self, dialog, tqparent): + qt.QHBox.__init__(self, tqparent) self.widget = self self.setSpacing(6) class Edit(qt.QHBox): - def __init__(self, dialog, parent, caption, text): - qt.QHBox.__init__(self, parent) + def __init__(self, dialog, tqparent, caption, text): + qt.QHBox.__init__(self, tqparent) self.setSpacing(6) label = qt.QLabel(caption, self) self.edit = qt.QLineEdit(self) @@ -219,26 +219,26 @@ class QtDialog: class Button(qt.QPushButton): #def __init__(self, *args): - def __init__(self, dialog, parent, caption, commandmethod): + def __init__(self, dialog, tqparent, caption, commandmethod): #apply(qt.QPushButton.__init__, (self,) + args) - qt.QPushButton.__init__(self, parent) + qt.QPushButton.__init__(self, tqparent) self.commandmethod = commandmethod self.setText(caption) qt.QObject.connect(self, qt.SIGNAL("clicked()"), self.commandmethod) class CheckBox(qt.QCheckBox): - def __init__(self, dialog, parent, caption, checked = True): - #TkDialog.Widget.__init__(self, dialog, parent) - qt.QCheckBox.__init__(self, parent) + def __init__(self, dialog, tqparent, caption, checked = True): + #TkDialog.Widget.__init__(self, dialog, tqparent) + qt.QCheckBox.__init__(self, tqparent) self.setText(caption) self.setChecked(checked) #def isChecked(self): # return self.isChecked() class List(qt.QHBox): - def __init__(self, dialog, parent, caption, items): - qt.QHBox.__init__(self, parent) + def __init__(self, dialog, tqparent, caption, items): + qt.QHBox.__init__(self, tqparent) self.setSpacing(6) label = qt.QLabel(caption, self) self.combo = qt.QComboBox(self) @@ -252,9 +252,9 @@ class QtDialog: self.combo.setCurrentItem(index) class FileChooser(qt.QHBox): - def __init__(self, dialog, parent, caption, initialfile = None, filetypes = None): + def __init__(self, dialog, tqparent, caption, initialfile = None, filetypes = None): #apply(qt.QHBox.__init__, (self,) + args) - qt.QHBox.__init__(self, parent) + qt.QHBox.__init__(self, tqparent) self.setMinimumWidth(400) self.initialfile = initialfile @@ -274,29 +274,29 @@ class QtDialog: return self.edit.text() def browseButtonClicked(self): - filtermask = "" + filtertqmask = "" import types if isinstance(self.filetypes, types.TupleType): for ft in self.filetypes: if len(ft) == 1: - filtermask += "%s\n" % (ft[0]) + filtertqmask += "%s\n" % (ft[0]) if len(ft) == 2: - filtermask += "%s|%s (%s)\n" % (ft[1],ft[0],ft[1]) - if filtermask == "": - filtermask = "All files (*.*)" + filtertqmask += "%s|%s (%s)\n" % (ft[1],ft[0],ft[1]) + if filtertqmask == "": + filtertqmask = "All files (*.*)" else: - filtermask = filtermask[:-1] + filtertqmask = filtertqmask[:-1] filename = None try: print "QtDialog.FileChooser.browseButtonClicked() kfile.KFileDialog" # try to use the kfile module included in pykde import kfile - filename = kfile.KFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file") + filename = kfile.KFileDialog.getOpenFileName(self.initialfile, filtertqmask, self, "Save to file") except: print "QtDialog.FileChooser.browseButtonClicked() qt.QFileDialog" # fallback to Qt filedialog - filename = qt.QFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file") + filename = qt.QFileDialog.getOpenFileName(self.initialfile, filtertqmask, self, "Save to file") if filename != None and filename != "": self.edit.setText(filename) @@ -317,13 +317,13 @@ class QtDialog: return True return False - self.app = qt.qApp + self.app = qt.tqApp self.dialog = Dialog(self.app.mainWidget(), "Dialog", 1, qt.Qt.WDestructiveClose) self.dialog.setCaption(title) self.widget = qt.QVBox(self.dialog) self.widget.setSpacing(6) - self.dialog.layout.addWidget(self.widget) + self.dialog.tqlayout.addWidget(self.widget) self.Frame = Frame self.Label = Label @@ -371,26 +371,26 @@ class Dialog: def close(self): self.dialog.close() - def addFrame(self, parentwidget): - return self.dialog.Frame(self.dialog, parentwidget.widget) + def addFrame(self, tqparentwidget): + return self.dialog.Frame(self.dialog, tqparentwidget.widget) - def addLabel(self, parentwidget, caption): - return self.dialog.Label(self.dialog, parentwidget.widget, caption) + def addLabel(self, tqparentwidget, caption): + return self.dialog.Label(self.dialog, tqparentwidget.widget, caption) - def addCheckBox(self, parentwidget, caption, checked = True): - return self.dialog.CheckBox(self.dialog, parentwidget.widget, caption, checked) + def addCheckBox(self, tqparentwidget, caption, checked = True): + return self.dialog.CheckBox(self.dialog, tqparentwidget.widget, caption, checked) - def addButton(self, parentwidget, caption, commandmethod): - return self.dialog.Button(self.dialog, parentwidget.widget, caption, commandmethod) + def addButton(self, tqparentwidget, caption, commandmethod): + return self.dialog.Button(self.dialog, tqparentwidget.widget, caption, commandmethod) - def addEdit(self, parentwidget, caption, text): - return self.dialog.Edit(self.dialog, parentwidget.widget, caption, text) + def addEdit(self, tqparentwidget, caption, text): + return self.dialog.Edit(self.dialog, tqparentwidget.widget, caption, text) - def addFileChooser(self, parentwidget, caption, initialfile = None, filetypes = None): - return self.dialog.FileChooser(self.dialog, parentwidget.widget, caption, initialfile, filetypes) + def addFileChooser(self, tqparentwidget, caption, initialfile = None, filetypes = None): + return self.dialog.FileChooser(self.dialog, tqparentwidget.widget, caption, initialfile, filetypes) - def addList(self, parentwidget, caption, items): - return self.dialog.List(self.dialog, parentwidget.widget, caption, items) + def addList(self, tqparentwidget, caption, items): + return self.dialog.List(self.dialog, tqparentwidget.widget, caption, items) def showMessageBox(self, typename, caption, message): return self.dialog.MessageBox(self.dialog, typename, caption, message) |