import PythonQt.QtGui as pqt from string import replace def remNewline(): selection = q.getSelectedText() lines = selection.splitlines() selNew = "" for line in lines: selNew = "%s %s" % (selNew, line.rstrip('\n')) q.insertText(selNew.lstrip()) #info and render window w = pqt.QWidget() w.setGeometry(200, 50, 200, 100) l = pqt.QGridLayout(w) w.setLayout(l) w.setWindowTitle("Remove Newlines") renderButton = pqt.QPushButton("Remove!", w) text = pqt.QTextBrowser(w) l.addWidget(renderButton, 2, 0) l.addWidget(text, 1, 0) renderButton.connect("clicked()", remNewline) info = """Removes all newlines in the selected text.""" text.setText(info) w.show()
# 04_Using_Qt.py import PythonQt.QtGui as pqt pqt.QMessageBox.information(0, 'Python', 'You have access to all of the Qt toolkit from the API!') w = pqt.QWidget() # Create main widget w.setGeometry(50,50, 250,400) text = pqt.QTextBrowser(w) # and text output display text.setOpenExternalLinks(True) text.show() text.setHtml('<h1>Welcome to the Python API!</h1>Although CsoundQt does not use PySide, most of the <a href="http://qt-project.org/wiki/PySide">PySide Docs</a> will apply!<br>You can use Qt to build interactive interfaces for CsoundQt scripts.') but = pqt.QPushButton("Button", w) but.move(5, 220) # This works but always try to use layouts instead! sli = pqt.QSlider(w) sli.move(100, 220) w.show()