def phrase_text(self): # TODO: not a good way to have such fixed values smallest_y = 120 largest_y = 700 smallest_x = 10 largest_x = 300 return self.__canvas.create_text(random.randrange(smallest_x, largest_x), random.randrange(smallest_y, largest_y), anchor=Tkinter.SW, font=("system", 32), text=self.__phrase_var.get(), fill=get_random_color(), activefill=get_random_color())
def phrase_text(self): smallest_y = 0.1 * self.__root.winfo_screenheight() largest_y = 0.9 * self.__root.winfo_screenheight() smallest_x = 10 # Not so good to have fixed 0.25 value, maybe we can enhance it later largest_x = 0.25 * self.__root.winfo_screenwidth() from util.global_def import get_font_size return self.__canvas.create_text( random.randrange(int(smallest_x), int(largest_x)), random.randrange(int(smallest_y), int(largest_y)), anchor=Tkinter.SW, font=("system", -1 * get_font_size()), text=self.__phrase_var.get(), fill=get_random_color(), activefill=get_random_color())
def help_text(self): return self.__canvas.create_text(0, 0, anchor=Tkinter.NW, font=("system", -15), text=GraphViewer.help_str(), fill="red", activefill=get_random_color())
def info_text(self): text = self.__cur_digest if self.__pause_slideshow: text += "\n[PAUSED]" return self.__canvas.create_text(0, 20, anchor=Tkinter.NW, font=("system", -15), text=text, fill="blue", activefill=get_random_color())
def info_text(self): text = self.__cur_digest if self.__pause_slideshow: text += "\n[PAUSED]" return self.__canvas.create_text(0, 20, anchor=Tkinter.NW, font=("system", 15), text=text, fill="blue", activefill=get_random_color())
def help_text(self): return self.__canvas.create_text(0, 0, anchor=Tkinter.NW, font=("system", 15), text=GraphViewer.help_str(), fill="red", activefill=get_random_color())
print(image.format, image.mode) # image.show() root = Tkinter.Tk() tmp = None try: image = Image.open(graph_file2) # .convert("RGB") tmp = image except IOError as e: # some image cannot be opened (maybe it's not image format?), err msg is 'cannot identify image file' print("cannot open image", str(e)) root.geometry('%dx%d+0+0' % (image.size[0], image.size[1])) tk_image_obj = ImageTk.PhotoImage(tmp) label_image = Tkinter.Label(root, image=tk_image_obj) label_image.place(x=0, y=0, width=image.size[0], height=image.size[1]) label_image.pack() phrase_var = Tkinter.StringVar() phrase_var.set("some test phrase") phrase = Tkinter.Label(root, textvariable=phrase_var, bg='black', fg=get_random_color(), justify=Tkinter.LEFT, anchor=Tkinter.SW, font=("system", 32)) smallest_y = 120 largest_y = 300 smallest_x = 10 largest_x = 300 phrase.place(x=random.randrange(smallest_x, largest_x), y=random.randrange(smallest_y, largest_y)) root.mainloop()