473,725 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxPython problem; global name NULL is not defined

58 New Member
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\Li b\site-packages\wx-2.8-msw-unicode\wx\_cor e.py", line 7913, in __init__
self._Bootstrap App()
File "C:\Python25\Li b\site-packages\wx-2.8-msw-unicode\wx\_cor e.py", line 7487, in _BootstrapApp
return _core_.PyApp__B ootstrapApp(*ar gs, **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 18037
iamgame
4 New Member
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
Netwatcher
58 New Member
Yep, it's working alright now, thank you
Sep 14 '08 #3
iamgame
4 New Member
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
2490
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? Howww might the problem look like in source - capisuite is an C++-module.
5
6704
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 every time: --- Traceback (most recent call last): File "/usr/bin/denyhosts.py", line 202, in ? first_time, noemail, daemon) File "/usr/lib/python2.3/site-packages/DenyHosts/deny_hosts.py", line 86, in __init__ last_offset)
2
5856
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
12460
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 to have a little command line box that sits on the desktop that I can execute those commands from but that is for another day. At the moment I am just trying to figure out how to put the code together but I keep getting into trouble when I try to use...
8
10547
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
11504
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 modules holds variables I need to pass from one module to another and is called 'EMR_globals'. Several other modules hold functions or user menus and then 'EMR_main' controls the initial user interaction. I'm using MySQL to hold the data. The...
2
23749
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 planning to then create a program to detect input and use this module, but I am hung up. I have constructed the code that I thought would work (though there may be a better way) and I got this error message. Traceback (most recent call last): File...
2
3125
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 modules do not explicitly import TestRunError. TestRunError is raised in various places throughout the modules.
4
4253
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> Traceback (most recent call last): File "./Main.py", line 7, in <module> print (t.getAtomName()) File "/home/jorge/Documentos/projetos/mestrado/códigos/cartesian_zmatrix/Atom.py", line 22, in getAtomName return atomName
0
8888
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
8752
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
9401
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
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
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
8097
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.