Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 26th, 2004, 03:04 AM
stefanosn stefanosn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 41 stefanosn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
class calls? please help

i put in a statusbar.py file this code

class StatusBar(Frame):

def __init__(self, master):
Frame.__init__(self, master)
self.label = Label(self, bd=1, relief=SUNKEN, anchor=W)
self.label.pack(fill=X)

def set(self, format, *args):
self.label.config(text=format % args)
self.label.update_idletasks()

def clear(self):
self.label.config(text="")
self.label.update_idletasks()

and i want from another showbar.py file to call the StatusBar class function. i am writing this

from Tkinter import *
root = Tk()

status = StatusBar(root)
status.pack(side=BOTTOM, fill=X)

mainloop()

but i get an error saying

Traceback (most recent call last):
File "C:\Python23\showbar.py", line 6, in ?
status = StatusBar(root)
NameError: name 'StatusBar' is not defined

help! please

Reply With Quote
  #2  
Old July 26th, 2004, 08:25 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 2 m 16 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Just add import statusbar to the top of you're file and you should be away. Im assuming that statusbar.py is in the same directory as you're program or is otherwise visable to Python - on Pythons search path (PYTHONPATH) i.e. site-packages

you will then need to preceed the call to StatusBar() with the name of the module you are using. So you end up with:

Code:
import statusbar
...
more code
...
status = statusbar.StatusBar(root)
status.pack(side=BOTTOM, fill=X)
...
more code
...


Hope this helps,

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > class calls? please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway