So I'm making a program in Python and for user interface I'm using Tkinter, the application seems to be running fine but as I navigate a while in it, I get the follwing TclError:
TclError: No more menus can be allocated.
I did some research and I found out that there is a limit for these "menus" on windows, but my question is, how do I know that these menus are being created? How can I delete them when I stop using them? I use methods for deleting top menus as "top.destroy()". But even though I am generating more and more menus and it's overflowing the windows heap or whatever it is.
Here is the source code for my program:
https://github.com/molBR/upgestao
Can somebody help?
Thanks in advance.
I have the same error when creating auto-hide menu. At first I created automatically generated and deleted dummy (empty) menu bar to replace a real menu bar to hide it. So after several dozens hiding tkinter start to show me this error: TclError: No more menus can be allocated.
The solution is simple: do not create/delete menus automatically.
Just create all necessary menus you want and save them in the memory. Do not delete them. And switch between menus during work of your program.
Related
Beginner in the whole Python/Anki thing. Learning more about coding for fun and I have set up a debugging environment with pycharm and an Anki profile with the bazelfixes and it seems to start anki up fine. I want to append an extra dropdown menu on the main menu toolbar in Anki so that I can connect the actions to my functions.
I went through the hooks and the toolbar hook worked but it is not exactly what I was going for because it adds to the toolbar, not the menu. I want to add a new dropdown into the actual main menu next to tools, help, etc. connect them to functions I have made. Kind of like this
I have looked at others and sometimes they work partially but it's like a fragmented puzzle some use qmainwindow and it makes a popup separate from anki when I run it, or other approaches where they use the aqt.mw.form() functions in various ways but when I do it it will be like "nonetype doesn't take .form function." or form is not an expected argument. I want to figure out the first basic step.
I have also looked at the aqt MW thing but I am kind of confused about how it works so I am not sure if that is a better approach to read up on. The whole class>def variable> mw.append type of structure I have been seeing in other's code is a little confusing for me. Or am I going about it the completely wrong way and should use html/CSS? Any help or advice is greatly appreciated!
Also here is the bazelfixes code I have been using on pycharm.
try:
import bazelfixes
bazelfixes.fix_pywin32_in_bazel()
bazelfixes.fix_extraneous_path_in_bazel()
bazelfixes.fix_run_on_macos()
except ImportError:
pass
if not os.environ.get(“ANKI_IMPORT_ONLY”):
aqt.run()
TL;DR How do I, within this code on pycharm append an extra dropdown item on the main menu bar. Is there a hook I am missing (not the init toolbar one)? Or a different approach I should try?
I built a small GUI using Tkinter. The GUI features, among some other elements, three buttons. These buttons serve to open a dystem dialog and select certain data-files etc. One of the three buttons is a 'Go' button that runs the underlying data-processing.
When running the .py script the GUI works fine. However, after creating a developer app in alias mode using Py2App the buttons have become invisible! They're still there and usable, but invisible until interacted with.
How can I prevent this from happening?
I was stuck in your exact situation for quite some time. When I ran my tkinter script, it worked perfectly and all the buttons showed up, but once I packaged it, the buttons stopped showing up (They were still there but you couldn't see them). After a long time of trying random things, I found out how to make the buttons and their text show up again. Simply resize the window. Even a difference of 1 or 2 pixels does the trick. I have not yet found a way to PREVENT this issue, but at least this makes the app look right.
Please reply if you figure out a solution to prevent this!
Good Luck!
I'm currently working on a timer application on python 3, basically is for you to keep track of how many time spend doing something. I'm in the part of the process where i need to create an interface probably with tkinter, with a drop down menu that lists all the things i need to keep track of (lets call those things "statuses").
Now, my question is, is there a way to add that the drop down menu with the statuses in the task bar on windows? so that a user does not have to go the interface and change status, but most importantly, the current status can be always on sight.
Is this even possible? If it is, I just need a few hints please! :)
Am not sure about adding a drop down menu to the taskbar icon(like the one you get with Microsoft lync taskbar icon to change status, hope u need something like this), but i would suggest(incase this helps) to add menu at right click over the taskbar icon.
wxPython might help.
see this article.
http://codeboje.de/MailSneaker-Part-3-SystemTrayTaskBar-Icons-with-Python-and-wxPython/
Hope this helps.
Is there a quick way to clear the menu bar i.e. Remove all menus in PyQt.
The reason I ask is that I am developing a modular application. Each module provides it's own menus and gives a weighting to where that menu should appear. Each module can also add a menuAction to another modules menu, however when that happens it changes the order of the menus. What i want to do is when the menus have finished being created is to remove them all and then re add them.
I know this will work because I can re add them now and they appear in the correct order but all the previous menus are still there.
did you try QMenu.clear (self)
mymenu = QtGui.QMenu("Menu")
mymenu.clear()
In order to indicate activity, some applications (e.g. Pidgin) highlight their entry in GNOME's Window List panel widget (e.g. via bold font or flashing color). This indication is reset automatically when the window is activated.
I have a terminal application for which I would like to achieve the same thing (preferably via Perl, but Python would work too) - but I have no idea where to start. I imagine I'd first have to find the terminal window (based on window title) and then trigger some kind of GTK action.
Any help would be greatly appreciated!
In a GTK application, use gtk_window_set_urgency_hint(). If you have a terminal application, you can't really do that - with libwnck you can get information about other application's windows, but as far as I know you can't get a GtkWindow pointer to another application's window.
May I suggest using the terminal beep? Of course this isn't a sure way to attract the user's attention, but some terminals are able to flash the title bar instead of beeping, or such things.
I'm not really into GTK programming, but as far as i know you want to set an "URGENT"-Flag for the Window which should be highlighted. Maybe this will get you any further. :)