from Tkinter import *
import tkMessageBox
import Tkinter
import tkFileDialog
def donothing():
print "a"
def file_save():
name=asksaveasfile(mode='w',defaultextension=".txt")
text2save=str(text.get(0.0,END))
name.write(text2save)
name.close
root = Tk()
root.geometry("500x500")
menubar=Menu(root)
text=Text(root)
text.pack()
filemenu=Menu(menubar,tearoff=0)
filemenu.add_command(label="New", command=donothing)
filemenu.add_command(label="Open", command=donothing)
filemenu.add_command(label="Save", command=file_save)
filemenu.add_command(label="Save as...", command=donothing)
filemenu.add_command(label="Close", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu=Menu(menubar,tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_command(label="Copy", command=donothing)
editmenu.add_command(label="Paste", command=donothing)
menubar.add_cascade(label="Edit", menu=editmenu)
helpmenu=Menu(menubar,tearoff=0)
helpmenu.add_command(label="Help",command=donothing)
menubar.add_cascade(label="Help",menu=helpmenu)
root.config(menu=menubar)
root.mainloop()
from tkinter import *
canvas_width = 700
canvas_height = 500
brush_size = 3
color = 'black'
def paint(event):
global brush_size
global color
x1 = event.x - brush_size
x2 = event.x + brush_size
y1 = event.y - brush_size
y2 = event.y + brush_size
w.create_oval(x1, y1, x2, y2,
fill = color, outline = color)
def brish_size_change(new_size):
global brush_size
brush_size = new_size
def color_change (new_color):
global color
color = new_color
root = Tk()
root.title('Paint')
w = Canvas(root,
width = canvas_width,
height = canvas_height,
bg='white',
cursor = "pencil")
w.bind('<B1-Motion>', paint)
black_btn = Button(text = "Чёрный", width = 10,
command=lambda: color_change("black"))
red_btn = Button(text = 'Красный', width = 10,
command = lambda:color_change("red"))
blue_btn = Button(text = 'Синий', width = 10,
command = lambda:color_change("blue"))
white_btn = Button(text = "Ластик", width = 10,
command=lambda: color_change("white"))
clear_btn = Button(text = "Удалить всё", width = 10,
command=lambda: w.delete("all"))
w.grid(row = 2, column = 0,
columnspan = 7, padx = 5,
pady = 5, sticky = E+W+S+N)
w.columnconfigure(6, weight = 1)
w.rowconfigure(2, weight = 1)
black_btn.grid(row = 0, column = 1)
red_btn.grid(row = 0, column = 2)
blue_btn.grid(row = 0, column = 3)
white_btn.grid(row = 0, column = 4)
clear_btn.grid(row = 0, column = 6, sticky = W)
root.mainloop()
Как это реализовать например с вот этим кодом?