Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'messages.': 0.05; 'root': 0.05; 'subject:menu': 0.05; 'tkinter': 0.07; "'python": 0.09; 'happens.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tcl/tk': 0.09; 'windows,': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '(also': 0.16; 'displayed.': 0.16; 'editor,': 0.16; 'empty,': 0.16; 'exactly?': 0.16; 'fine.': 0.16; 'menu.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:Tkinter': 0.16; 'tk()': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'do.': 0.18; 'app': 0.19; 'skip:f 30': 0.19; 'entered': 0.20; 'command': 0.22; 'import': 0.22; 'issue.': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'text,': 0.24; 'earlier': 0.24; 'appreciated': 0.26; 'code:': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'label': 0.30; 'code': 0.31; 'lines': 0.31; 'clicked': 0.31; 'run': 0.32; 'text': 0.33; 'worked': 0.33; 'problem': 0.35; 'editor': 0.35; 'test': 0.35; 'but': 0.35; 'version': 0.36; 'idle': 0.36; 'leads': 0.36; 'entry': 0.36; 'two': 0.37; 'implement': 0.38; 'minimum': 0.38; 'problems': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'how': 0.40; 'tips': 0.61; 'new': 0.61; 'first': 0.61; 'you.': 0.62; 'box,': 0.64; 'different': 0.65; 'here': 0.66; 'yes': 0.68; 'prompt': 0.68; 'skip:r 30': 0.69; 'construction': 0.72; 'info)': 0.84; 'mtext': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Tkinter menu crash Date: Tue, 05 Aug 2014 17:43:08 -0400 References: <1a31faea-eea6-4b1d-8dc1-185f13348621@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <1a31faea-eea6-4b1d-8dc1-185f13348621@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 94 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407275016 news.xs4all.nl 2956 [2001:888:2000:d::a6]:56551 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75760 On 8/5/2014 8:15 AM, Nicholas Cannon wrote: > Ok so the first part of the program(until the start of the menu) worked fine. It ran and did what I wanted it to do. What x.y.z version of Python. How did you run it, exactly? > I wanted to then implement a new menu(for practise) and then it crashes. Don't know why but it just crashes. If you ran from Idle editor on Windows, start Idle with 'python -m idlelib' in Command Prompt to see tk error messages. However, when I pasted code into 3.4.1 Idle Editor, changed first two lines to from tkinter import * from tkinter import messagebox as tm and ran -- no crash, no error message, no menu. I entered text into box, clicked Submit text, and OK on popup, and nothing happens. See below for why no menu. When you ask about a problem, please reduce code to the minimum that exhibits the problem for you. > (also tips on the code will be appreciated and I gave just started Tkinter programming) A different issue. > Here is the code: > > > from Tkinter import * > import tkMessageBox as tm > > def submit(): > #message box with yes no > tm.askyesno(title='Submit Text', message='Are you sure....') > > def info(): > tm.showinfo(title='About', message='Just a test Tkinter UI sample') > > #getting the text from the entrybox and > #packs it into a label > mtext = text.get() > label1 = Label(app, text=mtext) > label1.pack() > > #root window setup > root = Tk() > root.geometry('480x480+200+200') > root.title('Basic Tk UI') > > #frame set up > app = Frame(root) > app.pack() > > #variable and entry box set up > text = StringVar() > entry = Entry(app, textvariable=text) > entry.pack() > > #button set up > button1 = Button(app, text='Submit text', command= submit) > button1.pack() > > #menu construction > menubar = Menu(root) > > filemenu = Menu(menubar) > filemenu.add_command(label='About', command= info) > filemenu.add_command(label='Quit', command= root.destroy) > filemenu.add_cascade(label='TK UI Sample', menu=filemenu) Adding filemenu as a submenu of filemenu leads to infinite loop regress. On 3.4.1 with tcl/tk 8.6, this does not crash, but it might on an earlier version of Python and tcl/tk. Since menubar is left empty, it is not displayed. Fix both problems with menubar.add_cascade(label='TK UI Sample', menu=filemenu) > root.config(menu=menubar) > > > > #loop to listen for events > root.mainloop() > -- Terry Jan Reedy