top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Unlimited canvas painting program using Python?

+2 votes
1,971 views

How to create a program similar to paint, but the difference would be that the cursor would be always in the middle and the canvas moves or the camera is always fixed on the cursor as it moves around the canvas. And the canvas should be infinite. What would be reasonable to use?

In addition, i want it to draw a line without me having to press a button, just move the mouse.

posted Oct 24, 2013 by Amit Parthsarthi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

+1 vote

To start with, you'll want some sort of Graphic User Interface, a popular and common (but not the only) one is TkInter, which you can dive into here: https://wiki.python.org/moin/TkInter

answer Oct 24, 2013 by Meenal Mishra
+1 vote

So, i`ll take the canvas, somekind of mouse tracker, for each mouse location I will draw a dot or 2X2 square or something. Main thing i have never understood, is how can i get the backround to move.

Lets say I have 200X200 window. In the middle of it is the cursor that draws. If i move the mouse the cursor doesn't move, but the canvas moves. So if i move mouse to the left, i get a line that goes to the left. So i probably must invert the canvas movement. If mouse goes left, canvas goes right.

answer Oct 24, 2013 by Ahmed Patel
I think it'll be confusing because it goes against how every other program does it!

In a painting program you can point to other things, such as tools, but if the cursor never moves...

It would be simpler, IMHO, if you just moved the canvas and stopped the cursor going off the canvas when the user is drawing near the edge, so that the user doesn't need to stop drawing in order to expose more of
the canvas.
+1 vote

To hold an (effectively) infinite *bitmap* canvas, you'd (effectively) need an (effectively) infinite amount of memory. However, it could be done with an (effectively) infinite *vector* canvas. That way you could limit the on-screen rendering to just the clipped subset of the vector collection.

You'd still want to make it easy to toggle between "draw" and "stop drawing", but you could make a mouse-click. To implement, just pick a GUI library tkinter, wx, or whatver.

answer Oct 24, 2013 by Sheetal Chauhan
Similar Questions
+1 vote

I want to show simple dots while my program copies the files. I have found the code like:

for i in range(10):
 print '.',
 time.sleep(1)

But this will execute ten times as it is predefined and the task to copy will execute after or before this loop based on the location I have placed my line to copy the files using shutil.copy().

I want that the files should be copied and in parallel the progress should be shown and when the files are copied, the progress should exit.

0 votes
while len(word_letters) > 0 and lives > 0:
        # letters used
        # ' '.join(['a', 'b', 'cd']) --> 'a b cd'
        print('You have', lives, 'lives left and you have used these letters: ', ' '.join(used_letters))

        # what current word is (ie W - R D)
        word_list = [letters if letters in used_letters else '-' for letters in word]
        print(lives_visual_dict[lives])
        print('Current word: ', ' '.join(word_list))

https://www.youtube.com/watch?v=8ext9G7xspg
the part which i am finding difficult to understand appears at 32:15 of the above video.
i don't know how to highlight a part of a code while posting a question on this forum. this is my first post.
if someone can help than i would be very grateful.

0 votes

Inputs would be:
- Name
- age
- gender
- married/unmarried

User feeds this data once but he/she can check later on also. So in this case program should have option to feed and read data from file.

...