Tkinter hangs again under Windows

Radovan Garabik garabik at melkor.dnp.fmph.uniba.sk.spam
Tue Jan 18 04:44:47 EST 2000


jbhr at my-deja.com wrote:
 : By searching the FAQ and Deja News, the last time I saw this
 : mentioned was May 1999.

 : Python 1.5.2, newest Windows Installer with Tcl/Tk 8.0.5, Windows 95b

 : Well, now I have the problem: tk.mainloop() seems to just ignore
 : any event, but only under certain circumstances.

 : My program opens a file and displays some information of it in a
 : Listbox. If the program is started with a filename argument, this
 : file is read, otherwise a filename is prompted via
 : tkFileDialog.askopenfilename(). The info is then shown.
 : Now, if the program is started with a filename, everything (well,
 : almost :-)) is working fine - I can select items in the listbox,
 : use the menu or the button. If the program is started without a
 : filename, the file select box comes up, lets me select a file, and
 : the info is then displayed as well. The difference starts when I try
 : to select something - nothing happens. A Ctrl-C always breaks in
 : Tkinter.py, line 492: mainloop.
 : This problem doesn't exist under Linux. And it's the second Windows PC
 : with the very same problem.

I have the same problem. I have not investigated it further, though.
However, I do not use tkFileDialog.askopenfilename, but
tkMessageBox.showwarning. (and the program stops responding when there is no
gnuplot module, i.e. when it shows tkMessageBox.showwarning)


the relevant parts of the program:

#!/usr/bin/python
from Tkinter import *
import string, pickle
import tkSimpleDialog, tkMessageBox, tkFileDialog

have_gnuplot = 1
try:
    import Gnuplot
except:
    have_gnuplot = 0

...

class App(Frame):
    def __init__(self, master=None):
        self.list=[] 
        self.frame=Frame(master)
        self.frame.pack()

        if not have_gnuplot:
            self.g = Canvas(self.frame, width="4i", height="4i")
            self.g.pack(side=RIGHT)

        scrollbar = Scrollbar(self.frame, orient=VERTICAL)
        self.listbox = Listbox(self.frame, width=35, yscrollcommand=scrollbar.set)
        self.listbox.bind("<Double-Button-1>", self.edit)
        scrollbar.config(command=self.listbox.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.listbox.pack(side=LEFT, fill=BOTH, expand=1)

        self.loadb = Button(self.frame,
                        text="Load",
                        width=7,
                        command=self.load)
        self.loadb.pack(side=TOP)

        ....

        if not have_gnuplot:
            tkMessageBox.showwarning("Gnuplot missing", "Gnuplot.py not found, falling back to tkinter")


if have_gnuplot:
    g = Gnuplot.Gnuplot()
    g.title('title')
    g.xlabel('x')
    g.ylabel('y')


root = Tk()
app = App(root)
root.title("title")
root.mainloop()

 

-- 
 -----------------------------------------------------------
| Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__    garabik @ melkor.dnp.fmph.uniba.sk     |
 -----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!



More information about the Python-list mailing list