tkinter

Tkinter layout question

Tricky to explain with words so I'll use a picture. A: row 0, column 0 B: row 0, column 1 C: row 1, column 0, span 2 ...

Get coords of an oval in Tkinter

I can't seem to figure out how to reterive the x,y position of an oval created on a Tkinter canvas using Python via c.create_oval(x0, y0, x1, y2) I understand that Tkinter creates the oval inside the box specified by x0,y0,x1,y2 and if I can get those coordinates that would also work. I need the coordinates to move the oval by an off...

Background color for Tk in Python

I'm writing a slideshow program with Tkinter, but I don't know how to change the background color to black instead of the standard light gray. How can this be done? import os, sys import Tkinter import Image, ImageTk import time root = Tkinter.Tk() w, h = root.winfo_screenwidth(), root.winfo_screenheight() root.overrideredirect(1) root...

Python modules not updating after restarting the main module.

I've recently come back to a project having had to stop for about 6 months, and after reinstalling my operating system and coming back to it I'm having all kinds of crazy things happen. I made sure to install the same version(2.6) of python that I was using before. It started by giving me strange tkinter error that I hadn't had trouble ...

[Python/Tkinter] Grid within a frame?

Is it possible to place a grid of buttons in Tkinter inside another frame? I'm wanting to create a tic-tac-toe like game and want to use the grid feature to put gamesquares (that will be buttons). However, I'd like to have other stuff in the GUI other than just the game board so it's not ideal to just have everything in the one grid. ...

A Tkinter StringVar() Question

I would like to create a StringVar() that looks something like this: someText = "The Spanish Inquisition" #Here's a normal variable whose value I will change eventually TkEquivalent = StringVar() #and here's the StringVar() TkEquivalent.set(string(someText)) #and here I set it equal to the normal variable. When someText changes, t...

How do I attach event bindings to items on a canvas using Tkinter?

If I'm using a canvas to display data and I want the user to be able to click on various items on the canvas in order to get more information or interact with it in some way, whats the best way of going about this? Searching online I can find information about how to bind events to tags but that seems to be more indirect then what I wa...

[Tkinter/Python] Different line widths with canvas.create_line?

Does anyone have any idea why I get different line widths on the canvas in the following example? from Tkinter import * bigBoxSize = 150 class cFrame(Frame): def __init__(self, master, cwidth=450, cheight=450): Frame.__init__(self, master, relief=RAISED, height=550, width=600, bg = "grey") self.canvasWidth = cwidth ...

How to achieve interaction between GUI class with logic class

Im new to GUI programming, and haven't done much OOP. Im working on a basic calculator app to help me learn GUI design and to brush up on OOP. I understand that anything GUI related should be kept seperate from the logic, but Im unsure how to implement interaction between logic an GUI classes when needed i.e. basically passing variables ...

Dynamically add items to Tkinter Canvas

I'm attempting to learn Tkinter with the goal of being able to create a 'real-time' scope to plot data. As a test, I'm trying to draw a polygon on the canvas every time the 'draw' button is pressed. The triangle position is randomized. I have two problems: There is a triangle on the canvas as soon as the program starts, why and how do ...

Automatically support new changes with Python.

I was working on a program,that I need to support new additions. Hmmm. Let me give you some background on the program. It is an educational software program that has quizzes for the user to take, just to gain odd knowledge. Now, It currently supports 6 subjects, all organized with directores on the HDD ( i.e. the Science directory is ca...

Randomly add buttons to Tkinter GUI?

How do I randomly add buttons to a Tkinter GUI? I need it to be able to create a button, then put it anywhere on the window, is this possible? I am using Python 2.6 on Windows. ...

Creating a sliding frame containing widgets in tkinter in python

I am trying really hard to make a sliding frame containing widgets in tkinter in python. There is this frame inside a big window with different widgets. And as soon as i click on the next button on that frame the frame should slowly slide towards the left and vanish ultimately. As soon as it vanishes, i want new frame with widgets to com...

tkinter integration with glib mainloop

Is it possible to integrate tkinter with glib mainloop ? ...

Why do I get a segmentation fault while redirecting sys.stdout to Tkinter.Text widget in Python?

I'm in the process of building a GUI-based application with Python/Tkinter that builds on top of the existing Python bdb module. In this application, I want to silence all stdout/stderr from the console and redirect it to my GUI. To accomplish this purpose, I've written a specialized Tkinter.Text object (code at the end of the post). ...

Calculating the pixel size of a string with Python

I have a Python script which needs to calculate the exact size of arbitrary strings displayed in arbitrary fonts in order to generate simple diagrams. I can easily do it with Tkinter. import Tkinter as tk import tkFont root = tk.Tk() canvas = tk.Canvas(root, width=300, height=200) canvas.pack() (x,y) = (5,5) text = "yellow world" fonts ...

Python/Tkinter Label bound to StringVar is one click behind when updating

I have a simple program I'm writing to try to get some skills with Tkinter. The problem I'm running into here is that when I click on the different file names in the Listbox, the Label changes value one click behind whatever I'm currently clicking on. To replicate: Start the program, label is blank. Click on any of the entries in the...

Python/Tkinter Audio Player

Hey everyone reading this, I've recently got into doing GUI development with Python. Tkinter seems like the easiest and most logical choice starting out. I did a little with wxPython but it was more sophisticated than what I needed. Anyway, I'm developing a media player. Right now it's a simple window with a button to load .wav files. ...

Printing python tkinter output

I am trying to print the contents of a python tkinter canvas. I have tried using the postscript method of canvas to create a postscript file, but I get a blank page. I know this is because I have embedded widgets, and these do not get rendered by the postscript method. Before I rewrite my program to create a more printer-friendly layo...

Which method can I override for cleanup task when a Tkinter.Tk window in Python?

Hello. I created: class MainGUI(Tkinter.Tk): # some overrides # MAIN gui = MainGUI(None) gui.mainloop() But I need to do some cleanup when the window is closed by the user. Which method in Tkinter.Tk can I override? ...