ich versuche seit einiger Zeit ein Bild in ein GUI-Fenster einzufügen, habe allerdings noch nicht allzu viel Erfahrung mit Tkinter. Der folgende Code funktioniert wunderbar und das ganze sieht auch so aus, wie ich mir das vorgestellt hab.
Code: Alles auswählen
from Tkinter import *
from PIL import ImageTk, Image
root = Tk()
root.geometry("600x300")
img = ImageTk.PhotoImage(Image.open("wald.jpg"))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
labelFrame = LabelFrame(panel,text = "Wählen Sie")
labelFrame.pack(expand ="yes")
chosen = IntVar()
Radiobutton(labelFrame, text = "Option 1", variable = chosen, value = 1).pack(padx=50, pady=10)
Radiobutton(labelFrame, text = "Option 2", variable = chosen, value = 2).pack(padx=50, pady=10)
Button(labelFrame, text = "OK", width = "10").pack(padx=20, pady=10)
root.mainloop()Code: Alles auswählen
from Tkinter import *
from PIL import ImageTk, Image
class GUI(Frame):
def __init__ (self, master):
Frame.__init__(self, master)
self.pack(fill = "both", expand = "yes")
self.create_widgets()
def create_widgets(self):
img = ImageTk.PhotoImage(Image.open("wald.jpg"))
panel = Label(self, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
labelFrame = LabelFrame(panel,text = "Wählen Sie")
labelFrame.pack(expand ="yes")
chosen = IntVar()
Radiobutton(labelFrame, text = "Option 1", variable = chosen, value = 1).pack(padx=50, pady=10)
Radiobutton(labelFrame, text = "Option 1", variable = chosen, value = 2).pack(padx=50, pady=10)
Button(labelFrame, text = "OK", width = "10").pack(padx=20, pady=10)
root = Tk()
root.geometry("600x300")
app = GUI(root)
root.mainloop()Vielen Dank schon mal
