473,320 Members | 1,856 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,320 software developers and data experts.

Question on importing wxPython

python-2.3.5
wx-2.6

I just bought the wxPython In Action book and I see that all the examples
say to
import wx
All of our pre-existing code was horribly doing a
from wxPython import *

I changed all the code so that it was doing an import wx and found that
everything was broken. In particular, references to wxNewId would fail.

634 python
Python 2.3.5 (#2, May 4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import wx
wx.wxNewId
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'wxNewId'
>>>
In fact, the *only* way to get it was to go back to
import wxPython
and then refer to it as wxPython.wx.wxNewId

Is my system broken or am I missing something? i.e., should I be able to
say import wx?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
Jan 28 '08 #1
1 2357
On Jan 28, 12:06 pm, "Steven W. Orr" <ste...@syslang.netwrote:
python-2.3.5
wx-2.6

I just bought the wxPython In Action book and I see that all the examples
say to
import wx
All of our pre-existing code was horribly doing a
from wxPython import *

I changed all the code so that it was doing an import wx and found that
everything was broken. In particular, references to wxNewId would fail.

634 python
Python 2.3.5 (#2, May 4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.>>import wx
>wx.wxNewId

Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'wxNewId'

In fact, the *only* way to get it was to go back to
import wxPython
and then refer to it as wxPython.wx.wxNewId

Is my system broken or am I missing something? i.e., should I be able to
say import wx?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
I think the issue is that you are using the old style of wxPython. The
new style is wx.Something, so in this case, you want wx.NewId(). See
sample code below:

import wx
new_id = wx.NewId()

This helps the developer know what library that function comes from. I
see you are using 2.6. Just so you know, 2.8 is out now...you may want
to upgrade. Also, there's a really nice wxPython community mailing
list you can join, which you'll find here: http://wxpython.org/maillist.php

Mike

Jan 28 '08 #2

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

Similar topics

10
by: Harlin Seritt | last post by:
Is there really a major performance difference between doing the following: import Tkinter as TK TK.Label(yada yada) OR from Tkinter import *
4
by: Bo Peng | last post by:
Dear list, What I would like to do is something like: In myModule.py ( a wrapper module for different versions of the module), if lib == 'standard': from myModule_std import * elsif lib ==...
26
by: Kevin Walzer | last post by:
....with a twist. I'm undertaking my first semi-substantial Python GUI application after a long time dabbling with the language. I'm fairly experienced with Tcl/Tk, so Tkinter seems the...
3
by: Nebulism | last post by:
Hi everyone! Earlier I asked a question about mouse interaction with a GUI. I have found a pretty comprehensive script that is supposed to work <mod edit: link removed, source inserted>:# This...
2
by: OpenPavilion | last post by:
Hello, did anyone succeed in combining wxpython and a 3d engine (pyogre, crystalblend, panda3d, soya etc.) ? I would like to create an application, which uses wxpython tree, menu and grid...
4
by: rshepard | last post by:
I'm stymied by what should be a simple Python task: accessing the value of a variable assigned in one module from within a second module. I wonder if someone here can help clarify my thinking. I've...
3
by: Gandalf | last post by:
I try to reach a specific wx StaticText element's text and to change it by clicking on a button now let's say the this is my element: wx.StaticText(panel, 15, "Hello" ,(30, 70) ,...
0
by: gooli | last post by:
The best thing I've found until now is XRCed. It has it's quirks and pitfalls, but it fits the bill. Personally I prefer the previous version (the one that comes with wxPython 2.8.6) and don't...
3
by: ron.reidy | last post by:
Hi, I just installed wxPython from http://wxpython.org/download.php. When I import (import wx), I get this error: ImportError: DLL load failed: The application has failed to start because...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.