tkinter

How to use Python tkSimpleDialog.askstring

I want to use the response from an askstring prompt to set a variable. Unfortunately, I have the dilemma that I'm trapped in the loop asking the question or the window refuses to draw because the variable (urltoopen) has no value. The code as it stands: urltoopen = tkSimpleDialog.askstring('Address', 'Where do we get the pictures from?...

ttk.Button returns None.

I am trying to use the invoke method of a ttk.Button, as shown at TkDocs (look at "The Command Callback"), but I keep getting this error: AttributeError: 'NoneType' object has no attribute 'invoke' So, I tried this in the Interactive Shell: ActivePython 3.1.1.2 (ActiveState Software Inc.) based on Python 3.1.1 (r311:74480,...

Why does not the Python MSI installers come with Tcl/Tk header files?

The MSI installers downloadable from python.org does not include Tcl/Tk header (not source) files (that are required to compile some packages like matplotlib). Does anyone know of the rationale behind not including them? ...

Python bind - allow multiple keys to be pressed simultaniously

I have a problem in Python. I'm using Tkinter and have four bind events, that listen to key presses on my form. My problem is, that these don't run asynchronously. So, for example I can press one button, and the events are recognized. But when I press and hold two keys at the same time, just one event gets fired. Is there an alternativ...

Python 3.1 Tkinter layout help. I am close, please help me finish this.

I am using Python 3.1 by the way. I am trying to build a simple GUI using Tkinter - label, text entry field, button on the first row and editable text area with scrollbar to the right and on the bottom of it - on the second row. Please help me fix up the layout. What I have below does not quite work. If I have to use a grid, I will. I w...

cx_Freeze problem with Tkinter

I'm trying do a executable for windows for a gui aplication in tkinter using the ttk, I made a exe with cx_freeze, but when run the app in the console, it give me the following error. D:\My Dropbox\python\SAR Calculator\src\dist_tk> Traceback (most recent call last): File "C:\Python31\lib\site-packages\cx_Freeze\ 7, in <modul...

Tkinter Canvas Does Not Display

I'm attempting to learn some Python and Tkinter. The sample code below is intended to put two windows on the screen, a few buttons, and a Canvas with an image in it and some lines drawn on it. The windows and buttons appear just fine, however I'm not seeing either the canvas image or canvas lines. I'd appreciate some help to figure ou...

TKinter in python Gui programming

Hello, I want to show my calculated output to Gui window in python.I am trying with Tkinter.But having problem to get output on Tkinter level widget.The thing is that, I am putting input data as address information in text field of Tkinter window and want latitude , longitude of that inputed address to the text label. Can anyone please h...

Tcl/Tk Tkinter version 8.4 and 8.5 conflict on Mac Os X 10.4.11 with python 2.6.4

Hi, I am having trouble getting Tkinter up and runnning in order to install matplot lib. I am running Mac OS X 10.4.11, and just installed Python 2.6.4 . After several other fights, one remaining battle for me to get matlotlib installed is to have a working version of Tkinter, although there are several in my Mac from Xcode and also ...

Python Text widget in Tkinter

from Tkinter import * root = Tk() root.title("Whois Tool") text = Text() text1 = Text() text1.config(width=15, height=1) text1.pack() def button1(): text.insert(END, text1) b = Button(root, text="Enter", width=10, height=2, command=button1) b.pack() scrollbar = Scrollbar(root) scrollbar.pack(side=RIGHT, fill=Y) text.config(...

How to clear the entry widget in a GUI after a button is pressed in python

I'm trying to clear the entry widget after the user presses a button using tkinter in python. I tried using ent.delete(0,END) but I got an error saying that strings dont have the attribute delete here is my code: I'm getting error on real.delete(0, END). secret = randrange(1,100) print(secret) def res(real, secret): if secret==eval...

How can I resize the root window in Tkinter?

from Tkinter import * import socket, sys from PIL import Image, ImageTk root = Tk() root.title("Whois Tool") root.resizable(0, 0) text = Text() text1 = Text() image = Image.open("hacker2.png") photo = ImageTk.PhotoImage(image) label = Label(root, image=photo) label.pack() text1.config(width=15, height=1) text1.pack() def button1()...

How can I put 2 buttons next to each other?

b = Button(root, text="Enter", width=10, height=2, command=button1) b.config() b.pack(side=LEFT) c = Button(root, text="Clear", width=10, height=2, command=clear) c.pack(side=LEFT) scrollbar = Scrollbar(root) scrollbar.pack(side=RIGHT, fill=Y) text.config(width=35, height=15) text.pack(side=RIGHT, fill=Y) scrollbar.config(command=text...

Deleting a file

from Tkinter import * import socket, sys, os import tkMessageBox root = Tk() root.title("File Deleter v1.0") root.config(bg='black') root.resizable(0, 0) text = Text() text3 = Text() frame = Frame(root) frame.config(bg="black") frame.pack(pady=10, padx=5) frame1 = Frame(root) frame1.config(bg="black") frame1.pack(pady=10, padx=5) t...

displaying a large amount of formated text in Python

I have two large identical-sized files. One is ASCII plain text, and the other is a colour-coded overlay, one byte per text character in the corresponding file. These files can be large - upto 2.5 MB; possibly substantially more, perhaps over 100MB later. I want to display the text is a scrollable text viewer, using the second file as...

How to set pythonpath (python2.6) for tkinter on Ubuntu 9.04 (to use nltk)?

I'd like to use the nltk toolkit on my machine which runs Ubuntu 9.04. I installed python 2.6.4 and several additional packages (numpy, scipy, matplotlib and of course nltk). I can import nltk, but calling a few methods gives various error masseges, all contain "please install Tkinter library". Googling around I discovered from http://wi...

tkinter: Specifying arguments for a function that's called when you press a button

button1 = tkinter.Button(frame, text="Say hi", command=print) button2 = tkinter.Button(frame, text="foo", command=print) button3 = tkinter.Button(frame, text="bar", command=print) You've probably spotted the hole in my program: print can't specify arguments. This renders the whole thing useless and faulty. Obviously, having something l...

In Python using Tkinter, what is the difference between root.destroy() and root.quit()?

In Python using Tkinter, what is the difference between root.destroy and root.quit when closing the root window? Is one prefered over the other? Does one release resources that the other doesn't? ...

clicking "cancel" in tkColorChooser dialog leads to Error

I use python 2.6 under linux (SUSE Linux Enterprise Desktop 11 (x86_64)). I tested some very simple code : import tkColorChooser tkColorChooser.askcolor() then if I click on cancel, I always get error like: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.6/lib-tk/tkColorChooser.py",...

How to print contents of a Python Tkinter.Canvas control?

How would i print contents of a Python Tkinter.Canvas control? I've read that it is possible to print to a postscript printer from this control but examples are hard to come by. So, any ideas how what is needed to print the contents (including images)? If you've got a cross-platform method all the better! ...