Feb-16-2018, 09:02 PM
Feb-16-2018, 09:10 PM
Attributes can always be checked.
Color is an attribute.
So the answer is yes.
Color is an attribute.
So the answer is yes.
Feb-17-2018, 07:56 AM
So, can you please give me the command? Thanks. ;)
Feb-17-2018, 02:35 PM
There is no one command.
It all depends on context.
please show some code, and specifically what 'under you' pertains to.
It all depends on context.
please show some code, and specifically what 'under you' pertains to.
Feb-17-2018, 05:23 PM
Like, if a turtle is touching a pecific color.
Code for the "tron" game(dosen't have the death function, please code it for me):
Code for the "tron" game(dosen't have the death function, please code it for me):
import turtle troncycle = turtle.Turtle() troncycle1 = turtle.Turtle() screen = turtle.Screen() troncycle.pensize(1) troncycle.color("blue") troncycle.pencolor("blue") troncycle1.pensize(1) troncycle1.color("orange") troncycle1.pencolor("orange") def moveforward(): troncycle.forward(10) def moveforward1(): troncycle1.forward(10) def moveright(): troncycle.right(90) def moveleft(): troncycle.left(90) def moveright1(): troncycle1.right(90) def moveleft1(): troncycle1.left(90) troncycle.forward(1) troncycle1.forward(1) screen.onkeypress(moveright, "Right") screen.onkeypress(moveleft, "Left") screen.onkeypress(moveright1, "d") screen.onkeypress(moveleft1, "a") screen.onkeypress(moveforward1, "w") screen.onkeypress(moveforward, "Up") screen.listen() screen.mainloop()
Feb-17-2018, 06:09 PM
Feb-17-2018, 06:21 PM
sorry, but I just don't understand it...
Feb-17-2018, 07:25 PM
Ok, I'm not a turtle guy, so you're going to have to play with this to get what you want, but
here's a routine to get the canvas attributes:
here's a routine to get the canvas attributes:
import turtle troncycle = turtle.Turtle() troncycle1 = turtle.Turtle() screen = turtle.Screen() troncycle.pensize(1) troncycle.color("blue") troncycle.pencolor("blue") troncycle1.pensize(1) troncycle1.color("orange") troncycle1.pencolor("orange") def moveforward(): troncycle.forward(10) def moveforward1(): troncycle1.forward(10) def moveright(): troncycle.right(90) def moveleft(): troncycle.left(90) def moveright1(): troncycle1.right(90) def get_color(): cv = screen.getcanvas() cvitems = cv.__dict__ for attribute in cvitems.items(): print(attribute) def moveleft1(): troncycle1.left(90) troncycle.forward(1) troncycle1.forward(1) screen.onkeypress(moveright, "Right") screen.onkeypress(moveleft, "Left") screen.onkeypress(moveright1, "d") screen.onkeypress(moveleft1, "a") screen.onkeypress(moveforward1, "w") screen.onkeypress(moveforward, "Up") get_color() screen.listen() screen.mainloop()which will show:
Output:('widgetName', 'frame')
('master', <turtle._Root object .>)
('tk', <_tkinter.tkapp object at 0x000000000298F430>)
('_name', '!scrolledcanvas')
('_w', '.!scrolledcanvas')
('children', {})
('_tclCommands', [])
('_rootwindow', <turtle._Root object .>)
('width', 0.5)
('height', 0.75)
('canvwidth', 400)
('canvheight', 300)
('bg', 'white')
('_canvas', <tkinter.Canvas object .!canvas>)
('hscroll', <tkinter.Scrollbar object .!scrollbar>)
('vscroll', <tkinter.Scrollbar object .!scrollbar2>)
so to access just the color, (once cv has been defined) x = cv.bgx = cv.bg print('the color of x is: {}'.format(x))
Output:the color of x is: white