tkinter

How to know whether a window with a given title is already open in Tk?

Hi, I’ve writen a little python script that just pops up a message box containing the text passed on the command line. I want to pop it up only when the window —resulting from a previous call— is not open. from Tkinter import * import tkMessageBox root = Tk() root.withdraw() # TODO not if a window with this title exists tkMessageBox...

Change command Method for Tkinter Button in Python

I create a new Button object but did not specify the command option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created? ...

How do I end a Python Tkinter program?

How do I end a Python Tkinter program? Let's say I have this code: from Tkinter import * def quit(): ??? root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop() How should I define the quit() routine? ...

How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program?

How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program? ...

How do I find out the size of a canvas item in Python/Tkinter?

I want to create some text in a canvas: myText = self.canvas.create_text(5, 5, anchor=NW, text="TEST") Now how do I find the width and height of myText? ...

How do I overlap widgets with the pack geometry manager in Python/Tkinter?

I want to put a canvas with an image in my window, but then I want to pack() widgets over top of it so the canvas acts as a background. Is it possible to have two states for the pack() manager, one for one set of widgets and another for another set? ...

How to update a Tix.ComboBox's text?

I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update? Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text field currently has the value "...

Get Bound Event Handler in Tkinter

After a bind a method to an event of a Tkinter element is there a way to get the method back? >>> root = Tkinter.Tk() >>> frame = Tkinter.Frame(root, width=100, height=100) >>> frame.bind('<Button-1>', lambda e: pprint('Click')) # function needed >>> frame.pack() >>> bound_event_method = frame.??? ...

Date change notification in a Tkinter app (win32)

Does anyone know if it is possible (and if yes, how) to bind an event (Python + Tkinter on MS Windows) to a system date change? I know I can have .after events checking once in a while; I'm asking if I can somehow have an event fired whenever the system date/time changes, either automatically (e.g. for daylight saving time) or manually....

Help with <key> event in python Entry widget

Hey, I'm writing some code in python and I'm having trouble when trying to retrieve content of an Entry widget. The thing is: I want to limit the characters that can be typed, so I'm trying to clear the Entry widget when I reach the specific number of characters (2 in this case), but it looks like I always miss the last typed character....

I need some help with cursor event handling in python+Tkinter

Hey, I'm building a code in which I'd like to be able to generate an event when the user changes the focus of the cursor from an Entry widget to anywhere, for example another entry widget, a button... So far i only came out with the idea to bind to TAB and mouse click, although if i bind the mouse click to the Entry widget i only get m...

How do I use Tkinter with Python on Windows Vista?

I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this? ...

TkInter Invoke Event in Main Loop

How do you invoke a tKInter event from a separate object? I'm looking for something like wxWidgets wx.CallAfter. For example, If I create a child object and pass it my root Tkinter.Tk() and then try to call a method of that root window from the child object my app locks up. The best I can come up with is to use the .after method and...

Tabs in Tkinter

Having played around a little with both Tkinter and wxPython, I like Tkinter much better in terms of how clean my source code looks. However, it doesn't seem to have as many features; in particular it doesn't have tabs (as in, the tabs at the top of a Firefox window). A little Googling on the subject offers a few suggestions. There's ...

Tix documentation for Python

I've recently starting playing around with Tix in Python, and I'm distressed at the lack of Python documentation for it online. Both the tutorial and book have plenty of code examples in Tcl and none in Python. Googling has turned up no good Python docs. What do Tix users do for their Python documentation? Do they just learn to read ...

destroying a Toplevel tk window in python

I was trying to write code that would auto-close a Toplevel Tk window in Python. I ended up getting it to work, but ran into a little problem along the way that I wasn't able to figure out. The second two buttons work, but the first one doesn't and I don't understand why... Any ideas? from Tkinter import * root = Tk() def doDestroy ...

Close an easygui Python script with the standard 'close' button

I've created a very simple app, which presents an easygui entrybox() and continues to loop this indefinitely as it receives user input. I can quit the program using the Cancel button as this returns None, but I would also like to be able to use the standard 'close' button to quit the program. (ie. top right of a Windows window, top left...

Why don't TKinter windows appear when using multiprocessing on Linux?

I want to spawn another process to display an error message asynchronously while the rest of the application continues. I'm using the multiprocessing module in Python 2.6 to create the process and I'm trying to display the window with TKinter. This code worked okay on Windows, but running it on Linux the TKinter window does not appear if...

How to copy a picture from canvas to clipboard?

I have some Tkinter canvas and some picture of lines and text on it. Is there an easy way to copy it to a clipboard? ...

How do you run your own code alongside Tkinter's event loop?

My little brother is just getting into programming, and for his Science Fair project, he's doing a simulation of a flock of birds in the sky. He's gotten most of his code written, and it works nicely, but the birds need to move every moment. Tkinter, however, hogs the time for its own event loop, and so his code won't run. Doing root.ma...