473,406 Members | 2,713 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,406 software developers and data experts.

wxPython problem; global name NULL is not defined

im try to activate the tutorial code for wxPython,
it is working properly when i tell it to import * from wxPython.wx
but with an error about the package,
i've done as i was told to change the import to wx
and change all wxsomething to wx.something
but when i start it it gives me an error that say

Traceback (most recent call last):
File "C:/Python25/Sd", line 32, in <module>
app = MyApp(0)
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7913, in __init__
self._BootstrapApp()
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7487, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "C:/Python25/Sd", line 27, in OnInit
frame = MyFrame(NULL, -1, "Hello from wxPython")
NameError: global name 'NULL' is not defined


Expand|Select|Wrap|Line Numbers
  1. import wx
  2. ID_ABOUT = 101
  3. ID_EXIT  = 102
  4.  
  5. class MyFrame(wx.Frame):
  6.     def __init__(self, parent, ID, title):
  7.         wx.Frame.__init__(self, parent, ID, title,
  8.                          wx.DefaultPosition, wx.Size(200, 150))
  9.         self.CreateStatusBar()
  10.         self.SetStatusText("This is the statusbar")
  11.  
  12.         menu = wx.Menu()
  13.         menu.Append(ID_ABOUT, "&About",
  14.                     "More information about this program")
  15.         menu.AppendSeparator()
  16.         menu.Append(ID_EXIT, "E&xit", "Terminate the program")
  17.  
  18.         menuBar = wx.MenuBar()
  19.         menuBar.Append(menu, "&File");
  20.  
  21.         self.SetMenuBar(menuBar)
  22.  
  23.  
  24. class MyApp(wx.App):
  25.     def OnInit(self):
  26.         frame = MyFrame(NULL, -1, "Hello from wxPython")
  27.         frame.Show(true)
  28.         self.SetTopWindow(frame)
  29.         return true
  30.  
  31. app = MyApp(0)
  32. app.MainLoop()
  33.  
am i doing something wrong?
Sep 14 '08 #1
3 17988
am i doing something wrong?
Perhaps, try changing "NULL" to "None". Also, do not pass "true" in the frame.Show() method. And lastly, you can return "1" as the boolean value for OnInit() function.

Modified code is:

Expand|Select|Wrap|Line Numbers
  1. import wx
  2. ID_ABOUT = 101
  3. ID_EXIT  = 102
  4.  
  5. class MyFrame(wx.Frame):
  6.     def __init__(self, parent, ID, title):
  7.         wx.Frame.__init__(self, parent, ID, title,
  8.                          wx.DefaultPosition, wx.Size(200, 150))
  9.         self.CreateStatusBar()
  10.         self.SetStatusText("This is the statusbar")
  11.  
  12.         menu = wx.Menu()
  13.         menu.Append(ID_ABOUT, "&About",
  14.                     "More information about this program")
  15.         menu.AppendSeparator()
  16.         menu.Append(ID_EXIT, "E&xit", "Terminate the program")
  17.  
  18.         menuBar = wx.MenuBar()
  19.         menuBar.Append(menu, "&File");
  20.  
  21.         self.SetMenuBar(menuBar)
  22.  
  23.  
  24. class MyApp(wx.App):
  25.     def OnInit(self):
  26.         frame = MyFrame(None, -1, "Hello from wxPython")
  27.         frame.Show()
  28.         self.SetTopWindow(frame)
  29.         return 1
  30.  
  31. app = MyApp(0)
  32. app.MainLoop()
I have checked for its working, but do let me know if it doesn't in your case.
Sep 14 '08 #2
Yep, it's working alright now, thank you
Sep 14 '08 #3
Nice to know Netwatcher that the code is working alright for you now. :)
Sep 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Elmar Haneke | last post by:
Hi, I do have an problem with Python and Capisuite. On calling one of the Capisuite functions I get an Exception "global name 'Result' is not defined". Where to search for the problem?...
5
by: NetKev | last post by:
I added a function 'warn_Admin' and defined it just before another function 'process_log'. 'process_log' calls this warn_Admin' function. However, when it gets called i get the following error...
2
by: a | last post by:
def fn(): for i in range(l) global count count= .... how do i declare count to be global if it is an array subsequently i should access or define count as an array error:
1
by: NachosRancheros | last post by:
Ok so I just started to program with Python about a week ago and I am trying to make a program that will take the path of a file and a shortcut command and save it to a text file. Eventually I want...
8
by: Evan | last post by:
Hi I have a short script that makes 2 calls to methods in another script as follows: import canPlaces as canp callOne=canp.addMe(3,5) callTwo=canp.estocStn()
3
by: barronmo | last post by:
I'm getting an error msg I don't understand, "global name EMR_globals is not defined", and could use some help. I've separated the application I'm building into several modules. One of the...
2
by: pythonnewb | last post by:
I am fairly new to programming but have some very basic Java background. I am just learning python and tried to make a module that would allow me to create a file containing an address book. I was...
2
by: jmike | last post by:
I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other...
4
by: jorgejch | last post by:
Hello, I've started with python (3) recently. Initialy only for scripting. Now I'm trying the object oriented bit. I'm getting the following error message <Atom.Atom object at 0x7f0b09597fd0>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.