JavaScript won't change iframe src correctly

时间:2016-02-12 21:10:42

标签: javascript html iframe

I started taking an interest in JS recently and have been fooling about. I have wriiten some embedded JS in my HTML code and was wondering why it wasn't working properly. The code seems to always change the from tkinter import * from tkinter import filedialog import io from PIL import Image, ImageTk import zipfile class ComicDisplay(): def __init__(self, master): frame = Frame(master) frame.pack(fill='both', expand=1) self.parent = master self.fname = "" self.label = Label(frame, bg="brown", height=500) self.current_zip_file = filedialog.askopenfilename(filetypes=[(zip, "*.zip")]) # self.current_zip_file = "C:\\Users\\Alexis\\Dropbox\\Photos.zip" self.image_list = self.acquire_image_list(self.current_zip_file) self.current_image_number = 0 self.pil_image = self.acquire_image(self.current_zip_file, self.image_list[self.current_image_number]) self.tk_image = ImageTk.PhotoImage(self.pil_image) self.parent.title(self.fname) self.label.configure(image=self.tk_image) self.label.focus_set() self.label.bind("<Configure>", self.image_resizing) self.label.bind("<Left>", self.get_last_image) self.label.bind("<Right>", self.get_next_image) self.label.bind("<Button-1>", self.get_next_image) self.label.pack(padx=5, pady=5, fill='both', expand=1) def acquire_image_list(self, zip_file): image_list = [] with zipfile.ZipFile(zip_file, "r") as myFile: for filename in myFile.namelist(): image_list.append(filename) image_list.sort() return image_list def acquire_image(self, zip_file, image_file): with zipfile.ZipFile(zip_file, "r") as myFile: self.fname = image_file image_bytes = myFile.read(image_file) data_stream = io.BytesIO(image_bytes) pil_image = Image.open(data_stream) pil_image = self.image_sizer(pil_image) return pil_image def image_sizer(self, image_file, window_size=500): w, h = image_file.size if w > h: image_file_height = int(h*(window_size/w)) image_file = image_file.resize((window_size, image_file_height), Image.ANTIALIAS) else: image_file_width = int(w*(window_size/h)) image_file = image_file.resize((image_file_width, window_size), Image.ANTIALIAS) return image_file def image_resizing(self, event): new_height = root.winfo_height() - 14 new_size_image = self.image_sizer(self.pil_image, new_height) self.tk_image = ImageTk.PhotoImage(new_size_image) self.label.configure(image=self.tk_image) def get_next_image(self, event): if self.current_image_number >= len(self.image_list)-1: self.current_image_number = 0 else: self.current_image_number += 1 self.update_image() def get_last_image(self, event): if self.current_image_number == 0: self.current_image_number = len(self.image_list)-1 else: self.current_image_number -= 1 self.update_image() def update_image(self): self.fname = self.image_list[self.current_image_number] self.pil_image = self.acquire_image(self.current_zip_file, self.image_list[self.current_image_number]) self.tk_image = ImageTk.PhotoImage(self.pil_image) self.parent.title(self.fname) self.image_resizing(None) root = Tk() app = ComicDisplay(root) root.mainloop() to src no matter which box is selected. Test this here.

http://www.learn ... fillitin_mult_twelve.xml

2 个答案:

答案 0 :(得分:0)

for (int i = Scopes.size(); i > 0; i--) {
    auto ret = lookup_helper(key, Scopes[i]);
    if (ret) {
        return ret;
    }
}

is setting the value of strUser to "1" and it repeats the process, setting it n+1 until it gets to the last else if statement, which is why strUser always ends up being equal to 12.

You need to use two equal signs if you want to compare the values (instead of set a value).

strUser = "1"

答案 1 :(得分:0)

The problem is your comparation .root{ -fx-background-color: linear-gradient(#383838, #838383); -fx-font-size: 11pt; } .label{ -fx-text-fill: #e8e8e8; } .button{ -fx-background-color: linear-gradient(#dc9556, #ab4642); -fx-background-radius: 100; } .text-area{ -fx-background-color: white; -fx-background-radius: 0; } . Instead, use =

相关问题