Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-07-2008, 08:14 PM
|
#1
|
|
Member
Registered: Nov 2007
Distribution: Fedora 7, Fedora 9, Solaris 10, Mac OS X, RHEL5
Posts: 71
Rep:
|
Draw a Pixel with Python
Hi!
I am trying to draw a pixel with python, but I can't. I am using this:
canvas = Canvas(width=500, height=500, bg='white')
canvas.pack(expand=YES, fill=BOTH)
canvas.SetPixel(x,y,color)
But I get the following error:
AttributeError: Canvas instance has no attribute 'SetPixel'
I have read in Internet that SetPixel really exists. Can someone help me?
Thanks.
|
|
|
|
03-08-2008, 02:19 AM
|
#2
|
|
Member
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 139
Rep:
|
First of all you should say what GUI toolkit you are working with: Is it Tk, wxPython, PyQT, PyGTK or something else entirely. If your seriously stuck on what methods a module has dir() and help() are the way to go as every decent GUI has python doc strings in the package
just do something like this:
Code:
import module
dir(module)
help(module.method_name)
|
|
|
|
03-08-2008, 10:43 AM
|
#3
|
|
Member
Registered: Nov 2007
Distribution: Fedora 7, Fedora 9, Solaris 10, Mac OS X, RHEL5
Posts: 71
Original Poster
Rep:
|
Hi!
I am a beginner in Python, so I don't know so much. I am using Tkinter GUI Toolkit.
pgpython, do I have to do the following?:
Code:
from Tkinter import Canvas
dir(Canvas)
help(Canvas.SetPixel)
Thanks.
|
|
|
|
03-08-2008, 11:49 AM
|
#4
|
|
Member
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 139
Rep:
|
yes dir returns a list of all the methods and attributes a object has, while help returns the doc string for a attribute. Hence their usefulness. Sorry i can't be of more but I haven't used tkinter for a long time
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:30 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|