أنا أدرس ذاتي بيثون (ببطء!) وقد بنيت برنامجًا أساسيًا للطلاء حيث يمكن تغيير "لون الفرشاة" وهذا يتعلق به ... يمكن رسم مربعات النقرات على الرغم من ذلك وأراد معرفة ما إذا كان من الممكن جعل هذه المنطقة التي لا يمكن رسمها فيها؟ أنا أتطلع أيضًا إلى الحصول على خيارات إضافية في تغيير حجم "الفرشاة" وإدراج الشكل ، لذا فإن أي تلميحات ونصائح حول هذا سيكون موضع تقدير!
استيراد طباعة tkinter ("لرسم ، ومكملة زر الماوس الأيسر ونقل المؤشر.") طباعة ("لتغيير لون الفرشاة ، انقر فوق أحد الألوان.") window = tkinter.tk () canvas = tkinter.canvas (window ، width = 800 ، height = 600 ، bg = "white") canvas. Global LastX ، lasty lastx = event.x lasty = event.y def on_click (event): store_position (event) def on_drag (event): canvas.create_line (lastx ، lasty ، event.x ، event.y ، fill = color ، width = 3) store_position (event) canvas.bind ("" ، on_click) canvas.create_rectangle (10 ، 10 ، 30 ، 30 ، 30 ، fill = "red") blue_id = canvas.create_rectangle (10 ، 35 ، 30 ، 55 ، fill = "blue") black_id = canvas.create_rectangle (10 ، 60 ، 30 ، 80 ، "black") white_id = canvas 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 = set_colour_blue (الحدث): color color global = "blue" def set_colour_black (event): global color color = "black" def set_colour_white (event): global color color = "white" def set_colour_cyan (event): Global Color = "cyan "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 (white_id ، " canvas.tag_bind (cyan_id ، "" ، set_colour_cyan) canvas.tag_bind (yellow_id ، "" ، set_colour_yellow) canvas.tag_bind (green_id ، "" ، set_colour_green) window.mainloop ()