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

Fixing listctrl (+ TextEditMixin) editor with height -1 in GTK #849

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
2 participants
@tfmoraes

tfmoraes commented May 11, 2018

It's not possible to edit a listctrl cell value, because the editor has height -1. It's possible to see this error in the ListCtrl_edit from wxPython Demo. In the shell it shows this warning message:

(demo.py:8618): Gtk-WARNING **: 15:34:15.183: Negative content height -1 (allocation 1, extents 1x1) while allocating gadget (node entry, owner GtkEntry)

What I'm doing here to fix this error is calculating a text height (using self.editor.GetTextExtent('M')) and using this height values and editor height.

@RobinD42 RobinD42 added this to To do in 4.0.2 May 15, 2018

@RobinD42 RobinD42 changed the base branch from master to wxPy-4.0.x May 17, 2018

@RobinD42 RobinD42 changed the base branch from wxPy-4.0.x to master May 17, 2018

@RobinD42

This comment has been minimized.

Member

RobinD42 commented May 17, 2018

I'm not sure that this is the right fix. The -1 was probably intended to indicate "don't change this value" or perhaps "use the default height", however since it is using the (x,y,width,height) version of SetSize then we may need to tell it how to interpret that -1 with the flags parameter. Please try it with wx.SIZE_USE_EXISTING or wx.SIZE_AUTO flag and see if one of those fixes the problem for you.

The problem with using the text extent here is that it will only give you the height of the 'M' and won't include any internal margins or borders that the textctrl may be using.

If one of the flags above is not helpful then using height = self.editor.GetBestSize().height would probably be better than using the text extent.

@tfmoraes

This comment has been minimized.

tfmoraes commented May 21, 2018

Hi @RobinD42 ,

I've tested with all options you suggested me. I tested using ListCtrl_edit from demo.py. All of them makes GTK show this warning:
(demo.py:5530): Gtk-WARNING **: 12:28:30.138: Negative content height -5 (allocation 1, extents 3x3) while allocating gadget (node entry, owner GtkEntry)

Using height = self.editor.GetBestSize().height the given height is 0

Is there a way of get the internal borders and margins to add them to the GetTextExtent('M')?

Best regards.

@RobinD42 RobinD42 self-assigned this May 30, 2018

@RobinD42 RobinD42 moved this from To do to In progress in 4.0.2 May 30, 2018

@RobinD42

This comment has been minimized.

Member

RobinD42 commented May 31, 2018

Fixed in a86b25b and 6453684

@RobinD42 RobinD42 closed this May 31, 2018

4.0.2 automation moved this from In progress to Done May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment