tkinter

How do I use PIL with Tkinter?

I'm missing something at a very basic level when it comes to loading an image using PIL and displaying it in a window created by Tkinter. The simplest form of what I'm trying to do is: import Tkinter as TK from PIL import Image, ImageTk im = Image.open("C:\\tinycat.jpg") tkIm = ImageTk.PhotoImage(im) tkIm.pack() TK.mainloop() When I ...

Display jpg images in python

I am creating a simple tool to add album cover images to mp3 files in python. So far I am just working on sending a request to amazon with artist and album title, and get the resulting list, as well as finding the actual images for each result. What I want to do is to display a simple frame with a button/link for each image, and a skip/c...

How do you check if a widget has focus in Tkinter?

from Tkinter import * app = Tk() text_field = Entry(app) text_field.pack() I want to be able to check if text_field is currently selected or focused so that I know whether or not to do something with its contents when the user presses enter. ...

How do I get rid of Python Tkinter root window?

Do you know a smart way to hide or in any other way get rid of the root window (opened by Tk()) that appears (at least on Win32). I would like to use a normal dialog, but it looks like this: (The window on the left is unwanted.) Should I skip the dialog and put all my components in the root window? Is it possible+desirable? Or is ther...

Why do I have this TypeError when using tkinter?

so I upgraded to python 3.1.1 from 2.6 and i ran an old program of mine which uses tkinter. I get the following error message which I don't recall getting in the 2.6 version. Exception in Tkinter callback Traceback (most recent call last): File "C:\Python31\lib\tkinter\__init__.py", line 1399, in __call__ return self.func(*args) ...

Tkinter grid geometry manager size propagation (with sticky)

I'm missing something about how sizes propagate in Tk. Try this: from Tkinter import * root = Tk() frame1 = Frame(root, border=4, relief=RIDGE) frame1.grid(sticky=E+W) frame2 = Frame(root, border=4, relief=RIDGE) frame2.grid(sticky=E+W) label1 = Label(frame1, text='short', background='white') label1.grid(sticky=E+W) label2 = Label(fr...

How can I change the focus from one text box to another in Python Tkinter?

I'm new to Python and I'm trying to create a simple GUI using Tkinter. So often in many user interfaces, hitting the tab button will change the focus from one text box to another. Whenever I'm in a text widget, tab only indents the text cursor. Does anyone know if this is configurable? If not, can PyQt or any other Python UI framewor...

How to pack a tkinter widget underneath an existing widget that has been packed to the left side?

Hi all, I'm attempting to write a basic Tkinter GUI that has a Text widget at the top, then a Button widget left aligned under it, then another Text widget underneath the button. The problem I'm having is, after packing the Button widget to the left, when I then go to pack the second Text widget, it puts it next to the button on the ri...

Tkinter how to remove existing background color of text when highlighting

I'm writing a small utility in Python that does some pattern matching of text. Text that matches the pattern the user has entered gets highlighted yellow. I'm achieving this using a Tkinter Text widget, and setting up a tag on the textbox named "match" that gives any text with the tag name "match" a yellow background. This all looks n...

How do I change the foreground or background colour of a Tkinter button on Max OS X 10.6 with Python 2.6.1?

I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example: from Tkinter import * Label(N...

Determine which button was pressed with tkinter in Python?

I'm making a simple little utility while learning Python. It dynamically generates a list of buttons: for method in methods: button = Button(self.methodFrame, text=method, command=self.populateMethod) button.pack({'fill': 'x', 'expand': 1, 'padx': 5, 'pady': 3}) That part works fine. However, I need to know which of the butt...

In python's tkinter, how can I make a Label such that you can select the text with the mouse?

In python's tkinter interface, is there a configuration option that will change a Label such that you can select the text in the Label and then copy it to the clipboard? EDIT: How would you modify this "hello world" app to provide such functionality? from Tkinter import * master = Tk() w = Label(master, text="Hello, world!") w.pack(...

Timer in Python

Hi, I am writing a python app using Tkinter for buttons and graphics and having trouble getting a timer working, what I need is a sample app that has three buttons and a label. [start timer] [stop timer] [quit] When I press the start button a function allows the label to count up from zero every 5 seconds, the stop button stops the t...

Dice Roller using Tkinter

Thank you to everybody who helped answer my last question: My friend took the code, and has attempted to use Tkinter to make a box that we could use to make things nicer-looking, but he has been unable to integrate the dice roller from the last question and the Tkinter. Any help or ideas in getting the dice roller into the code below w...

Python Tkinter Prompt

I am trying to prompt the user to enter a string of text. Is there available with python tkinter a Javascript like prompt? ...

Need a GUI Builder for Tkinter / Python

Hello, I need a GUI Builder for Tkinter... was using something a couple of years ago, but I can't find it anymore (I remember something related to Komodo IDE, but perhaps I'm wrong). Please don't give me links to non-functional, old or dead projects, because I found lots of them and none worked; I need something functional. Also, I don'...

Twisted/tkinter program crashes on exit.

I am running an app using twisted and tkinter that sends the result to the server, waits for the server to send back a confirmation, and then exits. So, the function I use to exit is this: def term(): '''To end the program''' reactor.stop() root.quit() root.destroy() This is then set in the factory and called in the da...

How to play sound till the user hits a key?

First thought of implementing this using threads but python doesnt have a way for killing threads. I have read the other topic on killing threads. Is there any proper platform independent way of doing this? ...

How to bundle tkinter?

I am distributing an app that uses the Python/C API. I have all standard python modules in python31.zip which is basically an archive of the Lib folder in the python install directory. Here is the problem - most common modules like sys and io work fine. BUT tkinter does not. I get an error "cannot find module _tkinter". I really need tki...

How do I get stdout from tcl into a python string variable when using tkinter?

Hi I have the following python code... import Tkinter root = Tkinter.Tk() root.tk.eval('puts {printed by tcl}') It prints "printed by tcl" to the screen. How can I capture what the tcl interpreter prints to the screen into a python string. This is a simplified example of what I am doing. I have an automation system written in pyt...