using import * with GUIs?

2006-05-31 Thread John Salerno
Hi all. Quick question (but aren't they all?) :)

Do you think it's a good idea to use the 'from name import *' 
statement when using a GUI module? It seems on wxPython's site, they 
recommend using import wx nowadays, but I wonder if that advice is 
followed. Also, I'm still reading some Tkinter docs that seem to use 
'from Tkinter import *' a lot.

I understand the danger of doing this, but is it safer in these cases, 
given the more specific names that GUI frameworks tend to use 
(sometimes!)? Or should you still qualify all your calls with the module?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread [EMAIL PROTECTED]

John Salerno wrote:
 Hi all. Quick question (but aren't they all?) :)

 Do you think it's a good idea to use the 'from name import *'
 statement when using a GUI module? It seems on wxPython's site, they
 recommend using import wx nowadays, but I wonder if that advice is
 followed. Also, I'm still reading some Tkinter docs that seem to use
 'from Tkinter import *' a lot.

 I understand the danger of doing this, but is it safer in these cases,
 given the more specific names that GUI frameworks tend to use
 (sometimes!)? Or should you still qualify all your calls with the module?

The python style guide takes no position on this.
Personally I prefer explicit to implicit, and typing wx.  is not really
that much to type is it?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread Terry Reedy

John Salerno [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi all. Quick question (but aren't they all?) :)

 Do you think it's a good idea to use the 'from name import *'
 statement when using a GUI module? It seems on wxPython's site, they
 recommend using import wx nowadays, but I wonder if that advice is
 followed. Also, I'm still reading some Tkinter docs that seem to use
 'from Tkinter import *' a lot.

 I understand the danger of doing this, but is it safer in these cases,
 given the more specific names that GUI frameworks tend to use
 (sometimes!)? Or should you still qualify all your calls with the module?

If I were to use Tkinter, I would 'import Tkinter as tk'. 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread John Salerno
[EMAIL PROTECTED] wrote:

 Personally I prefer explicit to implicit, and typing wx.  is not really
 that much to type is it?

No, but typing Tkinter. is! ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread Alexandre Fayolle
Le 31-05-2006, John [EMAIL PROTECTED] nous disait:
 Hi all. Quick question (but aren't they all?) :)

 Do you think it's a good idea to use the 'from name import *' 
 statement when using a GUI module? It seems on wxPython's site, they 
 recommend using import wx nowadays, but I wonder if that advice is 
 followed. Also, I'm still reading some Tkinter docs that seem to use 
 'from Tkinter import *' a lot.

 I understand the danger of doing this, but is it safer in these cases, 
 given the more specific names that GUI frameworks tend to use 
 (sometimes!)? Or should you still qualify all your calls with the module?


Don't overlook the import module as shortname construct, which is a
real lifesaver for large modules when you'd rather avoid importing * 

Common idiom when using Numeric/numarray/numpy is 

import Numeric as N

Importing Tkinter as tk is imo worth it. 

-- 
Alexandre Fayolle  LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
Python et calcul scientifique:   http://www.logilab.fr/science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread John Salerno
Terry Reedy wrote:

 If I were to use Tkinter, I would 'import Tkinter as tk'. 

Good idea!

I was kind of excited about Tkinter for a little while...seems very 
easy, and it has an event delegation system that I understand! But then 
I saw that for a toolbar you use a Frame? And for a status bar you use a 
Label? Ick!

I guess if I'm going to learn a GUI, I might as well jump right into 
wxPython from the beginning.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread malv
John Salerno wrote:
 Terry Reedy wrote:

  If I were to use Tkinter, I would 'import Tkinter as tk'.

 Good idea!

 I was kind of excited about Tkinter for a little while...seems very
 easy, and it has an event delegation system that I understand! But then
 I saw that for a toolbar you use a Frame? And for a status bar you use a
 Label? Ick!

 I guess if I'm going to learn a GUI, I might as well jump right into
 wxPython from the beginning.
Better first look at Qt/PyQt before jumping right into wxPython.
You will at least know what you will be jumping into.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread Mel Wilson
John Salerno wrote:
 Hi all. Quick question (but aren't they all?) :)
 
 Do you think it's a good idea to use the 'from name import *' 
 statement when using a GUI module? It seems on wxPython's site, they 
 recommend using import wx nowadays, but I wonder if that advice is 
 followed. Also, I'm still reading some Tkinter docs that seem to use 
 'from Tkinter import *' a lot.
 
 I understand the danger of doing this, but is it safer in these cases, 
 given the more specific names that GUI frameworks tend to use 
 (sometimes!)? Or should you still qualify all your calls with the module?
More specific?  I dunno, I have trouble thinking of that
huge multitude of names in wx as specific.  Who knows what
in all that might collide with names you devise?

My formative experience came when I was looking at Python
Imaging Library Demo code.  Somebody did a simple call to
open and got returned an entire Jpeg image object.  I knew
that open was destined to take arguments other than simple
file paths, and return things other than simple files, but
it seemed awfully soon.  Then I got suspicious, looked at
the top of the code, and saw from Image import *

So a word, too, to people writing demo programs.  Writing
from mycode import * obscures which code is actually yours
in the code following.  Kind of defeats the purpose.

 Cheers,Mel.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using import * with GUIs?

2006-05-31 Thread Peter Decker
On 5/31/06, John Salerno [EMAIL PROTECTED] wrote:

 I guess if I'm going to learn a GUI, I might as well jump right into
 wxPython from the beginning.

May I recommend that you take a look at the Dabo project? While they
have a full application framework for creating database applications,
you can easily just use the dabo.ui module, which wraps wxPython. This
eliminates most of the C++ cruft that wxPython inherited from
wxWidgets, and makes for a much more Pythonic experience.

I worked with wxPython for a couple of years, and looked at Dabo based
on a recommendation on the wxPython list. Since then, I haven't
written a single app using raw wxPython; I use the dabo.ui module for
all my GUI applications. It gives you all the advantages of wxPython,
but it just works better.

-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list