473,915 Members | 5,813 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 1542

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
2306
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, unix). In my search for a GUI, I've also come to the conclusion that as much as I love Python,...
5
2411
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 me know. ** LONG POST AHEAD **
7
1894
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 version that looks and feels like a native application. All the code that interacts with the user is...
3
2287
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 some GUI programming again. I'd like to use Tk, but it seems to be dying a slow death, so it's...
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 building a GUI using .NET, or something else? If I use .NET then I need to write it using a...
1
1291
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 can recommend a book for designing GUIs.
29
16641
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 language for existing CAD environments, and I've also found some guy who's writing a 2d drafting...
19
1978
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
2204
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 intiger. What would be the best is if this window would open up when a function was called and the intiger...
0
10039
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9881
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11354
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10542
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5943
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4778
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
2
4344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3368
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.