Tkinter App Wanted
Kevin Cazabon
kevin_cazabon at hotmail.nospamplease!.com
Sat Apr 14 01:47:16 EDT 2001
Just a few comments based on YOUR script:
####
from Tkinter import *
class App:
def __init__(master):
self.frame=Frame(master)
self.frame.pack()
self.button=Button(self.frame,text="QUIT",fg="red",command=self.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!"
def quit(self):
import sys
sys.exit()
if __name__ == "__main__":
root=Tk()
app = App(root)
root.mainloop()
#################
That should work... just some minor tweaking.
"Brian & Colleen" <greybria at direct.ca> wrote in message
news:3AD7647B.6A4B555B at direct.ca...
| Is anyone willing to share the source for a small Tkinter app (maybe an
| editor or file viewer) that includes a menu. I'm having problems getting
| a menu to work inside an encapsulated application.#! /usr/bin/env python
|
| from Tkinter import *
|
| class App:
| 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()
|
| Somewhere inside the App class, I'd like to include a basic menu
| (File-Save As, Exit) etc. so that when I create an instance of App, all
| the pieces are there.
|
| Thanks in advance.
|
| --
| Brian Smith
| greybria at direct.ca
| http://mypage.direct.ca/g/greybria
|
|
|
More information about the Python-list
mailing list