python - how to open a child window? -


please fix script.

import tkinter  def winmake(parent):     win = tkinter.frame(parent)     win.config(relief = 'sunken', width = 340, height = 170, bg = 'red')     win.pack(expand = 'yes', fill = 'both')      msg = tkinter.button(win, text='press me', command = addformopen)     msg.pack()  def addformopen():     addform = tkinter.toplevel(root)     label(addform, text = 'ertert').pack()     print('fff')  root = tkinter.tk() winmake(root) root.mainloop() 

after clicking on button "press me" should open child window. console displays error message:

exception in tkinter callback traceback (most recent call last):     file "c:\python33\lib\tkinter\__init__.py", line 1475, in __call__     return self.func(*args)   file "c:\python33\projects\dvd_lis\p3_dvd_list_shelve_3d_class_edit_menubar\q.py", line 13, in addformopen     label(addform, text = 'ertert').pack()  nameerror: global name 'label' not defined 

you imported name tkinter contains class label. meaning, in order access it, need put tkinter. before (just did frame, button, etc.):

tkinter.label(addform, text = 'ertert').pack() 

otherwise, python not know label defined.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -