tkinter

Turtle in Tkinter creating multiple windows

倾然丶 夕夏残阳落幕 提交于 2021-01-29 09:05:19
问题 I am attempting to create a quick turtle display using Tkinter, but some odd things are happening. First two turtle windows are being created, (one blank, one with the turtles), secondly, any attempt of turning the tracer off is not working. This might be a simple fix but at the moment I cannot find it. Any help would be appreciated, Below is the code: import tkinter as tk import turtle window = tk.Tk() window.title('Top 10\'s') def loadingscreen(): canvas = tk.Canvas(master = window, width =

Destroy Tkinter button after click

别说谁变了你拦得住时间么 提交于 2021-01-29 09:03:01
问题 I have a Tkinter list box populated with city names. I want to grab the selected value and pass it to subsequent code after the mainloop. I have the following tkinker code: master = tk.Tk() variable = StringVar(master) variable.set(cities_list[0]) # default value w = OptionMenu(master, variable, *cities_list) w.pack() def ok(): print ("value is:" + variable.get()) return variable.get() window.destroy() button = Button(master, text="OK", command=ok) button.pack() mainloop() v_list = variable

Unable to change background color of treeview in python

纵然是瞬间 提交于 2021-01-29 09:01:11
问题 I am trying to change the background color of the rows in treeview using tags but unable to get the success. Following is my code: def display_device_status(self, colnames): # root = Tk() # self.root.title('Device Status') # self.root.resizable(width=FALSE, height=FALSE) # tree = ttk.Treeview(self.root, height=25, column=("col1", "col2"), show="headings", selectmode="browse") # tree.heading('#1', text='MAC') # tree.column('#1',width=290) # tree.heading('#2', text='Status') # tree.column('#2'

Can't fetch weather icons from openweathermap

橙三吉。 提交于 2021-01-29 08:35:10
问题 I have been trying to fetch weather icons from openweathermap api for a python application, but for some reason I am not able to do so. I am however, able to print the icon as text for e.g. its code like "3d" or "3n" but not the image. When I try to print the image, the error _tkinter.TclError: image "03n" doesn't exist pops up. My code is below. import requests from tkinter import * root = Tk() root.geometry("250x250+0+0") root.configure(bg='black') url = 'http://api.openweathermap.org/data

Changing a Variablestring in a Class in Python

只愿长相守 提交于 2021-01-29 08:21:26
问题 I have a small piece of code, which was working fine, until I decided to create a class and put things into that class. Now my problem is, I cannot change stringvariable anymore. Here is my code: import tkinter as tk import tkinter.ttk as ttk class MainApplication(tk.Frame): def __init__(self, parent, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent frame1 = ttk.LabelFrame(root, text="PANEL A", borderwidth=5) frame1.grid(row=0, column=0, padx=5, pady=5)

Attaching event to self (canvas) tkinter

 ̄綄美尐妖づ 提交于 2021-01-29 08:06:09
问题 i have created a class in python that extends the tkinter canvas. I am trying to attach an event to this canvas to handle click's within the class. It functions if i attach the event outside of the class itself but when binding within the class the click event only occur's once and then proceeds not to do anything at all only performing the first click: class myCanvas(Canvas): def callback(event): print('clicked at', event.x, event.y) def __init__(self, parent, **kwargs): Canvas.__init__(self

Creating a Treeview with Checkboxes

淺唱寂寞╮ 提交于 2021-01-29 08:04:25
问题 I am trying to build an application based on the following usage example (How to create a tree view with checkboxes in Python). This example builds a Treeview with checkboxes using the Tix library. However, when I run this example, whenever a Checkbox is checked, the text label of that box disappears. Could someone help me to avoid the behaviour mentioned just above? import Tix class View(object): def __init__(self, root): self.root = root self.makeCheckList() def makeCheckList(self): self.cl

Attaching event to self (canvas) tkinter

廉价感情. 提交于 2021-01-29 08:00:26
问题 i have created a class in python that extends the tkinter canvas. I am trying to attach an event to this canvas to handle click's within the class. It functions if i attach the event outside of the class itself but when binding within the class the click event only occur's once and then proceeds not to do anything at all only performing the first click: class myCanvas(Canvas): def callback(event): print('clicked at', event.x, event.y) def __init__(self, parent, **kwargs): Canvas.__init__(self

Tkinter not creating a window?

邮差的信 提交于 2021-01-29 07:55:48
问题 I am trying to create a window with Tkinter but no window is being created and I am not receiving any error codes? from tkinter import * def login_window(): window=Tk() window.title("Login") info_lbl = Label(window) info_lbl.grid(row=0, column=1) username_lbl = Label(window, text='Username') username_lbl.grid(row=1, column=1) username_entry = Entry(window, width=10) username_entry.grid(row=1, column=2) password_lbl = Label(window, text='Password') password_lbl.grid(row=2, column=1) password

Tkinters highlight of button is not working for me

我的未来我决定 提交于 2021-01-29 07:45:56
问题 According to the accepted answer on this post the use of .configure(highlightbackground='red') on a button should apply a color around the button however in testing I cannot reproduce what the poster has demonstrated in their gif recording. Here is my test case: (Note even copy pasting the posters code I cannot get the highlight effect they are showing) import tkinter as tk root = tk.Tk() btn = tk.Button(root, text='test', bg="#000000", fg="#ffffff", highlightthickness=4, activebackground="