473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using import * with GUIs?

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?
May 31 '06 #1
8 1509

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?

May 31 '06 #2

"John Salerno" <jo******@NOSPAMgmail.com> wrote in message
news:R2******************@news.tufts.edu...
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'.

May 31 '06 #3
ak*********@gmail.com wrote:
Personally I prefer explicit to implicit, and typing wx. is not really
that much to type is it?


No, but typing "Tkinter." is! ;)
May 31 '06 #4
Le 31-05-2006, John <jo******@NOSPAMgmail.com> 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
May 31 '06 #5
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.
May 31 '06 #6
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.

May 31 '06 #7
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.

May 31 '06 #8
On 5/31/06, John Salerno <jo******@nospamgmail.com> 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.
May 31 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bgc | last post by:
Hello All, I've been struggling for years now trying to come up with a solution to a very personal programming problem with Python. I'm an educational programmer, and I make applications that...
5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
7
by: Bob Swerdlow | last post by:
Anyone have opinions about whether we will be better off using PythonNet or wxPython for the GUI layer of our application on Windows? Our code is all Python and is now running on Mac OS X with...
3
by: Kenneth McDonald | last post by:
If this is not an appropriate newsgroup for this type of posting, please let me know and (if possible) suggest an alternative. I've done a fair bit of research on the net, but information is...
2
by: Bill | last post by:
I want to create a GUI using VS .NET. For now I just want to input some parameters used by the algorithms I've written in C++. Maybe later I want to access a database to load the data from and plot...
1
by: Paul Tremblay | last post by:
Hi all, First of all sorry for the cross post. I was not sure which ng would be most appropriate. I need a book that gives guidelines on good GUI design (preferably, comes with a few template...
29
by: 63q2o4i02 | last post by:
Hi, I'm interested in using python to start writing a CAD program for electrical design. I just got done reading Steven Rubin's book, I've used "real" EDA tools, and I have an MSEE, so I know what...
19
by: bagz | last post by:
Hi im looking for a relatively easy and straight forward c gui to use, but not sure which one to go for. All i have to do is create a little area with a few input fields for x,y,z start position...
12
compman9902
by: compman9902 | last post by:
Thank you for looking at my post. Okay, first of all I would like to point out that I have been all over the internet and the library and I cannot seem to get it through my head on how to make GUIs...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.