<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Problems programming with Tkinter' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Problems programming with Tkinter' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 02:39:15 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 02:39:15 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Problems programming with Tkinter</title>
      <link>http://www.programmersheaven.com/mb/python/287098/287098/problems-programming-with-tkinter/</link>
      <description>Hi !&lt;br /&gt;
&lt;br /&gt;
I'm trying to create a graphical program using Tkinter.&lt;br /&gt;
The program is supposed to save a string the user defines&lt;br /&gt;
as a filename. I've made it work with the the first button&lt;br /&gt;
in the program that's named "Spara ett vrde i en strng till ett filnamn", that's swedish for "Save a value in a string as a file name".&lt;br /&gt;
The button "Skriv ett vrde till filen" (swedish for "Write a value to the file")&lt;br /&gt;
&lt;br /&gt;
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?&lt;br /&gt;
Is there someone who can help me with my problem?&lt;br /&gt;
&lt;br /&gt;
Here's the sourcecode for my program:&lt;br /&gt;
&lt;br /&gt;
from Tkinter import *&lt;br /&gt;
class App:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   def __init__(self, master):&lt;br /&gt;
&lt;br /&gt;
       frame = Frame(master)&lt;br /&gt;
       frame.pack()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       self.hi_there = Button(frame, text="Spara ett vrde i en strng till ett filnamn", command=self.say_hi)&lt;br /&gt;
       self.hi_there.pack(side=LEFT)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       self.skriv_varde = Button(frame, text="Skriv ett vrde till filen", command=self.skriv_varde)&lt;br /&gt;
       self.skriv_varde.pack(side=LEFT)&lt;br /&gt;
&lt;br /&gt;
       self.visa_ruta = Button(frame, text="Visa ruta", command=self.visa_ruta)&lt;br /&gt;
       self.visa_ruta.pack(side=LEFT)&lt;br /&gt;
&lt;br /&gt;
   def say_hi(self):&lt;br /&gt;
       print "Sparar fil"&lt;br /&gt;
       S = "filen.fil"&lt;br /&gt;
       output = open(S, 'w')&lt;br /&gt;
       print "Filen sparad"&lt;br /&gt;
&lt;br /&gt;
   def skriv_varde(self):&lt;br /&gt;
       print "Skriver vrde till filen"&lt;br /&gt;
       myfile = open('filen.fil', 'w')&lt;br /&gt;
&lt;br /&gt;
       myfile.write('Ny mening')&lt;br /&gt;
       myfile.close()&lt;br /&gt;
       print "Vrdet till filen skrivet"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   def visa_ruta(self, parent):&lt;br /&gt;
&lt;br /&gt;
       top = self.top = Toplevel(parent)&lt;br /&gt;
&lt;br /&gt;
       Label(top, text="Value").pack()&lt;br /&gt;
&lt;br /&gt;
       self.e = Entry(top)&lt;br /&gt;
       self.e.pack(padx=5)&lt;br /&gt;
&lt;br /&gt;
       b = Button(top, text="OK", command=self.ok)&lt;br /&gt;
       b.pack(pady=5)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   def ok(self):&lt;br /&gt;
&lt;br /&gt;
       print "value is", self.e.get()&lt;br /&gt;
&lt;br /&gt;
       self.top.destroy()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
root = Tk()&lt;br /&gt;
&lt;br /&gt;
app = App(root)&lt;br /&gt;
root.mainloop()&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/287098/287098/problems-programming-with-tkinter/</guid>
      <pubDate>Sat, 01 Jan 2005 19:01:26 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Problems programming with Tkinter</title>
      <link>http://www.programmersheaven.com/mb/python/287098/287174/re-problems-programming-with-tkinter/#287174</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by Drost at  2005-1-3 0:23:4&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Hi !&lt;br /&gt;
:&lt;br /&gt;
&lt;br /&gt;
--- Deliberatelly cut for shortening the message ---&lt;br /&gt;
 &lt;br /&gt;
: 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?&lt;br /&gt;
: Is there someone who can help me with my problem?&lt;br /&gt;
: &lt;br /&gt;
: Here's the sourcecode for my program:&lt;br /&gt;
: &lt;br /&gt;
: from Tkinter import *&lt;br /&gt;
: class App:&lt;br /&gt;
:    def __init__(self, master):&lt;br /&gt;
:        frame = Frame(master)&lt;br /&gt;
:        frame.pack()&lt;br /&gt;
:        self.hi_there = Button(frame, text="Spara ett vrde i en strng till ett filnamn", command=self.say_hi)&lt;br /&gt;
:        self.hi_there.pack(side=LEFT)&lt;br /&gt;
:        self.skriv_varde = Button(frame, text="Skriv ett vrde till filen", command=self.skriv_varde)&lt;br /&gt;
:        self.skriv_varde.pack(side=LEFT)&lt;br /&gt;
:        &lt;span style="color: Red;"&gt;self.visa_ruta&lt;/span&gt; = Button(frame, text="Visa ruta", command=&lt;span style="color: Red;"&gt;self.visa_ruta&lt;/span&gt;)&lt;br /&gt;
:        self.visa_ruta.pack(side=LEFT)&lt;br /&gt;
: &lt;br /&gt;
:    def say_hi(self):&lt;br /&gt;
:        print "Sparar fil"&lt;br /&gt;
:        S = "filen.fil"&lt;br /&gt;
:        output = open(S, 'w')&lt;br /&gt;
:        print "Filen sparad"&lt;br /&gt;
: &lt;br /&gt;
:    def skriv_varde(self):&lt;br /&gt;
:        print "Skriver vrde till filen"&lt;br /&gt;
:        myfile = open('filen.fil', 'w')&lt;br /&gt;
: &lt;br /&gt;
:        myfile.write('Ny mening')&lt;br /&gt;
:        myfile.close()&lt;br /&gt;
:        print "Vrdet till filen skrivet"&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
:    def &lt;span style="color: Red;"&gt;visa_ruta&lt;/span&gt;(self, parent):&lt;br /&gt;
:        top = self.top = Toplevel(parent)&lt;br /&gt;
:        Label(top, text="Value").pack()&lt;br /&gt;
:        self.e = Entry(top)&lt;br /&gt;
:        self.e.pack(padx=5)&lt;br /&gt;
:        b = Button(top, text="OK", command=self.ok)&lt;br /&gt;
:        b.pack(pady=5)&lt;br /&gt;
: &lt;br /&gt;
:    def ok(self):&lt;br /&gt;
:        print "value is", self.e.get()&lt;br /&gt;
:        self.top.destroy()&lt;br /&gt;
: &lt;br /&gt;
: root = Tk()&lt;br /&gt;
: app = App(root)&lt;br /&gt;
: root.mainloop()&lt;br /&gt;
&lt;br /&gt;
Maybe a simpler solution is to use the tkSimpleDialog module's askstring function to get the user enter a value (hint: &lt;a href="http://www.pythonware.com/library/tkinter/introduction/x1164-data-entry.htm)"&gt;http://www.pythonware.com/library/tkinter/introduction/x1164-data-entry.htm)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The main problem seems to be a naming error where you assign to self.visa_ruta an instance of a Button widget and also there is a function with the same identifier later (the one which you've told to be the callback function of the button).&lt;br /&gt;
&lt;br /&gt;
Hope these'll help.&lt;br /&gt;
&lt;br /&gt;
Drost&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/287098/287174/re-problems-programming-with-tkinter/#287174</guid>
      <pubDate>Mon, 03 Jan 2005 00:18:51 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>