473,543 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1518

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******@NOSPA Mgmail.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*********@gma il.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******@NOSPA Mgmail.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******@nospa mgmail.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
2293
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 are used in educational environments by nontechnical folks. I therefore need GUIs that are pretty, easy to use, and cross platform (win, mac, linux,...
5
2390
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 relevant announcements. If you're interested, drop me a note. But if for some reason you think that this discussion is fine here at the c.l.py, please let...
7
1878
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 PyObjC and Cocoa, which works very well. Our goal is not necessarily to move to a cross-platform solution, but rather to create a solid Windows...
3
2267
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 scattered all over the place and I haven't been able to find mailing lists relating specifically to python and UIs. I'd like to start using Python for...
2
307
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 figures if it isn't too hard to do. I haven't done any GUI's before so what should I use? Do you think I should use the MFC library, or go with...
1
1277
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 GUIs one can extend). There seems to be so many books out there, I would be very grateful to hear from any experienced GUI designer out there - who...
29
16446
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 I *want* at the end of this; I just have never taken on a programming task of this magnitude. I've seen that some are using python as a utility...
19
1940
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 of a ball. Anyone have any suggestions as to which may be the best in my situation? Thanks in advance
12
2173
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 in C++. Here is what I need help with. All I need is a simple GUI window about 100 x 200 pixles. In it, I need to show a constantly changing...
0
7412
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7697
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5889
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1830
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
648
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.