Python Forum
tkinter questions--- part 2
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter questions--- part 2
#9
from tkinter import *
import random
import time
 
tk=Tk()
canvas=Canvas(tk, width=500, height=400)
canvas.pack()
 
class Ball:
    def__init__(self):
        self.shape = canvas.create_oval(10,10,60,60,fill="red")
        self.xspeed= 3
        self.yspeed= 4
 
    def move(self):
        canvas.move(self.shape, self.xspeed, self.yspeed)
        position= canvas.coords(ball)
        if position[3]>= 400 or position[1] <= 0:
            self.yspeed= -self.yspeed
        if position[2] >= 500 or position[0] <= 0:
            self.xspeed= -self.xspeed
         
ball1= Ball()
 
while True:
    ball1.move()
    tk.update()
    time.sleep(.01)
 
I do double underscore and I still get syntax error
Reply


Messages In This Thread
tkinter questions--- part 2 - by ironsheep - Dec-02-2018, 03:53 AM
RE: tkinter questions--- part 2 - by woooee - Dec-02-2018, 06:41 AM
RE: tkinter questions--- part 2 - by jfong - Dec-02-2018, 07:33 AM
RE: tkinter questions--- part 2 - by ironsheep - Dec-02-2018, 10:12 PM
RE: tkinter questions--- part 2 - by jfong - Dec-03-2018, 01:23 AM
RE: tkinter questions--- part 2 - by ironsheep - Dec-03-2018, 11:25 PM
RE: tkinter questions--- part 2 - by jfong - Dec-04-2018, 02:16 AM
RE: tkinter questions--- part 2 - by ironsheep - Dec-07-2018, 03:21 PM
RE: tkinter questions--- part 2 - by ironsheep - Dec-09-2018, 01:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter questions--- part 1 ironsheep 4 3,061 Nov-27-2018, 03:34 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020