Home > Archive > Tcl > July 2004 > maxiumn number of menus
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
maxiumn number of menus
|
|
| wai shun au 2004-07-21, 3:58 pm |
| i am writing a program that uses a lot of menus. as i add more menus
eventually i'll get the message "No more menus can be allocated."
is there a way to increase the maximum number of menus tk can allocate?
| |
| Michael Schlenker 2004-07-21, 3:58 pm |
| wai shun au wrote:
> i am writing a program that uses a lot of menus. as i add more menus
> eventually i'll get the message "No more menus can be allocated."
> is there a way to increase the maximum number of menus tk can allocate?
>
>
If your on Windows this may be relevant:
http://msdn.microsoft.com/library/d...tePopupMenu.asp
It notes there are a maximum of 16364 menus.
Only way to get some is to destroy some of the old ones.
If your on MacOS X, this comment in the source code may be relevant:
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetNewMenuID --
*
* Allocates a new menu id and marks it in use. Each menu on the
* mac must be designated by a unique id, which is a short. In
* addition, some ids are reserved by the system. Since Tk uses
* mostly dynamic menus, we must allocate and free these ids on
* the fly. We use the id as a key into a hash table; if there
* is no hash entry, we know that we can use the id.
*
* Carbon allows a much larger number of menus than the old APIs.
* I believe this is 32768, but am not sure. This code just uses
* 2000 as the upper limit. Unfortunately tk leaks menus when
* cloning, under some circumstances (see bug on sourceforge).
No other places in Tk show the error message you have pointed at, and i
think there is no way on windows and patching Tk on MacOSX to get around
that limit.
Michael
| |
| wai shun au 2004-07-21, 3:58 pm |
| yes, this is on windows. i am not sure about the 16364 number though.
running the following example is fine. however, if i call "addSC s20" from
console,
i can't see the second level popup menus anymore. if i call "addSC s21", i
would
get the message "No more menus can be allocated."
########################################
#
console show
set men1 {s1 s2 s3 s4 s5 s6 s7 s8 s9 s0 s11 s12}
set sc {s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19}
frame .frm
pack .frm
proc addSC {lala} {
global men1
menubutton .frm.m$lala -menu .frm.m$lala.$lala -text $lala
menu .frm.m$lala.$lala -title title$lala
pack .frm.m$lala -side left
foreach submenu $men1 {
menu .frm.m$lala.$lala.$submenu
.frm.m$lala.$lala add cascade -label $submenu -menu
..frm.m$lala.$lala.$submenu
foreach submenu2 $men1 {
menu .frm.m$lala.$lala.$submenu.$submenu2
.frm.m$lala.$lala.$submenu add cascade -label $submenu2 -menu
..frm.m$lala.$lala.$submenu.$submenu2
.frm.m$lala.$lala.$submenu.$submenu2 add command -label
lala$submenu2 -command {}
.frm.m$lala.$lala.$submenu.$submenu2 add separator
.frm.m$lala.$lala.$submenu.$submenu2 add command -label
mama$submenu2 -command {}
.frm.m$lala.$lala.$submenu.$submenu2 add command -label
tata$submenu2 -command {}
}
.frm.m$lala.$lala.$submenu add separator
}
}
foreach scraft $sc {
addSC $scraft
}
########################################
######################
> If your on Windows this may be relevant:
>
http://msdn.microsoft.com/library/d...tePopupMenu.asp
>
> It notes there are a maximum of 16364 menus.
>
> Only way to get some is to destroy some of the old ones.
>
|
|
|
|
|