Paint program: Problems with a line tool
Author |
Message |
mylinetoolisntworking
|
Posted: Mon Feb 18, 2008 11:43 am Post subject: Paint program: Problems with a line tool |
|
|
this is the function for my line tool in a paint program:
def lineTool():
event.get()
getMouse() # gets mouse position and if the left button is clicked
x1, y1 = mx,my
while True:
event.get()
getMouse()
if mb == 0:
x2 = mx
y2 = my
draw.line(screen,colour,(x1,y1),(x2,y2))
break
drawFrame()
display.flip()
it gets called when mb == 1 (when the mouse button is Pressed)
the problem as i see it is, mb stays at 1 after entering the loop.
i had it print mb and it retuned 1 over and over even after i released the button
any idea whats wrong? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
McKenzie
|
Posted: Mon Feb 18, 2008 12:03 pm Post subject: Re: Paint program: Problems with a line tool |
|
|
As you know in Python indents matter. You need to use code tags when you post or else it is very hard to tell what the problem is. Your getMouse is clearly changing global variables, post that as well. You can always PM all of your code to have a look at too. |
|
|
|
|
|
mylinetoolisntworking
|
Posted: Mon Feb 18, 2008 12:57 pm Post subject: Re: Paint program: Problems with a line tool |
|
|
Not quite sure how do do that, maybe this will help
def lineTool():
@event.get()
@getMouse()
@x1, y1 = mx,my
@while True:
@@event.get()
@@getMouse()
@@if mb == 0:
@@@x2 = mx
@@@y2 = my
@@@draw.line(screen,colour,(x1,y1),(x2,y2))
@@@break
@drawFrame()
@display.flip()
Sorry if thats a bit ugly, Iv'e been spoiled by dreamweaver |
|
|
|
|
|
andrew.
|
Posted: Sat Apr 05, 2008 8:58 pm Post subject: Re: Paint program: Problems with a line tool |
|
|
I'm new to Python and I don't know how to solve your problem, but to indent on the website, just put your code in [syntax="Python"] CODE [/syntax] tags. Same thing with other languages. |
|
|
|
|
|
|
|