ich hab da seit 2 Tagen ein Problem.
Und zwar habe ich unter Page Gui Builder mir Pythoncode (sind zwei Dateien support wo funktionen hinterlegt sind und eine Datei die den Aufbau des Gui beinhaltet)erstellen lassen und alles super und toll das Problem ist jetzt ich möchte als background eben ein Bild im Top Level haben. Habe schon einiges durchprobiert und irgendwas muss ich falsch machen, da einfach das Bild nicht reingeladen wird. Der Rest funktioniert wie gewohnt.
Vielleicht wisst ihr ja wo das Problem liegt. Ich bekomme nämlich auch keine Fehlermeldung ausgegeben
Anbei einmal der Beispielcode in Zeile 59-62 (top=tk.Canvas(top)) versuche ich das Bild einzufügen. Die Support Datei hab ich mal aus kommentiert, sodass die gar nicht aufgerufen werden muss.
Code: Alles auswählen
import sys
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
#import unknown_support
def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = tk.Tk()
top = Toplevel1 (root)
#unknown_support.init(root, top)
root.mainloop()
w = None
def create_Toplevel1(rt, *args, **kwargs):
'''Starting point when module is imported by another module.
Correct form of call: 'create_Toplevel1(root, *args, **kwargs)' .'''
global w, w_win, root
#rt = root
root = rt
w = tk.Toplevel (root)
top = Toplevel1 (w)
unknown_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_Toplevel1():
global w
w.destroy()
w = None
class Toplevel1:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#ececec' # Closest X11 color: 'gray92'
top.geometry("600x450+660+210")
top.minsize(120, 1)
top.maxsize(1924, 1061)
top.resizable(1, 1)
top.title("New Toplevel")
#top.configure(background="#d9d9d9")
top = tk.Canvas(top)
back_gnd_image = tk.PhotoImage(file="test.png")
top.create_image(0, 0, image=back_gnd_image)
if __name__ == '__main__':
vp_start_gui()