[issue16448] 'module' object has no attribute 'font' when "import tkinter" only.

2012-11-10 Thread R. David Murray

R. David Murray added the comment:

This is a question more suited to be asked on python-list or python-tutor, 
rather than a bug report.

I'll give you a clue while I'm closing the issue: in the font snippt you 
reference the font attribute when your module is imported.  In the messagebox 
snippet, you reference the messagebox attribute inside a callback which is 
*not* executed when your module is imported.  So while the file hierarchy 
structure is analogous in the two cases, your *code* is not.  When you close 
the window, you will see your messagebox attribute error when the callback is 
called.

--
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed
type: compile error -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16448] 'module' object has no attribute 'font' when "import tkinter" only.

2012-11-10 Thread jf

jf added the comment:

when i use tkinter.font, i meet a error "'module' object has no attribute 
'font'". if i add "import tkinter.font", it's no error.

but when i use tkinter,messagebox, it's no error without "import 
tkinter.messagebox".

and, under the tkinter folder, "messagebox.py" and "font.py" have the same 
hierarchical filesystem.

why they have different import method?

here is my code:
1)tkinter.font -- only use "import tkinter" meet a error, must add "import 
tkinter.font".code is below:

import tkinter
#import tkinter.font
root = tkinter.Tk()
ft = tkinter.font.Font(family = 'Fixdsys',size = 20,weight = tkinter.font.BOLD)
tkinter.Label(root,text = 'hello sticky',font = ft ).grid()
root.mainloop()

2)tkinter.messagebox -- only use "import tkinter" is all ok.code is below:

import tkinter
def callback():
if tkinter.messagebox.askokcancel("Quit", "Do you really wish to quit?"):
root.destroy()
root = tkinter.Tk()
root.protocol("WM_DELETE_WINDOW", callback)
root.mainloop()


i am a beginner on python. if have a reply, please email me. thanks.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16448] 'module' object has no attribute 'font' when "import tkinter" only.

2012-11-10 Thread jf

New submission from jf:

when i use tkinter.font, i meet a error "'module' object has no attribute 
'font'". if i add "import tkinter.font", it's no error.

but when i use tkinter,messagebox, it's no error without "import 
tkinter.messagebox".

and, under the tkinter folder, "messagebox.py" and "font.py" have the same 
hierarchical filesystem.

why they have different import method?

here is my code:
1)tkinter.font -- only use "import tkinter" meet a error, must add "import 
tkinter.font".code is below:

import tkinter
#import tkinter.font
root = tkinter.Tk()
ft = tkinter.font.Font(family = 'Fixdsys',size = 20,weight = tkinter.font.BOLD)
tkinter.Label(root,text = 'hello sticky',font = ft ).grid()
root.mainloop()

2)tkinter.messagebox -- only use "import tkinter" is all ok.code is below:

import tkinter
def callback():
if tkinter.messagebox.askokcancel("Quit", "Do you really wish to quit?"):
root.destroy()
root = tkinter.Tk()
root.protocol("WM_DELETE_WINDOW", callback)
root.mainloop()


i am a beginner on python. if have a reply, please email me. thinks.

--
components: Tkinter
messages: 175267
nosy: zaazbb
priority: normal
severity: normal
status: open
title: 'module' object has no attribute 'font' when "import tkinter" only.
type: compile error
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com