python - Is there a way to use ribbon toolbars in Tkinter? -


i yet decide language , tools use next project. love use python, implement ribbon toolbars. work has been done in tk (http://www.ellogon.org/petasis/bibliography/tcl2010/tkribbon.pdf), looks hasn't been implemented in tkinter yet. there can work?

you need create wrapper , version of binary can use. built use python 3.4 , copied tkribbon1.0-x86_64.zip. should unzip in python/tcl subdirectory version of tcl used python can load it.

a minimal wrapper looks this:

from tkinter import widget os import path  class ribbon(widget):     def __init__(self, master, kw=none):         self.version = master.tk.call('package','require','tkribbon')         self.library = master.tk.eval('set ::tkribbon::library')         widget.__init__(self, master, 'tkribbon::ribbon', kw=kw)      def load_resource(self, resource_file, resource_name='application_ribbon'):         """load ribbon definition resources.          ribbon markup compiled using uicc compiler , resource included         in dll. load provided file."""         self.tk.call(self._w, 'load_resources', resource_file)         self.tk.call(self._w, 'load_ui', resource_file, resource_name)  if __name__ == '__main__':     import sys     tkinter import *     def main():         root = tk()         r = ribbon(root)         name = 'application_ribbon'         if len(sys.argv) > 1:             resource = sys.argv[1]             if len(sys.argv) > 2:                 name = sys.argv[2]         else:             resource = path.join(r.library, 'libtkribbon1.0.dll')         r.load_resource(resource, name)         t = text(root)         r.grid(sticky=(n,e,s,w))         t.grid(sticky=(n,e,s,w))         root.grid_columnconfigure(0, weight=1)         root.grid_rowconfigure(1, weight=1)         root.mainloop()     main() 

running uses resources built-in tkribbon dll , looks this screenshot. complicated bit going getting ribbon markup resources dll loading.

you can use example load ribbons existing applications. instance, python ribbon.py c:\windows\system32\mspaint.exe mspaint_ribbon load ribbon resource mspaint. resource name in case has included default application_ribbon. own ribbon, using uicc build .rc file, rc /r file.rc produce .res file , link -dll -out:file.dll file.rc -noentry -machine:amd64 seems work produce resource dll works extension.


Comments