-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
296 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,112 @@ | ||
Canvas | ||
====== | ||
|
||
The **Canvas** widget can be used to draw lines, shapes, and text | ||
to create complex drawings and graphs. | ||
The origin (0, 0) of the canvas is in the top left corner. | ||
It has the keyword options: | ||
|
||
.. automodule:: canvas1 | ||
:members: | ||
* background = background color | ||
* borderwidth | ||
* height | ||
* width | ||
|
||
This is a screen capture of the above program. | ||
|
||
Draw lines and rectangles | ||
------------------------- | ||
|
||
To draw lines and rectangles, use these **create** methods: | ||
|
||
* create_line() | ||
* create_rectangle() | ||
|
||
.. image:: canvas1.png | ||
|
||
.. literalinclude:: canvas1.py | ||
|
||
:download:`canvas1.py<canvas1.py>` | ||
|
||
|
||
Create text | ||
----------- | ||
|
||
.. automodule:: canvas2 | ||
:members: | ||
Text can be added to a canvas with this function: | ||
|
||
This is a screen capture of the above program. | ||
* create_text() | ||
|
||
.. image:: canvas2.png | ||
|
||
.. literalinclude:: canvas2.py | ||
|
||
:download:`canvas2.py<canvas2.py>` | ||
|
||
|
||
Painting using ovals | ||
-------------------- | ||
|
||
.. automodule:: canvas3 | ||
:members: | ||
|
||
This is a screen capture of the above program. | ||
Small ovals can be used to paint with the mouse, | ||
by binding a callback function to the mouse movement. | ||
|
||
.. image:: canvas3.png | ||
|
||
.. literalinclude:: canvas3.py | ||
|
||
:download:`canvas3.py<canvas3.py>` | ||
|
||
|
||
Polygons | ||
-------- | ||
|
||
.. automodule:: canvas4 | ||
:members: | ||
We can add our own methods to the Canvas class. | ||
For example we can define a method to add a polygon. | ||
|
||
This is a screen capture of the above program. | ||
.. literalinclude:: tklib.py | ||
:pyobject: Canvas.polygon | ||
|
||
.. image:: canvas4.png | ||
|
||
.. literalinclude:: canvas4.py | ||
|
||
:download:`canvas4.py<canvas4.py>` | ||
|
||
|
||
Random circles | ||
-------------- | ||
|
||
.. automodule:: canvas5 | ||
:members: | ||
The following program places circles of random size at random locations. | ||
|
||
.. image:: canvas5.png | ||
|
||
.. literalinclude:: canvas5.py | ||
|
||
:download:`canvas5.py<canvas5.py>` | ||
|
||
|
||
Canvas configuration | ||
-------------------- | ||
|
||
.. image:: canvas6.png | ||
|
||
.. literalinclude:: canvas6.py | ||
|
||
:download:`canvas6.py<canvas6.py>` | ||
|
||
|
||
Canvas configuration with tree view | ||
----------------------------------- | ||
|
||
.. image:: canvas7.png | ||
|
||
.. literalinclude:: canvas7.py | ||
|
||
:download:`canvas7.py<canvas7.py>` | ||
|
||
|
||
Drawing shapes with the mouse | ||
----------------------------- | ||
|
||
.. image:: canvas9.png | ||
|
||
This is a screen capture of the above program. | ||
.. literalinclude:: canvas9.py | ||
|
||
.. image:: canvas5.png | ||
:download:`canvas9.py<canvas9.py>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.