FAQ

Josh wrote:
Caution, newbie approaching...
well... newbie vs newbie :))
I'm trying to come up with a very simple Tkinter test application that
consists of a window with a drop-down menu bar at the top and a grid
of colored rectangles filling the remainder of the window.
It seems you'd like to obtain a standard window with a standard menubar
attached at the top.... is it right?

Perhaps I'm not the best person for your problem resolution, but I hope
I'll could give you a contribute :)
class MultiColorMenu(Tkinter.Frame):
"This class is a bar of drop-down menus for manipulating a grid of
colored rectangles."
def __init__(self, master=None):
Tkinter.Frame.__init__(self, master)
self.tk_menuBar(self.help_menu())

def help_menu(self):
help_btn = Tkinter.Menubutton(self, text='Help', underline=0)
help_btn.pack(side=Tkinter.LEFT, padx="2m")
help_btn.menu = Tkinter.Menu(help_btn)
help_btn.menu.add_command(label="How To", underline=0,
command=self.helpFoo)
help_btn.menu.add_command(label="About", underline=0,
command=self.helpFoo)
help_btn['menu'] = help_btn.menu
return help_btn

def helpFoo(self):
print 'Heelllppppp!!!'
For my knowledge (..very small on python, yet) you should use the
Tkinter.Menu widget rather than creating an extension of the
Tkinter.Frame like you did in your MultiColorMenu class.

Just copy&paste this simple example, so you see if it is what you're
looking for.

#begin code
from Tkinter import *

root = Tk()
root.title("Menu demo")
root.geometry("300x300")

# -- barra menu
masterMenu = Menu(root)

# -- menu tipo di ricerca
menutiporicerca = Menu(masterMenu,tearoff=0)
menutiporicerca.add_command(label="Ricerca directory")
menutiporicerca.add_command(label="Ricerca file")
menutiporicerca.add_command(label="Ricerca dentro file")

# -- menu ricerche
menuricerca = Menu(masterMenu,tearoff=0)
menuricerca.add_cascade(label="Nuova ricerca...",menu=menutiporicerca)
menuricerca.add_command(label="Salva ricerca")
menuricerca.add_separator()
menuricerca.add_command(label="Esci")
masterMenu.add_cascade(label="Ricerca",menu=menuricerca)

# -- menu info
menuinfo = Menu(masterMenu,tearoff=0)
menuinfo.add_command(label="Info")
menuinfo.add_separator()
menuinfo.add_command(label="About..")
masterMenu.add_cascade(label="?",menu=menuinfo)

#setta barra menu
root.config(menu=masterMenu)
root.mainloop()

#end code

hope this help you. Bye.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJul 30, '03 at 5:41p
activeJul 31, '03 at 2:05p
posts2
users2
websitepython.org

2 users in discussion

Josh: 1 post Furliz: 1 post

People

Translate

site design / logo © 2022 Grokbase