本文整理汇总了Python中ttk.Label.photo方法的典型用法代码示例。如果您正苦于以下问题:Python Label.photo方法的具体用法?Python Label.photo怎么用?Python Label.photo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Label
的用法示例。
在下文中一共展示了Label.photo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import photo [as 别名]
def initUI(self):
# Style().configure("TButton", padding=(10, 10, 10, 10),
# font='serif 8', weight=1)
mri = Image.open("mri.jpg")
# mri.resize((w, h), Image.ANTIALIAS)
background_image=ImageTk.PhotoImage(mri)
background_label = Label(self, image=background_image)
background_label.photo=background_image
background_label.place(x=0, y=0, relheight=1)
self.columnconfigure(0, pad=10, weight=1)
self.columnconfigure(1, pad=10, weight=1)
self.columnconfigure(2, pad=20, weight=1)
self.rowconfigure(0, pad=20, weight=1)
self.rowconfigure(1, pad=20, weight=1)
self.rowconfigure(2, pad=20, weight=1)
self.customFont = tkFont.Font(family="Helvetica", size=15)
# Style().configure('green/black.TButton', foreground='yellow', background=tk_rgb, activefill="red",font=self.customFont)
entry = Entry(self) #TODO: REMOVE?
f = open('games.txt')
buttonArray = []
for i, line in enumerate(f):
line = line.split(':')
filename = line[0].translate(None, ' \n').lower()
imagefile = Image.open(filename + "-thumbnail.png")
image = ImageTk.PhotoImage(imagefile)
label1 = Label(self, image=image)
label1.image = image # + "\n" + line[1]
tk_rgb = "#%02x%02x%02x" % (100+35*(i%5), 50+100*(i%3), 70+80*(i%2))
button = (Button(self, text=line[0], image=image, compound="bottom", bd=0, bg=tk_rgb, font=self.customFont, command = lambda filename=filename :os.system("python " + filename + ".py")))
button.grid(row=i/3, column=i%3)
f.close()
self.pack(fill=BOTH, expand=1)
示例2: initUI
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import photo [as 别名]
def initUI(self):
self.parent.title("Sudoku")
Style().configure("TButton", padding=(0, 5, 0, 5),
font='serif 10')
#
#
# RWidth=self.parent.winfo_screenwidth()
# RHeight=self.parent.winfo_screenheight()
# self.parent.geometry(("%dx%d")%(RWidth,RHeight))
self.parent.geometry("1000x800")
menubar = Menu(self)
titlePhotoFrame = Frame(self)
titlePhotoFrame.grid(row = 4, column = 0)
frame = Frame(self)
frame.grid(row=0, column=0, padx=5)
space = Frame(self)
space.grid(row=1, column=0, pady=5)
timer_frame = Frame(self)
timer_frame.grid(row=2, column=0, pady=5)
# cells = [] # A list of variables tied to entries
# for i in range(9):
# cells.append([])
# for j in range(9):
# cells[i].append(StringVar())
#
# for i in range(9):
# for j in range(9):
# Entry(sudokuGrid, width = 3, justify = RIGHT,
# textvariable = cells[i][j]).grid(
# row = i+1, column = j+1)
drag1 = PhotoImage(file = "animated-dragon-image-0031.gif")
label = Label(frame, image = drag1)
label.photo = drag1
label.pack(side = "right", fill = "both", expand = "yes")
titlePhoto = PhotoImage(file = "SudokuTitl.gif")
label = Label(titlePhotoFrame, image = titlePhoto)
label.photo = titlePhoto
label.pack(side = "right", fill = "both", expand = "yes")
photo = PhotoImage(file = "dragon4.gif")
label = Label(frame, image = photo)
label.photo = photo
label.pack(side = "left", fill = "both", expand = "yes")
generate = Tkinter.Button(frame, height = 2, width = 6, text = "Generate", command = self.newPuzzle)
solvePuzzle = Tkinter.Button(frame, height = 2, width = 5, text = "Solve", command = self.solvePuzzle)
importPuzzle = Tkinter.Button(frame, height = 2, width = 5, text = "Import", command = self.readPuzzle)
#code to add widgets will go here...
generate.pack(side = RIGHT)
solvePuzzle.pack(side = RIGHT)
importPuzzle.pack(side = RIGHT)
filemenu = Menu(menubar, tearoff = 0)
filemenu.add_command(label="Generate Puzzle", command=self.newPuzzle)
filemenu.add_command(label="Import Puzzle", command=self.readPuzzle)
filemenu.add_command(label="Solve Puzzle", command=self.solvePuzzle)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=self.quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=self.donothing)
menubar.add_cascade(label="Edit", menu=editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=self.donothing)
helpmenu.add_command(label="About...", command=self.donothing)
menubar.add_cascade(label="Help", menu=helpmenu)
self.parent.config(menu = menubar)
self.pack()