-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Tooltip from tkinterpp #39
Comments
I've glanced over your balloon implementation, and there is a couple of things I don't agree on
Overall, I like:
Proposed changes :
Thoughts ? |
Actually I was making changes while you posted this. I'll elaborate on them. I created three new options. I also think Now, to address your points of critique:
This is part of the padding on the widgets. I am not opposed to making this an option with a default smaller value than it currently is.
It is an option now, whether it should be on by default is something to be considered.
The widget was designed with Windows in mind, and this was the default colour for Win32 tooltips, or something like that. I wouldn't necessarily mind making it less yellow, but for people on crappy screens that might make it look white (actually a screen I have to use on the weekends has that tendency), so I'm not sure whether making it less yellow would actually be a good idea.
Actually Okay, now on to the proposed changes:
This is out of scope of changing a widget, in my opinion. I think this is a good idea, but it has to be implemented at a very basic level. Either all ttkwidgets have to have explicit support for this by using a mixin of some kind, or the base class of all Tk widgets must be modified with a mixin during runtime. Let's first do the widget itself and then see about adding an option to create a widget more easily.
Personally, I find it easier to think in terms of pixels rather than in terms of characters when it comes to the width of widgets, though I can see how doing this in terms of characters could benefit, for example, HiDPI screen users with scaling. The logic for what you want to do might be a bit resource intensive though. As of right now, the |
I agree with most of what you said.
I think in this instance, characters make more sense. textwrap.wrap() expects a width in characters, plus wrapping at pixel values would just be weird.
For the canvas being recreated every time, we can actually cache the tooltips. Reminder : I did make functions to move/copy widgets, so the toplevel having to exist the whole time is a non-issue as there is a workaround. Moving the widget to its parent, not packing it, and moving it back after the toplevel is recreated.
It's not necessary, as I made a function to get the average character width for a font. If we want something clean, we can just use tkinter.font.Font().measure() to have an exact measurement and it's quite fast, especially if the font is cached |
With regards to this commit: Please just use a single branch for a single purpose. Like I said before, I'd like to implement something like the tooltips you imagined, but not in this branch. This branch and issue are just for merging/improving the tooltips that are already available. But as far as I can tell, your copying function actually relies on recreating the widgets using the information from the previous widgets, which is no faster than recreating them using known values. This is not so much about how much code it costs, as how much time. Tkinter is already a bit slow, it will become even more so if all widgets have tooltips and all the tooltips require loops in the function that makes them show up. Wrapping the text before creating the label is the best choice, I think. That way, only when the text and/or width are changed does the text have to be wrapped again. But wrapping by Tkinter is always the fastest way to do it, and the benefits of wrapping by character length seem small to me, non-existent even if it does not provide a benefit in environments with scaling. After all: The library will be used by the developer, and pixels and being able to use a number of pixels might even be beneficial if you want users to be able to change the font size or something like that. I will try to check whether there is an advantage when using DPI scaling on monitors, but until then, I am not sure what road is the right one. |
Yeah sorry. This util actually went along the lines of using this in the tooltip class (hence why it's in that branch). I've forgotten how exactly I was going to use it (silly me, but I'm sure it'll come back to me). Something along the lines of wrapping or setting the toplevel width to the proper size or something. I can remove it if you want.
True, I hadn't thought about it this way.
We can use tkinter's wrapping for now, but in the end, one of the biggest drawback of tkinter is how hard it is to make a clean responsive app, with widgets that place and size properly based on the window size. Having text wrap on character length would increase consistency, and avoid the developer some additionnal overhead code. I'd like you to edit the OP to reflect the changes discussed here, so that we can have a clear direction as to how we should proceed moving forward. These long texts are not the best way to keep track of tasks done and to be done. |
So far :
|
@RedFantom I have the ttkwidgets PPA repository installed under Ubuntu. I use CheckBoxTreeview successfully. Just now I copied the code for
Can you tell me what I need to do? Thanks, |
I don't think this issue belongs to #39, but if I know well, the problem is that the PPA repository is not up to date, and doesn't yet include the hook module. Try to install it with pip. |
@rdbende My python script already has 30 |
Then yes. |
It's kind of complicated to move this to a separate issue now, so I'll just leave it as-is, but this would indeed have been more appropriate in a separate issue. @rdbende is correct, you need to also have the
You can ask, but the PPA is maintained by @j4321 , and she hasn't been very active lately. Maybe she can update it, but I'm not sure. If you want to use Python, it's a good idea to get into the habit of using |
@RedFantom Last night I implemented tooltips with native tkinter code as published here: http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_01.shtml#e387 Then I made a small modification from yellow balloon to reversed foreground/background colors of the widget being hovered over. Now I just need to figure out how to implement hover delay using My apologies for not posting this question in the correct spot! Also for my ignorance of As for Thank you for your time and advice. |
Widget:
CreateToolTip
File:
tkinterpp/tooltip.py
Functionality:
Create a tooltip similar to the
Balloon
widget to provide a tooltip when hovering over a widget.TODO:
Balloon
widgetThe text was updated successfully, but these errors were encountered: