def lay_org_image(self, parent): frame = tk.Frame(parent, bg=Color.r_whitesmoke, width=350) self.org_img = tku.ImageLabel(frame, width=300, height=300) self.org_img.pack(side=tk.TOP, fill=tk.Y, padx=10, pady=5) self.org_img.set_image(img("flower.jpg")) self.org_img.bind('<Button-1>', self.do_choice_image) self.target_file_name = img("flower.jpg") self.style_img = tku.ImageLabel(frame, width=300, height=300) self.style_img.pack(side=tk.TOP, padx=10, pady=5) self.style_img.set_image(img("style.jpg")) self.style_img.bind('<Button-1>', self.do_choice_style_image) self.style_file_name = img("style.jpg") # 设置缺省风格格式文件 tk.Button(frame, text=" 目标图片 ", bg="LightBlue", font=Font.r_normal, command=self.do_choice_image)\ .pack(side=tk.LEFT, fill=tk.X, padx=20) tk.Button(frame, text=" 风格图片 ", bg="LightYellow", font=Font.r_normal, command=self.do_choice_style_image)\ .pack(side=tk.LEFT, fill=tk.X) tk.Button(frame, text="开始转换", bg="LightGreen", font=Font.r_medium_title, command=self.do_transfer)\ .pack(side=tk.RIGHT, fill=tk.X, padx=20) frame.propagate(True) frame.pack_propagate(0) return frame
def lay_result_image(self, parent): frame = tk.Frame(parent, bg=Color.r_white) fra_result = tk.Frame(frame, bg=Color.r_white) fra_result.pack(expand=tk.YES, fill=tk.BOTH, pady=5) fra_result.pack_propagate(0) self.final_img = tku.ImageLabel(fra_result, width=460, height=460) self.final_img.pack(side='top', padx=10, pady=10) self.final_img.set_image(img("style_flower.png")) # self.final_img.bind('<Button-1>', self.do_browser_workspace) menu_res = tk.Menu(self.final_img, tearoff=0) menu_res.add_command(label="显示大图", command=self.show_genImage) def popupmenu(event): menu_res.post(event.x_root, event.y_root) self.final_img.bind('<Button-1>', self.do_browser_workspace) self.final_img.bind('<Button-3>', popupmenu) tk.Button(fra_result, text=" 图片生成目录 ", bg="LightBlue", font=Font.r_small_content, command=self.do_browser_workspace) \ .pack(side=tk.BOTTOM, anchor='se', padx=10) return frame
def __init__(self): tku.WinBase.__init__(self) self.title = String.r_app_title self.set_size(1024, 768) self.set_icon(img("Money.ico")) self.lay_body()
def lay_org_image(self, parent): frame = tk.Frame(parent, bg=Color.r_whitesmoke, width=350) self.org_img = tku.ImageLabel(frame, width=300, height=300) self.org_img.pack(side=tk.TOP, fill=tk.Y, padx=10, pady=5) self.org_img.set_image(img("mai.jpg")) self.target_file_name = img("mai.jpg") menu_org = tk.Menu(self.org_img, tearoff=0) menu_org.add_command(label="显示大图", command=self.show_conImage) menu_org.add_command(label="更改图片", command=self.do_choice_image) def popupmenu(event): menu_org.post(event.x_root, event.y_root) self.org_img.bind('<Button-1>', self.do_choice_image) self.org_img.bind('<Button-3>', popupmenu) self.style_img = tku.ImageLabel(frame, width=300, height=300) self.style_img.pack(side=tk.TOP, padx=10, pady=5) self.style_img.set_image(img("scream.jpg")) self.style_img.bind('<Button-1>', self.do_choice_style_image) self.style_file_name = img("scream.jpg") # 设置缺省风格格式文件 # tk.Button(frame, text=" 目标图片 ", bg="LightBlue", font=Font.r_normal, command=self.do_choice_image) \ # .pack(side=tk.LEFT, fill=tk.X, padx=20) # tk.Button(frame, text=" 风格图片 ", bg="LightYellow", font=Font.r_normal, command=self.do_choice_style_image) \ # .pack(side=tk.LEFT, fill=tk.X) # tk.Button(frame, text="开始转换", bg="LightGreen", font=Font.r_medium_title, command=self.do_transfer) \ # .pack(side=tk.RIGHT, fill=tk.X, padx=20) tk.Button(frame, text=" 内容图片 ", bg="LightBlue", font=Font.r_normal, command=self.do_choice_image) \ .pack(side=tk.LEFT, fill=tk.X, padx=1) tk.Button(frame, text=" 风格图片 ", bg="LightYellow", font=Font.r_normal, command=self.do_choice_style_image) \ .pack(side=tk.LEFT, fill=tk.X, padx=1) tk.Button(frame, text=" 视频效果", bg="LightBlue", font=Font.r_normal, command=self.do_play_video) \ .pack(side=tk.LEFT, fill=tk.X, padx=1) tk.Button(frame, text="开始转换", bg="LightGreen", font=Font.r_normal, command=self.do_transfer) \ .pack(side=tk.LEFT, fill=tk.X, padx=1) frame.propagate(True) frame.pack_propagate(0) return frame
def lay_title(self, parent): """ 标题栏 """ frame = tk.Frame(parent, bg="black") def _label(_frame, text, size=12, bold=False): return tku.label(_frame, text, size=size, bold=bold, bg="black", fg="white") def _button(_frame, text, size=12, bold=False, width=12, command=None): # bg = DarkSlateGray return tk.Button(_frame, text=text, bg="black", fg="white", width=width, height=2, font=tku.font(size=size, bold=bold), relief=tk.FLAT, command=command) _label(frame, String.r_app_title, 16, True).pack(side=tk.LEFT, padx=10) _label(frame, "").pack(side=tk.LEFT, padx=50) # 用于布局的空字符串 _label(frame, "").pack(side=tk.RIGHT, padx=5) _button(frame, "退出", width=8, command=self.do_close).pack(side=tk.RIGHT, padx=15) tku.image_label(frame, img("user.png"), 40, 40, False).pack(side=tk.RIGHT) return frame
def lay_result_image(self, parent): frame = tk.Frame(parent, bg=Color.r_white) fra_result = tk.Frame(frame, bg=Color.r_white) fra_result.pack(expand=tk.YES, fill=tk.BOTH, pady=5) fra_result.pack_propagate(0) self.final_img = tku.ImageLabel(fra_result, width=460, height=460) self.final_img.pack(side='top', padx=10, pady=10) self.final_img.set_image(img("style_flower.png")) self.final_img.bind('<Button-1>', self.do_browser_workspace) tk.Button(fra_result, text=" 图片生成目录 ", bg="LightBlue", font=Font.r_small_content, command=self.do_browser_workspace)\ .pack(side=tk.BOTTOM, anchor='se', padx=10) # -------------------------------------------------------------- self.fra_output = tk.Frame(frame, height=200, bg=Color.r_whitesmoke) self.fra_output.pack(side=tk.BOTTOM, fill=tk.X) self.fra_output.pack_propagate(0) # fra_output-tabControl self.tabControl = ttk.Notebook(self.fra_output) # Create Tab Control self.tabControl.pack(side=tk.TOP, fill=tk.X, anchor=tk.NW) # fra_output - tabControl - tabParameters tabParameters = ttk.Frame(self.tabControl) self.tabControl.add(tabParameters, text='参数设置') f1 = tk.Frame(tabParameters) f1.pack(side='top', fill='x', pady=10) tk.Label(f1, text="循环次数", font=Font.r_small_title).pack(side='left', anchor='w', pady=3, padx=10) txtIterations = tk.Entry(f1, width=40, font=Font.r_normal) txtIterations.pack(side='left', anchor='n', padx=30, pady=3) self.txtIterations = txtIterations f2 = tk.Frame(tabParameters) f2.pack(side='top', fill='x') tk.Label(f2, text="内容权重", font=Font.r_small_title).pack(side='left', anchor='w', pady=3, padx=10) txtContent = tk.Entry(f2, width=40, font=Font.r_normal) txtContent.pack(side='left', anchor='n', padx=30, pady=3) self.txtContent = txtContent f3 = tk.Frame(tabParameters) f3.pack(side='top', fill='x', pady=10) tk.Label(f3, text="风格权重", font=Font.r_small_title).pack(side='left', anchor='w', pady=3, padx=10) txtStyle = tk.Entry(f3, width=40, font=Font.r_normal) txtStyle.pack(side='left', anchor='n', padx=30, pady=3) self.txtStyle = txtStyle # fra_output - tabControl - tabOutput self.tabOutput = ttk.Frame(self.tabControl) # Create a tab self.tabControl.add(self.tabOutput, text='处理信息') txtOutput = tk.Text(self.tabOutput, font=Font.r_small_content) ysb = ttk.Scrollbar(self.tabOutput, orient="vertical", command=txtOutput.yview) # y滚动条 ysb.pack(side='right', fill='y') txtOutput.configure(yscrollcommand=ysb.set) txtOutput.pack(expand='yes', fill='both') self.txtOutput = txtOutput return frame