Найти - Пользователи
Полная версия: Помогите найти ошибку.
Начало » Центр помощи » Помогите найти ошибку.
1 2
simonovaleksandr
И чтобы от линии не оставался след, тоже подскажите пожалуйста
как надо сделать
rami
Так, наверно:

 from tkinter import Tk, Canvas
 
root = Tk()
root.minsize(width=300, height=300)
root.resizable(0, 0)
c = Canvas(root, width=300, height=300)
c.pack()
line1 = c.create_line(100, 100, 200, 100)
 
def Right(event):
    if event.keysym == 'Up':
        c.move(line1, 0, -1)
 
c.bind_all('<KeyPress-Up>', Right)
root.mainloop()
simonovaleksandr
Я исправил ошибку, но при работе программы правая точка линии
опускается только на 1 пиксель ,и дальше при нажатии PgUp не опускается.
Помогите пожалуйста эту проблему решить.
Вот код :
from tkinter import *
root=Tk()
root.minsize(width=300,height=300)
root.resizable(0,0)
c=Canvas(root,width=300,height=300 )
c.pack()
def Right(event):
if event.keysym=='Up':
y=100
y=y+1
print(“нажата клавиша”)
c.create_line(100,100,200,y)
c.bind_all('KeyPress-Up',Right)
root.mainloop()
simonovaleksandr
Аа я думал вы еще не проверили, только потом увидел
simonovaleksandr
Здравствуйте , я хотел написать программу по перемещению ПРАВОЙ ТОЧКИ линии по вертикальной оси с
помощью нажатия на клавиши PgUp PgDn ,но не знаю как это сделать , помогите пожалуйста
Вот наброски:

from tkinter import *
root=Tk()
root.minsize(width=300,height=300)
root.resizable(0,0)
c=Canvas(root,width=300,height=300 )
c.pack()
y2=100
line1 = c.create_line(100, 100, 200, y2)
def up(event):
if event.keysym=='Up':
c.move(line1, 0, -1)
print(c.winfo_width())
if event.keysym=='Down':
c.move(line1, 0, +1)
c.update()
c.bind_all('<KeyPress-Up>',up)
c.bind_all('<KeyPress-Down>',up)
root.mainloop()
rami
 from tkinter import Tk, Canvas
 
root = Tk()
root.minsize(width=300, height=300)
root.resizable(0, 0)
c = Canvas(root, width=300, height=300)
c.pack()
line1 = c.create_line(100, 100, 200, 100)
 
def Right(event):
    line1_coords = c.coords(line1)
    if event.keysym == 'Up':
        y = -9
    elif event.keysym == 'Down':
        y = 9
 
    line1_coords[3] += y
    c.coords(line1, line1_coords)
 
 
c.bind_all('<KeyPress-Up>', Right)
c.bind_all('<KeyPress-Down>', Right)
root.mainloop()
simonovaleksandr
.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB