LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 03-07-2008, 08:14 PM   #1
geek_man
Member
 
Registered: Nov 2007
Distribution: Fedora 7, Fedora 9, Solaris 10, Mac OS X, RHEL5
Posts: 71

Rep: Reputation: 15
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.
 
Old 03-08-2008, 02:19 AM   #2
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
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)
 
Old 03-08-2008, 10:43 AM   #3
geek_man
Member
 
Registered: Nov 2007
Distribution: Fedora 7, Fedora 9, Solaris 10, Mac OS X, RHEL5
Posts: 71

Original Poster
Rep: Reputation: 15
Question

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.
 
Old 03-08-2008, 11:49 AM   #4
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
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
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub-pixel Hinting arubin Slackware 2 01-08-2008 12:34 PM
A rogue pixel... uglydot Linux - Software 1 04-10-2007 11:51 PM
Read pixel in Linux guitara Programming 6 03-22-2007 06:12 PM
Screen pixel manipulation? ichrispa Programming 2 01-25-2006 02:09 PM
pixel pipelines? tnelson42345 Linux - Hardware 1 11-12-2005 12:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration