Python tkinter.NW Examples
The following are 30
code examples of tkinter.NW().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 6 votes |
def create_top_display(self): frame = tk.Frame(self.root) glass_frame_image = tk.PhotoImage(file='../icons/glass_frame.gif') self.canvas = tk.Canvas(frame, width=370, height=90) self.canvas.image = glass_frame_image self.canvas.grid(row=1) self.console = self.canvas.create_image( 0, 10, anchor=tk.NW, image=glass_frame_image) self.clock = self.canvas.create_text(125, 68, anchor=tk.W, fill='#CBE4F6', text="00:00") self.track_length_text = self.canvas.create_text(167, 68, anchor=tk.W, fill='#CBE4F6', text="of 00:00") self.track_name = self.canvas.create_text(50, 35, anchor=tk.W, fill='#9CEDAC', text='\"Currently playing: none \"') self.seek_bar = Seekbar( frame, background="blue", width=SEEKBAR_WIDTH, height=10) self.seek_bar.grid(row=2, columnspan=10, sticky='ew', padx=5) frame.grid(row=1, pady=1, padx=0)
Example #2
Source File: display_command.py From faceswap with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, previewname): logger.debug("Initializing %s: (previewname: '%s')", self.__class__.__name__, previewname) ttk.Frame.__init__(self, parent) self.name = previewname get_images().resize_image(self.name, None) self.previewimage = get_images().previewtrain[self.name][1] self.canvas = tk.Canvas(self, bd=0, highlightthickness=0) self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True) self.imgcanvas = self.canvas.create_image(0, 0, image=self.previewimage, anchor=tk.NW) self.bind("<Configure>", self.resize) logger.debug("Initialized %s:", self.__class__.__name__)
Example #3
Source File: control_helper.py From faceswap with GNU General Public License v3.0 | 6 votes |
def get_group_frame(self, group): """ Return a new group frame """ group = group.lower() if self.group_frames.get(group, None) is None: logger.debug("Creating new group frame for: %s", group) is_master = group == "_master" opts_frame = self.optsframe.subframe if is_master: group_frame = ttk.Frame(opts_frame, name=group.lower()) else: group_frame = ttk.LabelFrame(opts_frame, text="" if is_master else group.title(), name=group.lower()) group_frame.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5, anchor=tk.NW) self.group_frames[group] = dict(frame=group_frame, chkbtns=self.checkbuttons_frame(group_frame)) group_frame = self.group_frames[group] return group_frame
Example #4
Source File: CInScan02.py From mcculw with MIT License | 6 votes |
def create_widgets(self): '''Create the tkinter UI''' if self.chan_num != -1: self.results_group = tk.LabelFrame( self, text="Results", padx=3, pady=3) self.results_group.pack( fill=tk.X, anchor=tk.NW, padx=3, pady=3) self.data_frame = tk.Frame(self.results_group) self.data_frame.grid() button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) self.start_button = tk.Button(button_frame) self.start_button["text"] = "Start" self.start_button["command"] = self.start self.start_button.grid(row=0, column=0, padx=3, pady=3) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.master.destroy quit_button.grid(row=0, column=1, padx=3, pady=3) else: self.create_unsupported_widgets(self.board_num)
Example #5
Source File: DeepBrainSegUI.py From DeepBrainSeg with MIT License | 6 votes |
def Load_Flair(self, event=None): self.Flairfilename = filedialog.askopenfilename() nib_vol = nib.load(self.Flairfilename) self.affine = nib_vol.affine self.Flair_vol = nib_vol.get_data() mid_slice = self.Flair_vol.shape[2]//2 true_size = self.Flair_vol.shape[:2] size = (self.Flair_canvas.winfo_width(), self.Flair_canvas.winfo_height()) size = (size[0], int(true_size[0]/true_size[1])*size[1]) if size[0] < size[1] else (int(true_size[1]/true_size[0])*size[0], size[1]) self.Flair_canvas_image = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(plot_normalize(self.Flair_vol[:,:,mid_slice].T)).resize(size)) self.Flair_canvas.create_image(0, 0, image=self.Flair_canvas_image, anchor=tk.NW) self.update_main_view(self.Flair_vol, self.Flair_vol.shape[0]//2, self.Flair_vol.shape[1]//2, self.Flair_vol.shape[2]//2) self.init_scales(self.Flair_vol)
Example #6
Source File: tkvt100.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def _write(self, ch, fg, bg): if self.x == self.width: self.x = 0 self.y+=1 if self.y == self.height: [self.canvas.move(x,0,-fontHeight) for x in self.canvas.find_all()] self.y-=1 canvasX = self.x*fontWidth + 1 canvasY = self.y*fontHeight + 1 items = self.canvas.find_overlapping(canvasX, canvasY, canvasX+2, canvasY+2) if items: [self.canvas.delete(item) for item in items] if bg: self.canvas.create_rectangle(canvasX, canvasY, canvasX+fontWidth-1, canvasY+fontHeight-1, fill=bg, outline=bg) self.canvas.create_text(canvasX, canvasY, anchor=Tkinter.NW, font=ttyFont, text=ch, fill=fg) self.x+=1
Example #7
Source File: icon_list.py From LIFX-Control-Panel with MIT License | 6 votes |
def draw_bulb_icon(self, bulb, label): """ Given a bulb and a name, add the icon to the end of the row. """ # Make room on canvas self.scrollx += self.icon_width self.canvas.configure(scrollregion=(0, 0, self.scrollx, self.scrolly)) # Build icon path = self.icon_path() sprite = tkinter.PhotoImage(file=path, master=self.master) image = self.canvas.create_image( (self.current_icon_width + self.icon_width - self.pad, self.icon_height / 2 + 2 * self.pad), image=sprite, anchor=tkinter.SE, tags=[label]) text = self.canvas.create_text(self.current_icon_width + self.pad / 2, self.icon_height / 2 + 2 * self.pad, text=label[:8], anchor=tkinter.NW, tags=[label]) self.bulb_dict[label] = (sprite, image, text) self.update_icon(bulb) # update sizing info self.current_icon_width += self.icon_width
Example #8
Source File: DeepBrainSegUI.py From DeepBrainSeg with MIT License | 6 votes |
def Load_T1(self, event=None): self.T1filename = filedialog.askopenfilename() nib_vol = nib.load(self.T1filename) self.affine = nib_vol.affine self.T1_vol = nib_vol.get_data() mid_slice = self.T1_vol.shape[2]//2 true_size = self.T1_vol.shape[:2] size = (self.T1_canvas.winfo_width(), self.T1_canvas.winfo_height()) size = (size[0], int(true_size[0]/true_size[1])*size[1]) if size[0] < size[1] else (int(true_size[1]/true_size[0])*size[0], size[1]) self.T1_canvas_image = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(plot_normalize(self.T1_vol[:,:,mid_slice].T)).resize(size)) self.T1_canvas.create_image(0, 0, image=self.T1_canvas_image, anchor=tk.NW) self.update_main_view(self.T1_vol, self.T1_vol.shape[0]//2, self.T1_vol.shape[1]//2, self.T1_vol.shape[2]//2) self.init_scales(self.T1_vol)
Example #9
Source File: itemscanvas.py From ttkwidgets with GNU General Public License v3.0 | 6 votes |
def add_item(self, text, font=("default", 12, "bold"), backgroundcolor="yellow", textcolor="black", highlightcolor="blue"): """ Add a new item on the Canvas. :param text: text to display :type text: str :param font: font of the text :type font: tuple or :class:`~tkinter.font.Font` :param backgroundcolor: background color :type backgroundcolor: str :param textcolor: text color :type textcolor: str :param highlightcolor: the color of the text when the item is selected :type highlightcolor: str """ item = self.canvas.create_text(0, 0, anchor=tk.NW, text=text, font=font, fill=textcolor, tag="item") rectangle = self.canvas.create_rectangle(self.canvas.bbox(item), fill=backgroundcolor) self.canvas.tag_lower(rectangle, item) self.items[item] = rectangle if callable(self._callback_add): self._callback_add(item, rectangle) self.item_colors[item] = (backgroundcolor, textcolor, highlightcolor)
Example #10
Source File: DeepBrainSegUI.py From DeepBrainSeg with MIT License | 6 votes |
def Load_T2(self, event=None): """ """ self.T2filename = filedialog.askopenfilename() nib_vol = nib.load(self.T2filename) self.affine = nib_vol.affine self.T2_vol = nib_vol.get_data() mid_slice = self.T2_vol.shape[2]//2 true_size = self.T2_vol.shape[:2] size = (self.T2_canvas.winfo_width(), self.T2_canvas.winfo_height()) size = (size[0], int(true_size[0]/true_size[1])*size[1]) if size[0] < size[1] else (int(true_size[1]/true_size[0])*size[0], size[1]) self.T2_canvas_image = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(plot_normalize(self.T2_vol[:,:,mid_slice].T)).resize(size)) self.T2_canvas.create_image(0, 0, image=self.T2_canvas_image, anchor=tk.NW) self.update_main_view(self.T2_vol, self.T2_vol.shape[0]//2, self.T2_vol.shape[1]//2, self.T2_vol.shape[2]//2) self.init_scales(self.T2_vol)
Example #11
Source File: tkvt100.py From learn_python3_spider with MIT License | 6 votes |
def _write(self, ch, fg, bg): if self.x == self.width: self.x = 0 self.y+=1 if self.y == self.height: [self.canvas.move(x,0,-fontHeight) for x in self.canvas.find_all()] self.y-=1 canvasX = self.x*fontWidth + 1 canvasY = self.y*fontHeight + 1 items = self.canvas.find_overlapping(canvasX, canvasY, canvasX+2, canvasY+2) if items: [self.canvas.delete(item) for item in items] if bg: self.canvas.create_rectangle(canvasX, canvasY, canvasX+fontWidth-1, canvasY+fontHeight-1, fill=bg, outline=bg) self.canvas.create_text(canvasX, canvasY, anchor=Tkinter.NW, font=ttyFont, text=ch, fill=fg) self.x+=1
Example #12
Source File: tkwidgets.py From hwk-mirror with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, **kwargs): super().__init__(parent, highlightthickness=0, **kwargs) vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL) vscrollbar.pack(side=tk.RIGHT, fill=tk.Y) self.canvas = canvas = tk.Canvas(self, bd=2, highlightthickness=0, yscrollcommand=vscrollbar.set) canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True) vscrollbar.config(command=canvas.yview) canvas.xview_moveto(0) canvas.yview_moveto(0) self.interior = interior = tk.Frame(canvas) self.interior_id = canvas.create_window(0, 0, window=interior, anchor=tk.NW) self.interior.bind("<Configure>", self.configure_interior) self.canvas.bind("<Configure>", self.configure_canvas) self.scrollbar = vscrollbar self.mouse_position = 0
Example #13
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 6 votes |
def create_top_display(self): frame = tk.Frame(self.root) glass_frame_image = tk.PhotoImage(file='../icons/glass_frame.gif') self.canvas = tk.Canvas(frame, width=370, height=90) self.canvas.image = glass_frame_image self.canvas.grid(row=1) self.console = self.canvas.create_image( 0, 10, anchor=tk.NW, image=glass_frame_image) self.clock = self.canvas.create_text(125, 68, anchor=tk.W, fill='#CBE4F6', text="00:00") self.track_length_text = self.canvas.create_text(167, 68, anchor=tk.W, fill='#CBE4F6', text="of 00:00") self.track_name = self.canvas.create_text(50, 35, anchor=tk.W, fill='#9CEDAC', text='\"Currently playing: none \"') self.seek_bar = Seekbar( frame, background="blue", width=SEEKBAR_WIDTH, height=10) self.seek_bar.grid(row=2, columnspan=10, sticky='ew', padx=5) frame.grid(row=1, pady=1, padx=0)
Example #14
Source File: timeline.py From ttkwidgets with GNU General Public License v3.0 | 6 votes |
def draw_categories(self): """Draw the category labels on the Canvas""" for label in self._category_labels.values(): label.destroy() self._category_labels.clear() canvas_width = 0 for category in (sorted(self._categories.keys() if isinstance(self._categories, dict) else self._categories) if not isinstance(self._categories, OrderedDict) else self._categories): kwargs = self._categories[category] if isinstance(self._categories, dict) else {"text": category} kwargs["background"] = kwargs.get("background", self._background) kwargs["justify"] = kwargs.get("justify", tk.LEFT) label = ttk.Label(self._frame_categories, **kwargs) width = label.winfo_reqwidth() canvas_width = width if width > canvas_width else canvas_width self._category_labels[category] = label self._canvas_categories.create_window(0, 0, window=self._frame_categories, anchor=tk.NW) self._canvas_categories.config(width=canvas_width + 5, height=self._height)
Example #15
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 6 votes |
def create_top_display(self): frame = tk.Frame(self.root) glass_frame_image = tk.PhotoImage(file='../icons/glass_frame.gif') self.canvas = tk.Canvas(frame, width=370, height=90) self.canvas.image = glass_frame_image self.canvas.grid(row=1) self.console = self.canvas.create_image( 0, 10, anchor=tk.NW, image=glass_frame_image) self.clock = self.canvas.create_text(125, 68, anchor=tk.W, fill='#CBE4F6', text="00:00") self.track_length_text = self.canvas.create_text(167, 68, anchor=tk.W, fill='#CBE4F6', text="of 00:00") self.track_name = self.canvas.create_text(50, 35, anchor=tk.W, fill='#9CEDAC', text='\"Currently playing: none \"') self.seek_bar = Seekbar( frame, background="blue", width=SEEKBAR_WIDTH, height=10) self.seek_bar.grid(row=2, columnspan=10, sticky='ew', padx=5) frame.grid(row=1, pady=1, padx=0)
Example #16
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 6 votes |
def create_top_display(self): frame = tk.Frame(self.root) glass_frame_image = tk.PhotoImage(file='../icons/glass_frame.gif') self.canvas = tk.Canvas(frame, width=370, height=90) self.canvas.image = glass_frame_image self.canvas.grid(row=1) self.console = self.canvas.create_image( 0, 10, anchor=tk.NW, image=glass_frame_image) self.clock = self.canvas.create_text(125, 68, anchor=tk.W, fill='#CBE4F6', text="00:00") self.track_length_text = self.canvas.create_text(167, 68, anchor=tk.W, fill='#CBE4F6', text="of 00:00") self.track_name = self.canvas.create_text(50, 35, anchor=tk.W, fill='#9CEDAC', text='\"Currently playing: none \"') self.seek_bar = Seekbar( frame, background="blue", width=SEEKBAR_WIDTH, height=10) self.seek_bar.grid(row=2, columnspan=10, sticky='ew', padx=5) frame.grid(row=1, pady=1, padx=0)
Example #17
Source File: painter.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def __init__(self, master, image): tkinter.Canvas.__init__(self, master, width=image.size[0], height=image.size[1]) # fill the canvas self.tile = {} self.tilesize = tilesize = 32 xsize, ysize = image.size for x in range(0, xsize, tilesize): for y in range(0, ysize, tilesize): box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize) tile = ImageTk.PhotoImage(image.crop(box)) self.create_image(x, y, image=tile, anchor=tkinter.NW) self.tile[(x, y)] = box, tile self.image = image self.bind("<B1-Motion>", self.paint)
Example #18
Source File: workspacecanvas.py From copycat with MIT License | 6 votes |
def add_text(self): padding = 100 def add_sequences(sequences, x, y): for sequence in sequences: x += padding if sequence is None: sequence = '' for char in sequence: self.chars.append((char, (x, y))) self.canvas.create_text(x, y, text=char, anchor=tk.NW, font=font1, fill='white') x += font1Size return x, y x = 0 y = padding add_sequences([self.initial, self.modified], x, y) x = 0 y += padding add_sequences([self.target, self.answer], x, y)
Example #19
Source File: graph.py From lections_2019 with GNU General Public License v3.0 | 6 votes |
def image(x, y, fileName, anchor = NW, **kwargs): if type(x) == tuple: fileName = y x, y = x x, y = transformCoord ( x, y ) try: if fileName.lower().endswith('.gif'): newImage = tkinter.PhotoImage(file = fileName) else: im = Image.open(fileName) newImage = ImageTk.PhotoImage(im) except: pass _images.append(newImage) img = _C.create_image(x, y, image = newImage, anchor = anchor, **kwargs) return img #----------------------------------
Example #20
Source File: graph.py From lections_2019 with GNU General Public License v3.0 | 6 votes |
def image(x, y, fileName, anchor = NW, **kwargs): if type(x) == tuple: fileName = y x, y = x x, y = transformCoord ( x, y ) try: if fileName.lower().endswith('.gif'): newImage = tkinter.PhotoImage(file = fileName) else: im = Image.open(fileName) newImage = ImageTk.PhotoImage(im) except: pass _images.append(newImage) img = _C.create_image(x, y, image = newImage, anchor = anchor, **kwargs) return img #----------------------------------
Example #21
Source File: view.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 6 votes |
def create_top_display(self): frame = tk.Frame(self.root) glass_frame_image = tk.PhotoImage(file='../icons/glass_frame.gif') self.canvas = tk.Canvas(frame, width=370, height=90) self.canvas.image = glass_frame_image self.canvas.grid(row=1) self.console = self.canvas.create_image( 0, 10, anchor=tk.NW, image=glass_frame_image) self.clock = self.canvas.create_text(125, 68, anchor=tk.W, fill='#CBE4F6', text="00:00") self.track_length_text = self.canvas.create_text(167, 68, anchor=tk.W, fill='#CBE4F6', text="of 00:00") self.track_name = self.canvas.create_text(50, 35, anchor=tk.W, fill='#9CEDAC', text='\"Currently playing: none \"') self.seek_bar = Seekbar( frame, background="blue", width=SEEKBAR_WIDTH, height=10) self.seek_bar.grid(row=2, columnspan=10, sticky='ew', padx=5) frame.grid(row=1, pady=1, padx=0)
Example #22
Source File: thresholder.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def __init__(self, master, im, value=128): tkinter.Frame.__init__(self, master) self.image = im self.value = value self.canvas = tkinter.Canvas(self, width=im.size[0], height=im.size[1]) self.backdrop = ImageTk.PhotoImage(im) self.canvas.create_image(0, 0, image=self.backdrop, anchor=tkinter.NW) self.canvas.pack() scale = tkinter.Scale(self, orient=tkinter.HORIZONTAL, from_=0, to=255, resolution=1, command=self.update_scale, length=256) scale.set(value) scale.bind("<ButtonRelease-1>", self.redraw) scale.pack() # uncomment the following line for instant feedback (might # be too slow on some platforms) # self.redraw()
Example #23
Source File: options.py From hwk-mirror with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, item, **kwargs): super().__init__(parent, **kwargs) self.grid_columnconfigure(0, weight=1) label = tk.Label(self, font=self.font, text=f"{item.name}", width=25, justify=tk.LEFT, anchor=tk.NW) self.ticket = item self.options = [lib.ToggleSwitch(self, text=option, font=self.font, width=15) for option in item.options] self._comments = tk.StringVar(self) comment = item.parameters.get("comments", "") self._comments.set(comment if comment else "Comments") self.comments = tk.Entry(self, textvariable=self._comments, font=self.font) self.grid_columnconfigure(0, weight=1) label.grid(row=0, column=0, columnspan=2, sticky="nswe", padx=5, pady=5) tk.Label(self, text=" ", font=self.font).grid(row=1, column=0, sticky="nswe") for i, option in enumerate(self.options): if option["text"] in item.selected_options: option.state = True option.grid(row=i+1, column=1, sticky="nwe", padx=5, pady=5) self.grid_rowconfigure(len(self.options) + 2, weight=1) self.comments.grid(row=len(self.options) + 2, column=0, columnspan=2, pady=5, padx=5, sticky="swe") self.comments.bind("<FocusIn>", self.on_entry_focus)
Example #24
Source File: uiexample.py From mcculw with MIT License | 5 votes |
def create_unsupported_widgets(self, board_num): incompatible_label = tk.Label(self, fg="red") incompatible_label["text"] = ( "Board " + str(board_num) + " was not found or is not compatible with this example.") incompatible_label.pack(fill=tk.X, side=tk.LEFT, anchor=tk.NW) button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.master.destroy quit_button.grid(row=0, column=0, padx=3, pady=3)
Example #25
Source File: CInScan03.py From mcculw with MIT License | 5 votes |
def create_widgets(self): '''Create the tkinter UI''' if self.chan_num != -1: info_text = tk.Label(self) info_text["text"] = ( "Encoder scan on device " + str(self.board_num) + " counter channel " + str(self.chan_num)) info_text.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3) results_group = tk.LabelFrame(self, text="Results") results_group.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3) self.data_label = tk.Label(results_group, justify=tk.LEFT) self.data_label.grid(padx=3, pady=3) button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) self.start_button = tk.Button(button_frame) self.start_button["text"] = "Start" self.start_button["command"] = self.start self.start_button.grid(row=0, column=0, padx=3, pady=3) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.master.destroy quit_button.grid(row=0, column=1, padx=3, pady=3) else: self.create_unsupported_widgets(self.board_num) # Start the example if this module is being run
Example #26
Source File: ULGT03.py From mcculw with MIT License | 5 votes |
def create_widgets(self): '''Create the tkinter UI''' main_frame = tk.Frame(self) main_frame.pack(fill=tk.X, anchor=tk.NW) positive_int_vcmd = self.register(self.validate_positive_int_entry) board_num_label = tk.Label(main_frame) board_num_label["text"] = "Board Number:" board_num_label.grid(row=0, column=0, sticky=tk.W) self.board_num_variable = StringVar() board_num_entry = tk.Spinbox( main_frame, from_=0, to=self.max_board_num, textvariable=self.board_num_variable, validate="key", validatecommand=(positive_int_vcmd, "%P")) board_num_entry.grid(row=0, column=1, sticky=tk.W) self.board_num_variable.trace("w", self.board_num_changed) info_groupbox = tk.LabelFrame(self, text="Board Information") info_groupbox.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3) self.info_label = tk.Label( info_groupbox, justify=tk.LEFT, wraplength=400) self.info_label.grid() button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.master.destroy quit_button.grid(row=0, column=0, padx=3, pady=3) # Start the example if this module is being run
Example #27
Source File: recipe-578004.py From code with MIT License | 5 votes |
def write(self, x, y, text, fill): "Writes the text to bottom-left of location." self.canvas.create_text(x, y, text=text, fill=fill, anchor=tkinter.NW)
Example #28
Source File: scroller.py From Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition with MIT License | 5 votes |
def check(event): global checks,newGame,text if newGame: for chk in checks: canv.delete(chk) del checks[:] canv.delete(gold,text) newGame=False hideGold() else: checks.append( canv.create_image(canv.coords(player)[xVAL], canv.coords(player)[yVAL], anchor=TK.NW, image=checkImg, tags=('check','bg'))) distance=measureTo(checks[-1],gold) if(distance<=0): canv.itemconfig(gold,state='normal') canv.itemconfig(check,state='hidden') text = canv.create_text(300,100,fill="white", text=("You have found the gold in"+ " %d tries!"%len(checks))) newGame=True else: text = canv.create_text(300,100,fill="white", text=("You are %d steps away!"%distance)) canv.update() time.sleep(1) canv.delete(text)
Example #29
Source File: ULGT01.py From mcculw with MIT License | 5 votes |
def create_widgets(self): '''Create the tkinter UI''' main_frame = tk.Frame(self) main_frame.pack(fill=tk.X, anchor=tk.NW) positive_int_vcmd = self.register(self.validate_positive_int_entry) err_code_label = tk.Label(main_frame) err_code_label["text"] = "Error Code:" err_code_label.grid(row=0, column=0, sticky=tk.W) self.err_code_variable = StringVar(0) self.err_code_entry = tk.Spinbox( main_frame, from_=0, to=2000, textvariable=self.err_code_variable, validate="key", validatecommand=(positive_int_vcmd, "%P")) self.err_code_entry.grid(row=0, column=1, sticky=tk.W) self.err_code_variable.trace("w", self.err_code_changed) err_msg_left_label = tk.Label(main_frame) err_msg_left_label["text"] = "Message:" err_msg_left_label.grid(row=1, column=0, sticky=tk.NW) self.err_msg_label = tk.Label( main_frame, justify=tk.LEFT, wraplength=300) self.err_msg_label["text"] = "No error has occurred." self.err_msg_label.grid(row=1, column=1, sticky=tk.W) button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.master.destroy quit_button.grid(row=0, column=0, padx=3, pady=3) # Start the example if this module is being run
Example #30
Source File: ULDO01.py From mcculw with MIT License | 5 votes |
def create_widgets(self): '''Create the tkinter UI''' if self.port != None: main_frame = tk.Frame(self) main_frame.pack(fill=tk.X, anchor=tk.NW) positive_int_vcmd = self.register(self.validate_positive_int_entry) curr_row = 0 value_label = tk.Label(main_frame) value_label["text"] = "Value:" value_label.grid(row=curr_row, column=0, sticky=tk.W) self.data_value_variable = StringVar() self.data_value_entry = tk.Spinbox( main_frame, from_=0, to=255, textvariable=self.data_value_variable, validate="key", validatecommand=(positive_int_vcmd, "%P")) self.data_value_entry.grid(row=curr_row, column=1, sticky=tk.W) self.data_value_variable.trace("w", self.data_value_changed) button_frame = tk.Frame(self) button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE) quit_button = tk.Button(button_frame) quit_button["text"] = "Quit" quit_button["command"] = self.exit quit_button.grid(row=0, column=1, padx=3, pady=3) else: self.create_unsupported_widgets(self.board_num)