{"id":22842998,"url":"https://github.com/deflatedpickle/menumaker","last_synced_at":"2025-04-14T06:53:10.536Z","repository":{"id":57440866,"uuid":"105739985","full_name":"DeflatedPickle/menumaker","owner":"DeflatedPickle","description":"An easy solution for creating menus for TkInter applications in just a few lines","archived":false,"fork":false,"pushed_at":"2018-06-06T06:23:54.000Z","size":36,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T20:41:01.663Z","etag":null,"topics":["tkinter"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeflatedPickle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-04T06:58:58.000Z","updated_at":"2024-10-17T13:43:41.000Z","dependencies_parsed_at":"2022-09-02T13:22:55.478Z","dependency_job_id":null,"html_url":"https://github.com/DeflatedPickle/menumaker","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeflatedPickle%2Fmenumaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeflatedPickle%2Fmenumaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeflatedPickle%2Fmenumaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeflatedPickle%2Fmenumaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeflatedPickle","download_url":"https://codeload.github.com/DeflatedPickle/menumaker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837279,"owners_count":21169373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tkinter"],"created_at":"2024-12-13T02:12:15.238Z","updated_at":"2025-04-14T06:53:10.509Z","avatar_url":"https://github.com/DeflatedPickle.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MenuMaker\nAn easy solution for creating menus for TkInter applications in just a few lines.\n\n**What does this library do?**\nIt decreases the amount of lines needed to construct menus to a single line.\n\n**How does it do it?**\nA function call with a list of tuples or a dictionary.\n\n**Why should I use this?**\nIt'll save you time.\n\n**How do I get this?**\nOpen your terminal and type in `pip install menumaker`.\n\n## Comparison:\nBoth of the following code snippets produce the same output, but as you'll see, the code from MenuMaker is much shorter.\n### Normal Tkinter:\n```python\nimport tkinter as tk\n\ndef new(*args):\n    print(\"New!\")\n\ndef undo(*args):\n    print(\"Undo.\")\n\ndef redo(*args):\n    print(\"Redo.\")\n\ndef delete(*args):\n    print(\"Bwahm!\")\n\ndef delete_all(*args):\n    print(\"More bwahm!\")\n\nroot = tk.Tk()\nmenubar = tk.Menu()\n\nvar = tk.IntVar()\nvar2 = tk.BooleanVar()\n\nvar.trace_variable(\"w\", lambda *args: print(\"Changed!\"))\n\nfile = tk.Menu(menubar)\nfile.add_command(label=\"New\", command=new, accel=\"Ctrl+N\")\nroot.bind(\"\u003cControl-n\u003e\", new)\nfile.add_command(label=\"Open\")\nfile.add_command(label=\"Save\")\nmenubar.add_cascade(label=\"File\", menu=file)\n\nedit = tk.Menu(menubar)\nedit.add_command(label=\"Undo\", command=undo, accel=\"Ctrl+Z\")\nroot.bind(\"\u003cControl-z\u003e\", undo)\nedit.add_command(label=\"Redo\", command=redo, accel=\"Ctrl+Shift+Z\")\nroot.bind(\"\u003cControl-Shift-Z\u003e\", redo)\nedit.add_separator()\nedit.add_command(label=\"Cut\")\nedit.add_command(label=\"Copy\")\nedit.add_command(label=\"Paste\")\nedit.add_command(label=\"Delete\", command=delete, accel=\"Delete\")\nroot.bind(\"\u003cDelete\u003e\", delete)\nedit.add_command(label=\"Delete All\", command=delete_all, accel=\"Alt-Delete\")\nroot.bind(\"\u003cAlt-Delete\u003e\", delete_all)\nmenubar.add_cascade(label=\"Edit\", menu=edit)\n\nbackground = tk.Menu(menubar)\nbackground.add_radiobutton(label=\"Green\", variable=var)\nbackground.add_radiobutton(label=\"Red\", variable=var)\n\nview = tk.Menu(menubar)\nview.add_checkbutton(label=\"Toolbar\", variable=var2)\nview.add_cascade(label=\"Background\", menu=background)\nmenubar.add_cascade(label=\"View\", menu=view)\n\nroot.configure(menu=menubar)\nroot.mainloop()\n```\n\n### MenuMaker:\n```python\nimport tkinter as tk\nimport menumaker\n\ndef new(*args):\n    print(\"New!\")\n\ndef undo(*args):\n    print(\"Undo.\")\n\ndef redo(*args):\n    print(\"Redo.\")\n\ndef delete(*args):\n    print(\"Bwahm!\")\n\ndef delete_all(*args):\n    print(\"More bwahm!\")\n\nroot = tk.Tk()\nmenubar = tk.Menu(root)\n\nvar = tk.IntVar()\nvar2 = tk.BooleanVar()\n\nvar.trace_variable(\"w\", lambda *args: print(\"Changed!\"))\n\nmenumaker.constructor(menubar, [\n    (\"file\", {\"items\": [\"new ~ctrl+n\", \"open\", \"save\"]}),\n    (\"edit\", {\"items\": [\"undo ~ctrl+z\", \"redo ~ctrl+shift+z\", \"---\", \"cut\", \"copy\", \"paste\", \"delete ~delete\", \"delete all ~alt+delete\"]}),\n    (\"-background\", {\"items\": [\"(var) green\", \"(var) red\"]}),\n    (\"view\", {\"items\": [\"[var2] toolbar\", \"-background\"]})\n])\n\nroot.configure(menu=menubar)\nroot.mainloop()\n```\n\n## Syntax:\n- `[]` - A Checkbutton.\n- `()` - A Radiobutton.\n- `-` - A sub-menu.\n- `---` - A Separator.\n- `~` - An accelerator label.\n- `|` - An image.\n\nIf a function is found with the same name as a menu item, the command of that menu item will be set to the found function.\n\nPutting the name of a variable inside of the brackets for a Radio or Checkbutton will set the variable used for the Radio or Checkbutton to the variable given.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeflatedpickle%2Fmenumaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeflatedpickle%2Fmenumaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeflatedpickle%2Fmenumaker/lists"}