Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106505 > unrolled thread
| Started by | Nicolae Morkov <morkovnicolae@gmail.com> |
|---|---|
| First post | 2016-04-05 11:19 +0100 |
| Last post | 2016-04-05 08:23 -0400 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Import graphics error Nicolae Morkov <morkovnicolae@gmail.com> - 2016-04-05 11:19 +0100
Re: Import graphics error Steven D'Aprano <steve@pearwood.info> - 2016-04-05 20:33 +1000
Re: Import graphics error Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-04-05 08:23 -0400
| From | Nicolae Morkov <morkovnicolae@gmail.com> |
|---|---|
| Date | 2016-04-05 11:19 +0100 |
| Subject | Import graphics error |
| Message-ID | <mailman.61.1459851765.32530.python-list@python.org> |
# This program creates a graphics window with a rectangle. It provides the
3 # template used with all of the graphical programs used in the book.
4 #
5
6 from graphics import GraphicsWindow
7
8 # Create the window and access the canvas.
9 win = GraphicsWindow()
10 canvas = win.canvas()
11
12 # Draw on the canvas.
13 canvas.drawRect(5, 10, 20, 30)
14
15 # Wait for the user to close the window.
16 win.wait()
*This is the error I get*
Traceback (most recent call last):
File
"C:/Users/Nicolae/AppData/Local/Programs/Python/Python35/pythonK/pr.py",
line 1, in <module>
from graphics import GraphicsWindow
ImportError: No module named 'graphics'
*And when I installed graphic library the error was :*
Traceback (most recent call last):
File
"C:/Users/Nicolae/AppData/Local/Programs/Python/Python35/pythonK/pr.py",
line 1, in <module>
from graphics import GraphicsWindow
ImportError: cannot import name 'GraphicsWindow'
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2016-04-05 20:33 +1000 |
| Message-ID | <5703946f$0$1612$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #106505 |
On Tue, 5 Apr 2016 08:19 pm, Nicolae Morkov wrote: > # This program creates a graphics window with a rectangle. It provides the > 3 # template used with all of the graphical programs used in the book. What book? > *This is the error I get* > > Traceback (most recent call last): > File > "C:/Users/Nicolae/AppData/Local/Programs/Python/Python35/pythonK/pr.py", > line 1, in <module> > from graphics import GraphicsWindow > ImportError: No module named 'graphics' Okay. So you didn't have the graphics module installed, and the import failed because the module wasn't installed. > *And when I installed graphic library the error was :* > > Traceback (most recent call last): > File > "C:/Users/Nicolae/AppData/Local/Programs/Python/Python35/pythonK/pr.py", > line 1, in <module> > from graphics import GraphicsWindow > ImportError: cannot import name 'GraphicsWindow' How did you install it? Are you sure it is the right module? -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2016-04-05 08:23 -0400 |
| Message-ID | <mailman.66.1459859222.32530.python-list@python.org> |
| In reply to | #106506 |
On Tue, 05 Apr 2016 20:33:18 +1000, Steven D'Aprano <steve@pearwood.info>
declaimed the following:
>On Tue, 5 Apr 2016 08:19 pm, Nicolae Morkov wrote:
>
>> # This program creates a graphics window with a rectangle. It provides the
>> 3 # template used with all of the graphical programs used in the book.
>
>What book?
>
Hopefully not "Python Programming: An Introduction to Computer Science"
as the first hit (
http://mcsp.wartburg.edu/zelle/python/graphics/graphics/node1.html ) for
"python graphics library" doesn't match the calls (well, the second hit,
the first hit was a demo program -- which surprised me as Firefox appeared
to launch it!)
>From the above documentation:
-=-=-=-=-
from graphics import *
def main():
win = GraphWin("My Circle", 100, 100)
c = Circle(Point(50,50), 10)
c.draw(win)
win.getMouse() # pause for click in window
win.close()
main()
-=-=-=-=-
Same library name as the OP, but different window creation.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web