I am going to make the selected text italic in PyQt text editor
Scenario 1
Scenario 2
The images are pretty self explaining.You will probably say then why don't you
just you textEdit.setFontItalic() then actually I am already using that but
textEdit doesn't have overline and strikeout while QTextCharFormat has ton of
properties but it has it's problems
textEdit.setCurrentCharFormat(),setCurrentFont(),setStyleSheet,setFont() but all
cause the same problem as QTextCharFormat
is there a way around this
thanks
Hey guys I have got the answer.
instead of cursor.setCharFormat() use cursor.mergeCharFormat()
Related
When I use from tkinter import * in vscode with atom one dark theme, I get no highlights from tkinter functions, though my code is still working.
In the picture, pack(), Tk(), Label and mainloop() is supposed to be highlighted (I know this, cause they are in the actual atom software).
Is there anyway to fix this?
Thanks!
There is nothing wrong with the code editor nor the theme. Its just how most of the theme works. Which part do you expect to be highlighted? All tkinter widgets(Label,Entry,etc.) are classes, and most themes do not have any highlighting for classes. I don't think much themes would have highlighting on class names and function names as its used very frequently.
"In the picture, pack(), Tk(), Label and mainloop() is supposed to be highlighted. Is there anyway to fix this?"
"Is supposed to be highlighted" is wrong words to use, as most themes does not highlight classes.
What usually has highlighting is, all the keywords and keyword arguments and string, etc. Since these are highlighted in your code, its working perfectly. I don't think there are any "special effects" for tkinter, as any theme for python is same as any theme for tkinter.
One way to get your desired effect, is to use a different theme, that actually will highlight classes (maybe monokai or some material themes?). I personally don't prefer alot of theme around, so something like this is perfect. Or the other way is to make or customize your themes, which can mess up the color if you are not sure what your doing.
I'm going to guess this is a problem on tkinters part and not the color theme but if it works on other themes and not one dark pro you can always try to change the exisiting colors using "yo generator code"
css-tricks does a good job showing how to install it: https://css-tricks.com/creating-a-vs-code-theme/
Altough they go through how to create your own theme. But you can always choose to import an existing theme.
I have a problem in which I update StaticText fairly often(once every second) and every time it updates, it tears the frame. This is very bothersome on Windows but on Linux it never happened. I tried doing TextCtrl Readonly but I get ugly boxes around text I was wondering if there was a better option for updating text in wxPython frequently that wouldn't tear the screen. Thanks in advance!
I wish I understood better what you meant by "tearing" the frame - I don't seem to have problems with changing StaticText values after a window is created (though sometimes it's necessary to call Layout on a Panel or Dialog).
However, if you're really just looking for read-only TextCtrl's without the "ugly boxes" you should use TextCtrl(style = wx.NO_BORDER | wx.TE_READONLY). The combination will give you what you want - what appears to be a StaticText, but that can't be user-edited and doesn't display a border. You'll also be able to select its value (which may or may not be an advantage).
I would like to create a "custom widget" in QtDesigner4 for matplotlib widgets.
I'm familiar with getting matplotlib widgets in QtDesigner3, and I have little problem manually coding the widget in Qt4. I'm not entirely sure how to do this the new way that QtDesigner handles custom widgets.
There appears to be some documentation, but I thought I'd ask if someone else has coded a solution before I attempt to do so myself.
I believe there is a matplotlib widget for qtdesigner4 (for windows) packaged with python(x,y).
I have never used it myself, but I found some discussion on how to use it here.
If you do have any luck with this, it would be great if you considered answering your own question with a detailed walkthrough!
HTH,
There is a solution in chapter 6 of "Matplotlib for Python Developers". Check out the book's supplemental code.
I have TextView with pages of text, but I want to be able to highlight (change the background color) of specific strings in different colors. Is this possible? If so, can anybody point me in the right direction? Thanks
Haven't tried this myself, but TextBuffer.insert_with_tags with a properly configured TextTag looks promising.
If the specific strings are always the same, as in a programming language, then use GtkSourceView instead.
I have made a pygame physics simulation--'a projectile motion' but it lacks interactivity like accepting angle of launch,speed etc. I am wanting to add input boxes with increase decrease arrows but don't know how to go about it. Thanks for the help.
Maybe you can try PGU (Phil's pyGame Utilities).
In addition to other tools, it has a library for creating GUIs.
This PGU demo shows probably something similar to that you are looking for:
Try Some of these:
http://wiki.wxpython.org/IntegratingPyGame
http://www.pygame.org/project-Pygame+embedded+in+wxPython-1580-2788.html
Good luck!
I don't think trying to add wx-Elements is a very pygame way of implementing a GUI, a better (in sense of portable) way would be to use some all-in-python-GUI-extention for pygame. But the issue of GUI in pygame is anoying, since I could not find any library that offeres such a thing.
I know of two interesting approches, first there is Albow (a little bit of widgetry for pygame), which has a nice implementation of styles. The newest Version (which is not very new, I'm afraid) can be found at http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/
Then there is OcempGUI http://ocemp.sourceforge.net/gui.html -- which has documentation and an some good concepts of event handling.
The sad thing is, both projects seem to be dead. I know of no other pygame-GUI that is worth looking at (correct my on that one, please!). For my own project I started to build something inspired by both of them (just don't expect that to ever become useable), since I'm not really content with either of the two. But they might by just the thing if you don't want to put too much time into it and want to have a good collection of GUI elements from labels and buttons up to file browsing dialogs or scrollable text fields.