私はPython(ゆっくり!)を自己ティーチングしていて、ブラシ「色」を変更できる基本的なペイントプログラムを構築しました。それはそれについてです...クリックボックスは描画できます。また、「ブラシ」サイズやシェイプインサートを変更するなど、追加のオプションがあることを探しているので、これに関するヒントやヒントをいただければ幸いです。
TKINTERプリントをインポートします( "描画、左マウスボタンを押し、カーソルを移動します。")印刷(「ブラシの色を変更するには、色の1つをクリックします。」)ウィンドウ= tkinter.tk()canvas = tkinter.canvas(window、width = 800、height = 600、bg = "white")canvas.pack( lastx、lastey lastx = event.x lasty = event.y def on_click(event):store_position(event)def on_drag(event):canvas.create_line(lastx、event、event.x、event.y、fill = color、width = 3)store_position(event)canvas.bind( " canvas.create_rectangle(10、10、30、30、fill = "red")blue_id = canvas.create_rectangle(10、35、30、55、fill = "blue")black_id = canvas.create_rectangle(10、60、30、80、fill = "fill =" black ")white_id = canvas.createe(10、10、10、10、10、10、10、10、10、10、30、10、30、30、30、105、105、 "white") cyan_id = canvas.create_rectangle(10, 110, 30, 130, fill = "cyan") yellow_id = canvas.create_rectangle(10, 135, 30, 155, fill = "yellow") green_id = canvas.create_rectangle(10, 160, 30, 180, fill = "green") def set_colour_red(event): global colour colour = "red" def set_colour_blue(イベント):グローバルカラー= "blue" def set_colour_black(event):global color = "black" def set_colour_white(event):global color = "white" def set_colour_cyan(event):global color color = "cyan" def set_colour_ yeven(event ":" def ")グローバルカラー= "green" canvas.tag_bind(red_id、 ""、set_colour_red)canvas.tag_bind(blue_id、 ""、set_colour_blue)canvas.tag_bind(black_id、 "、"、 "、set_colour_black)canvas.tag_bind(set_colous canvas.tag_bind(cyan_id、 ""、set_colour_cyan)canvas.tag_bind(yellow_id、 ""、set_colour_yello)canvas.tag_bind(green_id、 "、"、set_colour_green)windop.mainloop()