473,224 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Tkinter program crashes

Hello,

Any idea - why the following code crashes on my Win 98 machine with
Python 2.3? Everytime I run this code, I have to reboot my machine.
I also have Win32all-157 installed.

from Tkinter import *

class App:

def __init__(self, master):

frame = Frame(master)
frame.pack()

self.button = Button(
frame, text="QUIT", fg="red", command=frame.quit
)
self.button.pack(side=LEFT)

self.hi_there = Button(frame, text="Hello",
command=self.say_hi)
self.hi_there.pack(side=LEFT)

def say_hi(self):
print "hi there, everyone!"

root = Tk()

app = App(root)

root.mainloop()
Regards,
Srijit
Jul 18 '05 #1
3 6964
In article <22**************************@posting.google.com >,
sr****@yahoo.com wrote:
Any idea - why the following code crashes on my Win 98 machine with
Python 2.3? Everytime I run this code, I have to reboot my machine.
I also have Win32all-157 installed.


I can see no errors in the code. Also, I tried it on unix and Mac and it
ran fine. I suspect there's a problem with your installation of Python,
Tkinter or Tcl/Tk.

I do have a few style complaints. It is silly to worry about style when
the program is crashing, but I've appended them (along with a modified
sample program) in case you may be interested at some point.

-- Russell

Suggested style changes:
- the frame isn't being used for anything so you might as well just pack
the widgets into the master. But it would be much better to have App
subclass Frame so App acts like any other Tkinter widget. You can then
mix App with other widgets to make larger widgets. (One minor drawback
is you have to grid or pack it once you create it -- just like any other
Tkinter widget).

- Use "import Tkinter" instead of "from Tkinter import *" for anything
except trivial code. It makes for more typing, but cuts down on
namespace pollution -- especially useful if you start subclassing
Tkinter classes.

- The say_hi method might as well be locally defined. I suggest you only
create class methods if they need data from the class or if users of the
class might find them handy.

Here's a version incorporating those changes. The if __name__ stuff at
the bottom allows you to import this module and use App as a widget.

import Tkinter

class App(Tkinter.Frame):
def __init__(self, master):
Tkinter.Frame.__init__(self, master)

self.button = Tkinter.Button(
self, text="QUIT", fg="red", command=self.quit)
self.button.pack(side=Tkinter.LEFT)

def say_hi():
print "hi there, everyone!"

self.hi_there = Tkinter.Button(
self, text="Hello", command=say_hi)
self.hi_there.pack(side=Tkinter.LEFT)

if __name__ == "__main__":
root = Tkinter.Tk()

app = App(root)
app.pack()

root.mainloop()
Jul 18 '05 #2
Hello Members,

Here are the details of Python Tkinter applications crash on my
machine (Win 98, Python 2.3 and Win32all-157).

This has happened whenever I try to run a Tkinter application. The
application runs fine. The problem happens whenever I exit from the
Tkinter application.
This was happening with Python 2.3b1. It continued to happen when I
uninstalled Python 2.3b1 and installed python 2.3.

The only exception is IDLE. IDLE is also a Tkinter application. Other
Python applications are yet to give problems. For example I was
successful in running PyGTK applications on my same setup.

For example when I ran the Tkinter code (refer below for the actual
code) and exited from the application I got the following message.

PYTHON caused an invalid page fault in
module KERNEL32.DLL at 0167:bff7b9a6.
Registers:
EAX=00000000 CS=0167 EIP=bff7b9a6 EFLGS=00000246
EBX=011033a0 SS=016f ESP=0062f878 EBP=0062f888
ECX=01103370 DS=016f ESI=01105a98 FS=3c4f
EDX=7efeff73 ES=016f EDI=01103370 GS=0000
Bytes at CS:EIP:
ff 76 04 e8 13 89 ff ff 5e c2 04 00 56 8b 74 24
Stack dump:
0110484c 010f274f 01105a98 0000002e 0062f8d4 010f0c79 00000009
01103370 0062f98d 010f0c48 0000002e 010ef913 0000002e 00000001
010d9f40 0000002e

I am unable to figure out the problem. I guess re-installing Python
2.3 will not help.
I hope somebody will help me to run Tkinter applications comfortably
on my machine. Otherwise I have to live without Tkinter applications
(except IDLE) on my machine.
I also know it does not happen on Win 2000 or Win XP. Now I cannot
afford Win 2000 or XP.

Regards,
Srijit

The Tkinter code which crashed my Win 98 machine is :

import Tkinter

class App(Tkinter.Frame):
def __init__(self, master):
Tkinter.Frame.__init__(self, master)

self.button = Tkinter.Button(
self, text="QUIT", fg="red", command=self.quit)
self.button.pack(side=Tkinter.LEFT)

def say_hi():
print "hi there, everyone!"

self.hi_there = Tkinter.Button(
self, text="Hello", command=say_hi)
self.hi_there.pack(side=Tkinter.LEFT)

if __name__ == "__main__":
root = Tkinter.Tk()

app = App(root)
app.pack()

root.mainloop()
Jul 18 '05 #3
On Thu, 2003-08-14 at 10:55, sr****@yahoo.com wrote:
Hello,

Any idea - why the following code crashes on my Win 98 machine with
Python 2.3? self.button = Button(
frame, text="QUIT", fg="red", command=frame.quit

Rather than "frame.quit", could you try "sys.quit", to see if it makes a
difference?

--

Chad Netzer
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gary Richardson | last post by:
I've just switched to Python 2.3.2 and have encountered a problem that causes a program to crash. The program was working with Python 2.2. The code below will illustrate the problem. A listbox is...
3
by: Bob Greschke | last post by:
I have a program where the user pushes a button, a "starting" message is ..inserted to a text field with an associated scroll bar, a thread is started that inserts a "working..." message on to the...
3
by: Mickel Grönroos | last post by:
Hi everybody, I'm using QuickTimeTcl (3.1) to be able to play movie files in my Tkinter application (Python 2.3.2) on Windows 2000. I was planning to write a simple wrapper class,...
2
by: Michael Zhang | last post by:
My project uses Python-2.3.4 + Tkinter + PIL-1.1.4 to retrieve images from server and display those images. I created a thread (also a separate toplevel window) for displaying images and another...
0
by: Brian Kazian | last post by:
I am currently having trouble running a piece of code I have written. My main code is called new.py, and when I run it, it pops up the TKinter root window as specified. However, if I try perform...
3
by: aldonnelley | last post by:
Hi all. Just having a weird problem with tkinter. I'm trying to make a gui that shows results from an image search, with a "forward" and "back" button so the user can compare results from...
5
by: Kevin Walzer | last post by:
I'm having difficulty structuring a Tkinter menu entry. Here is the command in question: self.finkmenu.add_command(label='Update List of Packages',...
0
by: wolfonenet | last post by:
Hi All, My setup is: WinXP Python 2.5.1 TKinter version: $Revision: 50704 $ Tcl: 8.4 Debugger: WinPdb
2
by: Russell Blau | last post by:
I have some Tkinter programs that I run on two different machines. On Machine W, which runs Python 2.5.1 on Windows XP, these programs run fine. On Machine H, which runs Python 2.5.1 on Windows...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.