Hi,
Is there any way to get (or even set) the size of a popup menu? I would like to position it so that it is centered above the cursor.
Thanks,
Max
Hi,
Is there any way to get (or even set) the size of a popup menu? I would like to position it so that it is centered above the cursor.
Thanks,
Max
Hello,
Hi,
Is there any way to get (or even set) the size of a popup menu? I would like to position it so that it is centered above the cursor.
I don’t think that there is a direct way to get the size of a menu since it does not derive from wxWindow. The best that I have found to do in the past is to examine the width of the labels for the menu items to find the longest one and then do some rough calculations to get an approximate width of the menu.
Psuedo code: (self is window that owns the menu)
twidth, theight = self.GetTextExtent(longest_lbl)
twidth += 16 (approximate padding on left and right of label, this varies by platform)
if (using check items or using bitmaps in the menu):
twidth += 16 (checkitem/bmp width)
twidth += 5 (approximate amount of padding between bmp and label)
Cody
On 9/4/08, Max Landaeus max@landaeus.com wrote:
Cody Precord wrote:
Hello,
Hi,
Is there any way to get (or even set) the size of a popup menu? I
would like to position it so that it is centered above the cursor.I don't think that there is a direct way to get the size of a menu since it does not derive from wxWindow. The best that I have found to do in the past is to examine the width of the labels for the menu items to find the longest one and then do some rough calculations to get an approximate width of the menu.
Psuedo code: (self is window that owns the menu)
twidth, theight = self.GetTextExtent(longest_lbl)
twidth += 16 (approximate padding on left and right of label, this varies by platform)
if (using check items or using bitmaps in the menu):
twidth += 16 (checkitem/bmp width)
twidth += 5 (approximate amount of padding between bmp and label)Cody
------------------------------------------------------------------------_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thanks Cody,
this works well enough for my purposes.
Max
On 9/4/08, *Max Landaeus* <max@landaeus.com <mailto:max@landaeus.com>> > wrote: