Was mache ich falsch, fehlt etwas?PhotoImage(file='www.gif')
Dankefür eure Hilfe,das macht mich wahnsinnig^^
Was mache ich falsch, fehlt etwas?PhotoImage(file='www.gif')
Code: Alles auswählen
from Tkinter import *
root = Tk()
c = Canvas(root, width="2c",height="2c")
c.pack()
bild = PhotoImage(file=r"/home/sabba/in/mr_snede-calvin.gif")
c.create_image(0, 0, anchor=NW, image=bild)
root.mainloop()
Code: Alles auswählen
Button(image=bild)
Label(image=bild)
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: cp1252 -*-
IN_IDLE = 0
import sys
from Tkinter import *
class HauptFenster:
def __init__(self):
self.root=Tk()
self.root.title("Quiz")
self.b_1=Button(self.root,text="starten",command=quiz)
self.b_1.pack()
Label(image='unbenannt.gif')
class quiz:
def __init__(self):
self.root=Tk()
self.root.title("Quiz")
self.choice=StringVar()
self.database=DataBase('localhost','irgendwer','einedatenbank','einetabelle','ein....')
self.cols_names=["1","2","3","4"]
# Spaltennamen, der aktuellen Tabelle werden ermittelt
# TEXT?? FRAGEN?? ##
#entsprechend den ermittelten Namen wird das SF dynamisch aufgebaut
for i in range(len(self.cols_names)):
self.rb=Radiobutton(self.root,text=self.cols_names[i],
value=self.cols_names[i],
variable=self.choice)
self.rb.grid(row=i+2,column=1)
self.b_1=Button(self.root,text="antworten",command=self.get_selected)
self.b_1.grid(row=i+1,column=0)
self.root.mainloop()
def get_selected(self):
choice=self.choice.get()
print choice
# Funktion zum Testen was ausgegeben wird.
# Wie oben beschrieben Ergebnis nur, wenn es alleine verwendet wird.
if __name__=="__main__":
hf=HauptFenster()
Code: Alles auswählen
Traceback (most recent call last):
File "\test.py", line 77, in ?
hf=HauptFenster()
File "\test.py", line 17, in __init__
c = Canvas(root, width="2c",height="2c")
NameError: global name 'root' is not defined
Code: Alles auswählen
Label(image="unbenannt.gif")
Code: Alles auswählen
bild = PhotImage(file="unbenannt.gif")
Label(image=bild)
Code: Alles auswählen
Traceback (most recent call last):
File "test.py", line 75, in ?
hf=HauptFenster()
File "test.py", line 17, in __init__
bild = PhotImage(file="www.gif")
NameError: global name 'PhotImage' is not defined
PhotoImage ist schon definiert, aber PhotImage nichtnobody hat geschrieben: bild = PhotImage(file="www.gif")
NameError: global name 'PhotImage' is not defined
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "test.py", line 33, in __init__
self.database=DataBase('localhost','irgendwer','einedatenbank','einetabelle','ein....')
NameError: global name 'DataBase' is not defined
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "test.py", line 33, in __init__
self.database=DataBase('localhost','irgendwer','einedatenbank','einetabelle','ein....')
NameError: global name 'DataBase' is not defined
Code: Alles auswählen
from Tkinter import *
from PIL import Image, ImageTk
root = Tk()
image = Image.open('homer.jpg')
photo = ImageTk.PhotoImage(image)
Label(image=photo).pack()
root.mainloop()
Code: Alles auswählen
roots = Frame(root, padx=120, pady=105)
roots.config(background="#990000")
roots.grid(row=0,column=0,sticky=N+E+S+W)
roots.master.title("...")
Code: Alles auswählen
image = Image.open('logo schwarz.jpg')
photo = ImageTk.PhotoImage(image)
Label(roots, width="5c", height="1c", image=photo).grid(sticky=W, pady=15)
Code: Alles auswählen
c = Canvas(roots, width="5c", height="1c") # c = Leinwand, mit Logo drin
c.grid(sticky=W, pady=15)
bild = PhotoImage(file=r"C:\Documents and Settings\Desktop\logo schwarz.gif") #Pfadangabe des Logos
c.create_image(0, 0, image=bild)