FAQ Database Discussion Community


Is it possible to make the lines move diagonally in tkinter?

python,python-3.x,canvas,tkinter
In this program below, i can move the lines left and right, up and down. However is it possible to make the lines move diagonally, e.g. when up arrow and right arrow presses the program makes a diagonal line moving NE from tkinter import * canvas_height = 400 canvas_width =...

Store class variable in dictionary

python,class,dictionary,tkinter
I am making a program that will have a box that receives two inputs, an event name and the time allocated for the event, and will later output a list of all the events that have been added. This is the class for the input boxes: class agendaEvent: def __init__(self,...

Python 3.4 tkinter real-time temperature converter

python,tkinter,converter,temperature
I wrote complicated program in Python 3.4 (with tkinter gui). It's temperature converter (Celsius to Fahrenheit and reverse) in real-time. It works almost good, but there is one problem. I have to add a space after input value every time. Anyone have idea what's wrong in this program? from tkinter...

How to access a button's parent in Tkinter without writing class?

python,user-interface,tkinter,event-driven
Is there any way to find a widget's parent (specifically button) without saving the parent in an object attribute? but = Button(main_window, text = "close window!") but.bind("<Button-1>", btn_handler) def btn_handler(e): e.parent().destroy() # I need something like this! # e.parent() ==>> main_window # without writing class and defining self.parent ... I...

Unexplained Infinite Loop in Tkinter

python,tkinter
I am learning Tkinter for python2 where i came across this code.this creates a window in tkinter and increments the value of label every 1 second While the code runs perfectly fine..Can you tell me why an infinite loop is not observed as after every thousand seconds the control return...

Tkinter automatically opens my file

python,tkinter
I made a GUI app where you can open a file and then you can calculate some things on it (from the main function). However, when I run this program, it automatically opens the file which I chose and the main() function runs, even if I haven't commanded it yet....

tkinter: progress list not updating

osx,python-2.7,user-interface,tkinter,listbox
I have great difficulty boiling down my problem into a fundamental one, so my apologies if this is already treated in another question. My problem lies in providing progress feedback to the user. The basic system is used to import files, analyze them (with an external function) and in the...

Python MVC style GUI Temperature Converter

python,user-interface,python-3.x,model-view-controller,tkinter
#The view (GuiTest.py) import tkinter import Controller class MyFrame(tkinter.Frame): def __init__(self, controller): tkinter.Frame.__init__(self) self.pack() self.controller = controller #Output Label self.outputLabel = tkinter.Label(self) self.outputLabel["text"] = ("") self.outputLabel.pack({"side":"right"}) #Entry Space self.entrySpace = tkinter.Entry(self) self.entrySpace["text"] = ("") self.entrySpace.pack({"side":"left"}) #two convert buttons self.convertButton=tkinter.Button(self) self.convertButton["text"]= "Fahrenheit to...

How to have parameters to a button command in tkinter python3 [duplicate]

python,function,python-3.x,tkinter
This question already has an answer here: Python Tkinter: Passing arguments to Button widget 1 answer commands in tkinter when to use lambda and callbacks 2 answers I want to have UI where when I press a button, stuff pops up in the console. The issue is the stuff...

Python 2.5 Tkinter Highlight Spinbox Entry

python,tkinter,spinner,entry
This question seems trivial to me but I can't seem to find anything related to it, and the Spinbox docs don't seem to help. Is there any way to select all of the text in a Spinbox widget? I'm currently trying: self.spinbox.selection_clear() self.spinbox.selection('range', 0, END) to no avail. I have...

Tkinter fast reader

python,tkinter
I have a problem in implementing a fast reader program with tkinter, and that is because it hangs after ~5 seconds. I know that is because of the while loop but I didn't figured out a way to solve it. Maybe looping outside of the root mainloop? Here is the...

writing a tkinter scrollbar for canvas within a class

python,python-3.x,tkinter
I've searched around and cannot seem to find an answer for my problem. I am trying to create a working scrollbar for the following code and cannot seem to get it to work. The problem appears to be with the OnFrameConfigure method. I have seen elsewhere that the method should...

Duplicate Frames Created When Calling a Function in a Tkinter Application

python,python-3.x,tkinter,tk
So this is my first Python GUI project utilizing tkinter. I come from a background in R. I decided after a review of the documentation to create a class to handle the bulk of the work. The problem appears with my incrementer functions fwd() and bck(). If I do not...

Can you play sound in windows while doing another task simultaneously?

python-2.7,tkinter,label
Is there a way to while playing winsound.PlaySound("some sound", FLAGS) also change a photolabel? I've been trying and no matter where I put the play sound it always play the sound before changing my photo label. My code: def thriller(self): winsound.PlaySound("thriller.wav", winsound.SND_NODEFAULT) img5 = ImageTk.PhotoImage(Image.open('thriller.jpg')) self.photoLabel.configure(image = img5) self.photoLabel.image =...

Problems with displaying an user selection from a Combobox in a Listbox

python,combobox,tkinter,listbox
I want the follow code snippet to take the user selection from the combobox and display it in a Listbox I have set up. When I run the code, and select from the combobox, the selection is displayed in the listbox as <tkinter.StringVar object at 0x1007ae748> instead of the actual...

how to attatch scrollbar to dropdown list in tkinter?

python,tkinter,scrollbar,optionmenu
from Tkinter import * master = Tk() variable = StringVar(master) variable.set("one") # default value w = OptionMenu(master, variable, "Carrier 19EX 4667kW/6.16COP/Vanes", "Carrier 19EX 4997kW/6.40COP/Vanes", "Carrier 19EX 5148kW/6.34COP/Vanes", "Carrier 19EX 5208kW/6.88COP/Vanes", "Carrier 19FA 5651kW/5.50COP/Vanes", "Carrier 19XL 1674kW/7.89COP/Vanes", "Carrier 19XL 1779kW/6.18COP/Vanes", "Carrier 19XL 1797kW/5.69COP/Vanes", "Carrier 19XL 1871kW/6.49COP/Vanes", "Carrier 19XL 2057kW/6.05COP/Vanes", "Carrier 19XR...

How do I properly change the values of a Radiobutton?

python,user-interface,tkinter,radio-button
I have created a IntVar() this.v. When this.v = 1, my elif statement is true, which should not be the case. What have I done wrong? When I print(this.v.get()) the value returned is 1. (import tkinter) this.v = IntVar() this.button1 = Radiobutton(this.root,text = "Small Boxes First",variable = this.v,value = 1)...

python's tkinter button color change is not getting updated

python,user-interface,tkinter
I am writing a small program in which when a button is clicked the color of a label changes to green ( by default it was red ) and after sometime it reverts back to red. using time.sleep() doesn't work. The code that I have already tried is: def change():...

Call the Button contrustor from inside a class' __init__

python,class,python-2.7,tkinter
My GUI program uses a number of buttons that have a couple very specific features, so I'm writing a class that wraps these methods around a button so I don't need to keep rewriting simple functions for each button. I have the class: class ToggleableButton(Button): __isToggled = False __root =...

TypeError: get() takes 1 positional argument but 3 were given

python,tkinter
This code will run a basic data input window through tkinter which will save the user's inputs. When i run the code and mouse click the Submit button I get the error: print ("Información Adicional: {}".format(self.entry_name.get(1.0, "end"))) TypeError: get() takes 1 positional argument but 3 were given This is the...

Set Entry widget values dynamically in Tkinter

python,tkinter,tk
I have a window to browse a folder containing necessary files. I am using tkFileDialog for the same. I want to set the value of Entry widget equal to this selected folder. Initially when no folder is selected it will be null. As soon as I select the folder, the...

how to make a python script run repeatedly

python,tkinter
I have a simple script which saves some values to a database , I also have a window built in Tkinter. So basically my problem is I want the savebase() function to be continuously called upon, till the window remains open. How can this be done ? Till now I'm...

Tkinter, show user new window with information about what program is doing while main window is not responding

python,multithreading,python-3.x,tkinter
Lets say I have folder with music. --Iron Maiden --Prowler --Sanctuary --Iron Maiden --etc And I have class with method in it which is finding all music in this folder and adding information about this song to the list. Little example, just getting path to all files in folder. from...

How to get/print Updated Time per second in a Tkinter window

python,tkinter
I want to print current time in seconds on a label in a window using Tkinter, but instead of updating every 500 milliseconds it just remains the same. Any ideas what I can do to get this thing right? def timeout(): t=time.time() window.after(500, timeout) return t window = Tkinter.Tk() window.title("Example")...

Building Othello game using Tkinter (Python)

python,tkinter,reversi
How would I go about building an Othello GUI using tkinter in python? Specifically how would I begin by making the initial four pieces show up? How do I get my board to print out the position of a piece when i select a square? So far it prints out...

Python 3.4 tkinter sleep

python,tkinter
I want to show all products within itertools.product(string.punctuation, repeat=2)) from index 0 to end with sleep 0.5 sec after each element. Unfortunately tkinter hasn't normal sleep function. I can use only w.after(time, callback) but this is bad for what I want to do. I want to do something like this:...

