I am working on a Pyqt5 soft which can print a text in a qtext edit.
2 qcombobox allows the user to choose the text.
The text displayed in the qtext edit is loaded from json files.
This part of the soft is ok.
For now, i want the user to be able to edit the files ( i need to change style, especially put the text in bold).
I think that the best way to do it is with html, but i can’t manage the balise insertion.
I also face issues by selecting only part of the text.
i don't really understand the cursor/ anchor fonctions and don't have find explicit documentation.
Any one to give me an advice, or even part of the code that can help me ?
thank you in advance !
Related
I've looked at the documentation of Starlette, and can't seem to figure out how to take the content of a text box and link it to a python variable. The plan is to have a user enter text into several text boxes, click a button, and then the information will be used for an SQL query.
I really have no idea how to proceed.
Edit: I think people are misunderstanding. There is no code yet. I don't know how to reference a text box using Starlette.
I'm wondering if there's a way to have an MD text field that is able to format correctly to screenplay format? My goal is to have buttons along the top of an app that select the correct format ie choosing justify and forcing all caps. From what I can see so far this isn't possible with kivy but I'm willing to be corrected if I'm wrong.
Thanks
I am just starting out to use tkinter in Python 3.5 and I don't understand it the best yet but hopefully will over time.
Anyway, what I was asking was how do I create a text box that a user can type into, I know it is possible but don't yet know how to execute this as, as I said at the beginning, I'm just starting out.
If there is any scaffolding code of a box that I could use to that would allow a user to enter text, it would be a great help if you could show it to me.
Also, to interact with this input, would it be the same as python?
I know this is a lot to be asking but any responses are welcome,
Thanks in advance :)
Both of the following links contain code relating to text entry.
http://effbot.org/tkinterbook/entry.htm
http://effbot.org/tkinterbook/text.htm
Entry is a single line box.
Text is a multiple line box and supports text formatting
Edit2: Solved! I have no idea what changed or why, but now even a RichTextCtrl appends reliably. I left the old message below, despite this.
So I'm writing a GUI in python using wxPython. One of the main elements of this GUI is a textbox.
Features I need:
The ability to reliably append text to the end of the textbox.
Prevent user editing the textbox
Vertical Scroll bar
Features I'd like:
User can select text even when more lines are being appended
Text color can be changed
With that in mind I tried to do use the RichTextCtrl provided by wxPython.
However there appears no way to reliably add text to the end of the text box. The AppendText method is not reliable. If I click a location in the textbox while several lines are being appended this way it is likely one or more of the lines will be inserted where-ever I moved the cursor.
Does anyone have any suggestions on how to reliably append text to a RichTextCtrl? I might be able to clear it and replace all of its text with new text every time I want to append something, but I fear the performance hit from this would be severe. If there is a different text control that would be more appropriate for this please suggest it.
Edit: Using a regular TextCtrl appends reliably. Still no luck with a RichTextCtrl.
AppendText works for me on Windows with wxPython 2.9. If you want to prevent the user from editing, you'll need to use the wx.TE_READ_ONLY style flag. To make a vertical scroll bar appear, add the wx.TE_MULTILINE flag too.
The wxPython demo shows how to change text color. Basically you programmatically select a range and set a style / font for that selection. Getting the ability to select text while appending may not be possible. You would probably have to set up some kind of buffer for the appends and append after the user finishes selecting or keep track of what the user is selecting, append and then reselect.
Let me start off by saying that I'm starting this project to get familiar with Python. The project is to parse JSON from Reddit.com every 15 minutes and then display it with Tkinter.
Parsing the JSON text wasn't too difficult, but I'm not sure how display the text. I will need to display two things -- the title of the link and the link -- in a column style view. I was also planning on having two columns side by side to take advantage of the horizontal screen width. I've tried starting out with a Listbox, but that seemed to more be used if you want a selectable list. I just want to display the text and be done with it. Is there a different and more appropriate widget I should be using? I looked into the Entry widget a bit and thought that might be getting closer, but that seemed to only be for storing a single entry.
If you are using a sufficiently modern version of python (2.7, 3....something, I forget) you can use the ttk.Treeview widget which is similar to the listbox but supports multiple columns.
A much simpler choice is to use the text widget. You can insert the text followed by a newline. To line thimgs up in columns just insert a tab, and define an appropriate tab stop.
There are plenty of other options, but those two are arguably the best.
If you haven't dicovered it yet, tkdocs.com has a wealth of information about tkinter.