Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tkinter as tk
from PIL import Image, ImageDraw, ImageFont, ImageTk
APP_TITLE = "Save Canvas Image"
APP_XPOS = 100
APP_YPOS = 100
APP_WIDTH = 500
APP_HEIGHT = 400
WHITE = (255, 255, 255)
class MyGraph(tk.Frame):
def __init__(self, app_win, **kwargs):
self.app_win = app_win
tk.Frame.__init__(self, app_win, **kwargs)
self.graph_plane = Image.new("RGB", (200, 200), WHITE)
self.drawing = ImageDraw.Draw(self.graph_plane)
self.label_image = ImageTk.PhotoImage(self.graph_plane)
self.draw_frame = tk.Label(self, image=self.label_image)
self.draw_frame.pack(expand=True)
def main():
app_win = tk.Tk()
app_win.title(APP_TITLE)
app_win.geometry("+{}+{}".format(APP_XPOS, APP_YPOS))
app_win.geometry("{}x{}".format(APP_WIDTH, APP_HEIGHT))
app = MyGraph(app_win, bg='steelblue').pack(fill='both', expand=True)
app_win.mainloop()
if __name__ == '__main__':
main()