Why does the update method in Tkinter cause the window to freeze?

python,tkinter,tkinter-canvas
First of all, I know Tkinter isn't thread safe and this problem has something to do with that but I wanted to find out formally why this code makes a window that displays but is unresponsive. from Tkinter import * root = Tk() c = Canvas() c.pack() c.create_line(10,10, 30, 30)...

How do we change the title of this frame?

python,tkinter
I was playing around with some Tkinter code that I found online: from Tkinter import * class ScrolledList(Frame): def __init__(self, options, parent=None): Frame.__init__(self, parent) self.pack(expand=YES, fill=BOTH) self.makeWidgets(options) def handleList(self, event): index = self.listbox.curselection() label = self.listbox.get(index) self.runCommand(label) def makeWidgets(self, options): sbar = Scrollbar(self) list = Listbox(self, relief=SUNKEN) sbar.config(command=list.yview) list.config(yscrollcommand=sbar.set) sbar.pack(side=RIGHT,...

tkinter showerror creating blank tk window

python-3.x,tkinter,messagebox,tkmessagebox
I have a program that needs to display graphical error messages to users. It is a tkinter GUI, so I am using tkinter.messagebox.showerror When I call showerror, it shows the error, but also creates a blank "tk" window, the kind created when an instance of the Tk class is called,...

Update a label in Tkinter when pressing a button

python,tkinter
I want to make a "program" that updates a label when you press a button and print out a variable, but with the code i have it does not work. Can someone help me out? Thanks in advance! from Tkinter import * root = Tk() x = 0 def test():...

Using tkinter to assign a global variable and destroy the gui

python,user-interface,tkinter,arcgis,esri
I have been writing an annual data verification program and need a bit of user input with it and decided to go the tkinter route. I have created the interface for one of the user input screen, and will have to make others, but I'm having some issues with the...

Plot hlines in embedded graph?

python,python-3.x,matplotlib,tkinter,embed
I'm practicing tkinter and matplotlib in this piece of code and what it is supposed to do is to embed a simple matplotlib graph into a tkinter GUI. The thing is I also want horizontal lines to be plotted in this embedded graph by mouse clicks but I'm not getting...

How to have multiple text widgets with scrollbars in a frame on tkinter

python,python-3.x,tkinter
I want my text widgets to have scrollbar capability within each text widget. I have created a canvas and within it have embedded a frame using create_window. I then put 2 Text widgets into this frame. I want each of the text widgets to have a scrollbar, however when I...

Invalid syntax when inside class python v2.7 [closed]

python,tkinter,mysql-python
when I try to run cursor.execute("SELECT VERSION()") inside my class method it gives me an SyntaxError. But works just fine outside the class, the same code. I'm brand new to Python, have tried search and so on but could not find anything. The error I get is following: cursor.execute("SELECT VERSION()")...

Calculate the time between a range of key events in Python

python,events,tkinter,keyboard-events
As a part of my self learning projects, I decided to create an application in Python that listens to certain keyevents and finds the amount of time it takes to type a word. It's been more than 12 hours of straight debugging and loop/logic experiments and all I could do...

Python 3 tkinter button command inside different class

python,class,button,tkinter,def
I'm creating a Python (3.4.3) - tkinter program and am wondering whether it is possible to reference a def (self.get_details) from inside another class for a button's command. I haven't been able to find an answer to this problem anywhere, so I figured I'd just ask. Example: import tkinter as...

commands in tkinter when to use lambda and callbacks

python,lambda,tkinter,command
I'm confused as to the difference between using a function in commands of tkinter items. say I have self.mb_BO.add_radiobutton(label= "Red", variable=self.BO, value=2, command=self.red) what is the difference in how the add statement works from this: self.mb_BO.add_radiobutton(label= "Red", variable=self.BO, value=2, command=self.red()) where func red(self) changes the color to red. And self.mb_BO.add_radiobutton(label=...

Tkinter: How can I pause an animation loop when a TopLevel window is active (until its destroyed)?

python,tkinter
I have a game of pong (adapted). Each time the player's paddle misses the ball, I want a window to appear with a question inside. If he answers correctly, the Toplevel window should be destroyed and the user can continue the game, failure will result in more questions until the...

Any other way to design other than grid with tkinter Python?

python,python-3.x,tkinter
Please be patient with me, I am 16 years old, only started programming about last year september on codeacademy. Anyway, I'm creating this program so I can get an end of term grade for math originally but now I have been told that the school may want to use it....

Save user input into a Text widget Tkinter when using classes

python,text,tkinter
I want to know how to save text entered by the user in a Text widget when pressing a "submit" button. At the moment, I have the function submitbutton but it comes up with an error when clicking "submit." On another note, I want the top right Label widget to...

Problems with tk entry and optionmenu widget in currency converter

python,python-2.7,tkinter
I am currently having problems with my currency converter program in my python class. I am trying to convert an amount, the entry widget, from the starting currency, the first option menu, to the desired currency, the second option menu. I have spent hours reading the documentation, so I hope...

Scroll through a tkinter frame or window [duplicate]

python-3.x,scroll,tkinter,scrollbar
This question already has an answer here: Adding a scrollbar to a grid of widgets in Tkinter 1 answer I am creating a window that will be quite long, and I want to have a scrollbar to be able to scroll vertically through the window (it's a settings window)....

Writing Another Text File based on Saved File from Tkinter

python,file,tkinter,dialog,save
I prompt the user to save a file, and I want to automatically save a file along with it. For example, let's say the user saves a text file under my program called "foo.txt", I want to automatically make a text file called "lengthfoo.txt". The word "length" before "foo", and...

Creating an auto incrementing loop within a function in python

python,loops,tkinter,increment
I'm trying to set up a loop that keeps track of a number of ordernums as well as assign a nw ordernum to each new order in increasing value. Here's the full code: *This is the fixed code using Klaus D. 's advice import tkinter from tkinter import * from...

NameError in tkinter GUI based Reddit Scraper Application --Python

python,user-interface,tkinter,reddit,scraper
I'm in the process of building a GUI based Reddit scraper application and I have run into a few problems. First, I can't seem to get my second tkinter window to load from the redditReturn class file. Also, i'm not sure if it is correct to have my section of...

how to enable a entry by clicking a button in Tkinter?

python,tkinter
I need to activate many entries when button is clicked please do not write class based code, modify this code only because i need to change the whole code for the project as i did my whole project without classes from Tkinter import * import ttk x='disabled' def rakhi(): global...

autoscroll of text and scrollbar in python text box

python,tkinter
I have a tkinter 'Text' and 'Scrollbar' working fine. In my program in the text window automatically lines will keep on adding. So When a new line of text is inserted and data reached out of limit I would like the text and scrollbar to be scrolled to the bottom...

How to change on_press “animation” of Tkinter button in python

python,user-interface,tkinter,customization
i have a taskbar-like Frame, which contains custom Buttons with images. But everytime i click on this button, Tkinter displaced the button 1px to the right/buttom. Is it possible to override this behaviour? Or do i have to derived from Tkinter.Label instead of Tkinter.Button ? edit: Adding some code: import...

How do I make a color selection scale in Tkinter?

python,tkinter,color-picker,ttk
I'm trying to create a color selection scale for a Tkinter application. I'm not interested in the tkinter.colorchooser module or separate scales for each RGB channel. I need a single scale like the color slider in Photoshop. What I currently have is a vertical scale widget with RGB integer values...

How to get rid of curly braces from expanded list

python,python-3.x,tkinter
I'm new to Python, so please bear with me. I'm trying to populate an optionmenu with rows from an SQLite database. The problem is that when a cell contains a space, the option appears with {} around it. What is the proper way to do this? from tkinter import *...

Python image inside other folder

python,tkinter
I have a weather program in python, using the openweathermap.org API. The main file is located in a directory, but the image I want in my Tkinter window is located in an image/ directory. At the moment, I have put the images into the folder of my python script, but...

tkinter gui formatting menu's with frames (pyhon2.7)

python,python-2.7,tkinter
I am currently a high school student taking a beginner programming class. We just started a new unit learning Tkinter in python and I had a few questions regarding a project we have. I decided to do my project on making a currency converter. I finished everything regarding api's, and...

How to left justify Python tkinter grid columns while filling entire cell

python,python-3.x,tkinter,grid
I'm trying to write a python class to display data in a tabular format. I'm sure there are classes out there already to do the same thing, however, I'm using this exercise as a way to teach myself Python and tkinter. For the most part, I have the class working...

Manually triggering the ttk notebook tab change event

python,events,tabs,tkinter,ttk
I'm talking about <<NotebookTabChanged>> event that ttk.Notebook can be bound to. Say I have: def tabChanged(self, event): print "tab changed" And say I want to manually trigger this method. What I actually mean by this is, say I have a basic, tabbed GUI and there's a start button which makes...

Sending a Class' attribute to an outside function in the function call

python,class,tkinter,attributes
I'm trying to generalise a function in my script by sending in the Class' attribute through the function call to an outside function, but since I have to call the attribute self.attribute_name inside the class and object_name.attribute.name outside it, I either get an error that no self.attribute_nameexists outside the code...

How do you populate a Combobox based on the selection of another Combobox?

python-3.x,combobox,tkinter
I am trying to populate a combobox based on the selection of another combobox. I can do this if I use an update button to update the combobox#1 selection.However, I would like to do the update dynamically. I have attached a simple example of code that seems to work as...

Display text when cursor is placed over button in python

python,tkinter
How to display text in the window when the cursor is placed over the button. I have below code, when put cursor over the button "Ok" it has to show text as "Check details filled before pressing Ok". import Tkinter class Example(Tkinter.Frame): def __init__(self, *args, **kwargs): Tkinter.Frame.__init__(self, *args, **kwargs) self.l1...

How to have tabs of a ttk Notebook in different rows?

python,tabs,tkinter,ttk
In the below program i have many tabs in a single notebook page. when the number of tabs increases the look changes. So how to put the tabs in different rows As in attached image, I have many tabs in a single row, but I want some tabs say from...

How to install tkinter or Tcl for python 2.7 on windows 7?

python,tkinter
I am getting following errors. When I am searching on web I am not able to understand how to do that.Following program I am running please help. import json import pandas as pd import matplotlib.pyplot as plt import re from Tkinter import * tweets_data_path = 'C:/Users/e2sn7cy/Documents/GitHub/twitter_data.txt' tweets_data = [] tweets_file...

Return from inside a function defined inside another function in Python

python,tkinter
I know that the title isn't very clear, so I'll try to explain in more depth: I have a function f defined inside a function g, and I want to be able to call f from inside g, and make f make g return something. For example: def g(): def...

How to put an image on another image in python, using ImageTk?

python,user-interface,tkinter
I want to put an image in front of another one, then use this combined image as a button's background image in Tkinter. How can I do it? I am free to import Tkimage, Image. Clarify: I want to stick this on the center of this so that something like...

Python ttk Object - Not understanding Widget-Specific Options

python,python-3.x,tkinter
I was implementing a ttk progress bar yesterday and saw some code that I didn't quite understand. A maximum value can be set for a progress bar by using something like the following: progress_bar["maximum"] = max I was expecting the ttk Progressbar object would use an instance variable to track...

How can I bind multiple canvas elements together in order to change their color simultaneously?

python,user-interface,tkinter,tkinter-canvas
So, these are the lines which I have created/drawn: from tkinter import * root = Tk() f= Frame(root) f.pack() c = Canvas(f,bg = "black") c.pack() line1 = c.create_line(10,0,10,50,fill = "white",activefill = "blue",tag = "one") line_side1 = c.create_line(0,25,10,25,fill= "white", activefill = "blue",tag = "one") line2 = c.create_line(30,0,30,50,fill = "white",activefill = "blue",tag...

Two checkbuttons to toggle sound not working right

python-2.7,button,tkinter
self.mb = Menubutton ( self.window2, text="Sound Toggler", relief=RAISED ) self.mb.grid(row=4, column = 0) self.mb.menu = Menu ( self.mb, tearoff = 0 ) self.mb["menu"] = self.mb.menu self.ONSound = IntVar() self.ONSound.set(1) self.OFFSound = IntVar() self.OFFSound.set(0) self.mb.menu.add_checkbutton ( label="ONSound", variable=self.ONSound, command = self.turnON(), onvalue=1,offvalue=0) self.mb.menu.add_checkbutton ( label="OFFSound", variable=self.OFFSound, command = self.turnOFF(), onvalue=1,offvalue=0)...

Label keeps on appearing

python-3.x,tkinter
SO I am using Python 3.4 and tkinter. And when I call a function again n again which contains a label, the label keeps on appearing in window but previous label doesn't go away? How can I remove any printed label from GUI window as soon as function is called...

Tkinter impossible to use place()

python,tkinter,tk,place
I just encounter problem. I can't use the place method in some part of my app. for example : root = Tk() gameFrame = Frame(root) gameFrame.place(x=125, y=75) in the begining of my app, i create a some Frame, then my "gameFrame" is positioned with the method place, and it works...

python tkinter tree get selected item values

python,tkinter,tree,row
I'm just starting with a small tkinter tree program in python 3.4. I'm stuck with returning the first value of the row selected. I have multiple rows with 4 columns and I am calling an a function on left-click on a item: tree.bind('<Button-1>', selectItem) The function: def selectItem(a): curItem =...

Disabling tkinter ttk scale widget

python,user-interface,tkinter,ttk
I am trying to disable all of the (ttk) widgets in a frame, but it appears that the scale widget is giving me some trouble, as it throws the following exception: _tkinter.TclError: unknown option "-state" Some relevant code: import tkinter as tk from tkinter import ttk def disable_widgets(parent): for child...

Python -Switch state of turtle pen using single keypress

python,tkinter,turtle-graphics
While writing a simple drawing program, I ran into a problem; I want to use the space key to switch the state of the pen from up to down and vice versa. Of course this could be achieved with an if event.char == "a key:" pen.penup() elif event.char == "another...

Tkinter, Windows: How to view window in windows task bar which has no title bar?

python,windows,tkinter,python-3.4
I created a window: root = Tk() and removed the titlebar: root.overrideredirect(True) Now the window is not on the task bar in windows. How can i show it in the task bar? (I only want to bring my window to the front if other windows are on top of mine)...

How can I put 2 buttons with images Vertically in a frame

python,tkinter
Im using tkinter and trying to create a toolbar located on the left side going vertically, I already have a toolbar on the top of the frame filled in going horizontaly however can't figure out how to make a second one on the left, with all the buttons. This is...

TkInter Menubar causes program to not run

python,tkinter
I am trying to write a simple text editor using TkInter. I want it to have a menu bar like other text editors, where you can save, open another file, etc. However, whenever I try to add a menu bar to my class, the program simply starts, hangs for about...

Python: Tkinter root window not reappearing

python,tkinter
I am currently experiencing some trouble getting the root window for tkinter to hide when a Toplevel window appears and then become visible when it is closed. The toplevel window is suppose to be a configuration window and upon completing, it will configure the root window. In my main tkinter...

TKinter: Scrollable Canvas, Expandable Widgets, and Pack

python,tkinter,widget,scrollable
I am creating a table using Labels laid out as a grid within a Frame. I'd like to embed this Frame in a scrollable canvas, and I'd like the Labels to expand to fill the horizontal space while maintaining vertical scrolling capability. To see what I am trying to do,...

Python removes quotes

python,sql,tkinter,oledb
I'm trying to make a simple gui with tkinter utilizing windows built-in search functionality. This is the code I'm having issues with. #gets search keywords from user input and splits into list keyword_list = self.entry.get() keyword_list = keyword_list.split() #creates empty string keyword_string = "" #fills empty string with list, appends...

Tkinter and UnboundLocalError

python,tkinter
I am trying to get the coordinates for each square on the board but the error UnboundLocalError: local variable 'x' referenced before assignment keeps showing up when I click on a square. import tkinter class RA: def __init__(self): self._columns = 8 self._rows = 8 self._root = tkinter.Tk() self._canvas = tkinter.Canvas(master...

tkinter: bind Return key to the OK button — but not to the Text widget

python,binding,tkinter
With tkinter/ttk (8.5+), in a custom dialog, I want to bind the Return key to the OK button. So I use the standard instruction: self.window.bind("<Return>", self.on_ok) The problem is, in this custom dialog there is also a (multiline) Text widget. And once the Return key is bound to the OK...

Python Tkinter Button Issues (Twitch bot)

python,tkinter
I am trying to make a test Tkinter button for my twitch chat bot. What this button would do when clicked is send a simple message to the channel it's connected to. However, I am encountering some issues when trying to figure out how to do this. I have the...

CheckButton on tkinter is not “On” after setting the value

python,tkinter
I recently changed the geometry manager in my program from grid to pack because of a problem trying to get the Navigatiotoolbar in the frame. The problem is that a check button that used to be on by default is not On by default now. Here is the code for...

Entry Widget is driving me nuts!: Tkinter Reddit Scraper thinks that a string entry is numbers?

python,user-interface,tkinter,reddit,scraper
Im in the middle of a small project, to create a tkinter gui that outputs the top ten posts from a user-defined subreddit from reddit.com using their api. Because I need to have the subreddit be the choice of the user, it needs to be inputted using a tkinter entry...

How do I assign a variable to a Tkinter input?

python,tkinter
I am using the following code to create a widget with three inputs. I am able to modify this code to format the widget how I want, but I then need to copy files based on the input from the fields in the widget. For example, if the user inputs...

tkinter histogram prints downwards

python-3.x,tkinter,tkinter-canvas
I am trying to draw two histograms alongside one another using tkinter canvas. Everything sort of works ( looks extremely scruffy at the moment) but the histograms are drawn downwards. I have tried making the y0 value negative, but then nothing at all is drawn. I am using two lists...

StringVar() from JSON list using pop() - Python / tkinter

python,json,dictionary,tkinter,pop
I am trying to create a basic quiz program using tkinter for Python. Right now I am trying to load a question from a list of two dictionaries from a JSON file: [ ...

Which dynamically created object called the function?

python,lambda,tkinter
I am making a python app with a Tkinter GUI. So far it has some dynamically created listboxes which I will link all to one scrollbar. I need a way to let yscroll() know which listbox has been scrolled. Passing the i variable to yscroll() does not work. from Tkinter...

Shuffling list of widgets? Tkinter

python,json,tkinter,widget,shuffle
Finally I have finished this damn thing! Except for one issue. I have a program quiz program created with tkinter that grabs a dictionary from a list inside a JSON file. Now everything appears to be working fine, except for the shuffling of a list of buttons which remain in...

How to get an entry.bind and a button do the same thing?

python,button,tkinter,bind,entry
I think the name of the topic is pretty clear, I haven't found any answer elsewhere so I came to ask for it. I have a tkinter GUI with an entry and a validation button. I'd like to call the same function when I press a key in the entry,...

Tkinter: Update widget from different module

python,python-3.x,tkinter
I've got a Tkinter application that I'm writing in Python 3. I've got one module which contains a class in which I create all my widgets. I'm trying to update a progress bar from a separate module that does the heavy lifting. #GUI.py import tkinter as tk from tkinter.filedialog import...

Declaration of FigureCanvasTkAgg causes memory leak

python,python-2.7,matplotlib,memory-leaks,tkinter
I'm having difficulty figuring out just why the declaration of FigureCanvasTkAgg causes a memory leak, I have the following lines in my class __init__ method: # pndwinBottom is a paned window of the main screen self.__drawplotFrame = Frame(pndwinBottom, width=WIDTH, height=HEIGHT) # the frame on which we will add our canvas...

Reset Tkinter Widget to its default value

python,tkinter
In need to make a generic function that on event it would return the focused-out widget to its default value. Is there a way to accomplish this? Example: entry1 = Tkinter.Entry() entry1.grid(..) entry1.insert(0,"hello") entry1.bind("<FocusIn>", EntryFocusedIn) entry1.bind("<FocusOut>", EntryFocusedOut) entry2 = Tkinter.Entry() entry2.grid(..) entry2.insert(0,"again") entry2.bind("<FocusIn>", EntryFocusedIn) entry2.bind("<FocusOut>", EntryFocusedOut) def EntryFocusedIn(params): params.widget.delete(0, Tkinter.END)...

Python tkinter button lagging/printing upon exit

python,user-interface,button,tkinter,canopy
First of all note that I am doing all these in Enthought/Canopy. I have this basic GUI where it has 4 entry boxes in which you type stuff, and then you hit a button and it prints the stuff you entered. However, it is not operating the way I want...

Understanding Super() in python

python,python-3.x,tkinter
class SeaofBTCapp(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) container = tk.Frame(self) Hello all I am trying to understand objects and classes. Using tkinter the author has created a class which inherits from the Tk() class of tkinter and proceeds to write his own __init__ method which I assume overrides...

Tkinter Reddit scraper (Tkinter and Praw) returns error “TypeError”

python,tkinter,typeerror,reddit,scraper
Im relatively new to python and am trying to create a tkinter application that collects information from a specific subreddit and returns it back to the user in a tkinter window. However, when I run the code it returns the error: TypeError: 'NoneType' object has no attribute 'getitem' There appears...

timer that calls every n milliseconds a function without .after or threading

python,timer,tkinter
I need a timer that calls a function every n milliseconds. This should not be in a endloss loop (while true) or something like that import threading def printit(): threading.Timer(5.0, printit).start() print "Hello, World!" Or def printit(): root.after(100,printit()) As I have a GUI that should be able to interact. So...

Problems with MySQLdb python

python,python-2.7,tkinter,mysql-python
When I try connect to mysql with user "root", my application returns "Access denied for user *"ODBC"@"localhost" (using password:NO)"*. I dnt know why this appear. Im using Tkinter like GUI, I tested only Connection's script, its Okay. Code Connection import MySQLdb class Conexao(): def __init__(self, host,user,passwd,db): self.host = host self.user...

Tkinter code using font module can't run from command line?

python,tkinter
I have code using tkinter which I can run from IDLE just fine, but which throws the exception AttributeError: 'module' object has no attribute 'font' when it is run from the command line. Other tkinter programs work fine, but anything using the tkinter package's font.py gives me this error. I've...

How do I change the text size in a label widget, python tkinter [duplicate]

python,tkinter,label
This question already has an answer here: How to change a widget's font style without knowing the widget's font family/size? 5 answers In python 3.4 using Tkinter, how do I change the text size in a label widget? So far I have tried label_one = Label(root, text = 'Hello',...

Using a variable to call a function in Python 3 and tkinter

python,function,variables,tkinter,tkmessagebox
I have a few different functions that I want to call, but I would like to use a the value of a variable to do it. I'm using buttons in tkinter to change the value of the variable, as well as a button that picks a random variable, and a...

Unable to call validatecommand in python 2.7 Tkinter GUI

python,python-2.7,user-interface,tkinter
I am creating a GUI in Python 2.7 using Tkinter and am now trying to implement a value check for my entry boxes using validatecommand. When I run the GUI, it runs the check function because it is 'forced' but I also want it to call the check function when...

Why is my tkinter toplevel 'X' button over-ride method not being called?

python,tkinter
I have created a toplevel widget class and want to it to call the method 'close' when the window is 'X' (closed). I get the error - name 'close' not defined. Could someone help me getting this method to run when the toplevel window is closed? Code in focus: class...

Create circular image PIL Tkinter

python,user-interface,tkinter,python-imaging-library
Currently I have a zoom feature in my application that works very well, however I'd like the actual zoom box to be a circle instead. Here's what the current zoom looks like: the zoomed in rectangle is where the mouse pointer location is, and surrounding area is zoomed in. But...