Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Problems programming with Tkinter (

Svennglenn 01-02-2005 11:47 AM

Problems programming with Tkinter
Hi !

I'm trying to create a graphical program using Tkinter.
The program is supposed to save a string the user defines
as a filename. I've made it work with the the first button
in the program that's named "Spara ett värde i en sträng till ett
filnamn", that's swedish for "Save a value in a string as a file name".
The button "Skriv ett värde till filen" (swedish for "Write a value to
the file")

But, i want the program to open a new dialogue when i press the button
"Visa ruta" and in that dialogue will be a field where you can enter a
value directly in the program, but a can't get it to work because is
don't know how i shall do to open a new dialogue window in the program?
Is there someone who can help me with my problem?

Here's the sourcecode for my program:

from Tkinter import *
class App:

def __init__(self, master):

frame = Frame(master)

self.hi_there = Button(frame, text="Spara ett värde i en
sträng till ett filnamn", command=self.say_hi)

self.skriv_varde = Button(frame, text="Skriv ett värde till
filen", command=self.skriv_varde)

self.visa_ruta = Button(frame, text="Visa ruta",

def say_hi(self):
print "Sparar fil"
S = "filen.fil"
output = open(S, 'w')
print "Filen sparad"

def skriv_varde(self):
print "Skriver värde till filen"
myfile = open('filen.fil', 'w')

myfile.write('Ny mening')
print "Värdet till filen skrivet"

def visa_ruta(self, parent):

top = = Toplevel(parent)

Label(top, text="Value").pack()

self.e = Entry(top)

b = Button(top, text="OK", command=self.ok)

def ok(self):

print "value is", self.e.get()

root = Tk()

app = App(root)

All times are GMT. The time now is 08:59 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.