I’ve just had my first course in programming at the university and for the following three months I have no additional programming classes so I’ve decided to do a small project during this “break”.
What I’m trying to do is a edit-program for a smaller Wiki I used to work on. It’s suppose to make it easier for the users to use things like templates, and also have a wizard to help the user make basic pages. I talked to some older students and they recommended pyqt for the GUI of the software.
Now to the problem, and I feel like this is a really dirty hack:
My solution right now is to use the built in copy and paste commands, the problem is that right now if I just click the button for bold, without marking text, I get:
”’text currently in clipboard”’ and I just want it to add ”’ ”’.
Here’s the (important) code in question, I obviously call addBold when the button/hotkey is pushed.
self.textEdit = QtGui.QTextEdit()
def.addBold(self):
self.textEdit.copy()
self.textEdit.insertPlainText("\'\'\'")
self.textEdit.paste()
self.textEdit.insertPlainText("\'\'\'")
What I’d rather have is code that looks something like:
x=markedText
if not x:
self.textEdit.insertPlainText("\'\'\' \'\'\'")
else:
self.textEdit.insertPlainText("\'\'\'"+x+"\'\'\'")
x = None
So does anyone know how I can assign the marked text to x? Or is there yet another solution that is better?
Sadly I could not find a way without manipulating the clipboard. Hope this helps.