| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import PythonQt.QtGui as pqt |
| 7 |
|
| 8 |
def remNewline(): |
| 9 |
selection = q.getSelectedText() |
| 10 |
lines = selection.splitlines() |
| 11 |
selNew = "" |
| 12 |
for line in lines: |
| 13 |
selNew = "%s %s" % (selNew, line.rstrip('\n')) |
| 14 |
q.insertText(selNew.lstrip()) |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
w = pqt.QWidget() |
| 19 |
w.setGeometry(200,50, 200,100) |
| 20 |
l = pqt.QGridLayout(w) |
| 21 |
w.setLayout(l) |
| 22 |
w.setWindowTitle("Remove Newlines") |
| 23 |
|
| 24 |
renderButton = pqt.QPushButton("Remove!",w) |
| 25 |
text = pqt.QTextBrowser(w) |
| 26 |
l.addWidget(renderButton, 2, 0) |
| 27 |
l.addWidget(text, 1, 0) |
| 28 |
renderButton.connect("clicked()", remNewline) |
| 29 |
|
| 30 |
info = """Removes all newlines in the selected text.""" |
| 31 |
text.setText(info) |
| 32 |
|
| 33 |
w.show() |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|