Re: Desperate GUI Help Please!!

Fredrik Lundh <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
The Tkinter toolkit comes with a canvas widget that's probably a
better choice for the drawing parts of your application.  Tkinter
itself is a bit outside the scope for this mailing list; you'll
probably have more luck on the tkinter-discuss list:

    http://mail.python.org/mailman/listinfo/tkinter-discuss

or in the main Python forum.

</F>

On Tue, Mar 16, 2010 at 11:15 AM, thomas1984 <[email protected]> wrote:
>
> Hello,
>
> I need to make a GUI which has a fixed window size approx 390 (width) X 6020
> (height)
>
> It needs to have a fileMenu containing "File" "About" "Exit". In the "file"
> menu it needs a menuItem called "new route".
>
> When you click on "new route" it needs to display a new window with a
> listBox.. When a user selects an item from the list box and clicks OK - it
> should pass this value to the original window.
>
> The difficulty here is that the main body of the GUI window, needs to
> display an image BUT it needs to be an image that is able to be drawed on.
>
> Below is my code for drawing on the image....... It is an EXAMPLE - but i
> need it like this i.e. by importing the ImageDraw library.
>
> # Do the proper imports for this script
> from Tkinter import *
> import os, sys
> import Image
> import ImageDraw
> # Load the image
> try:
> im = Image.open("C:\Documents and Settings\Administrator\Desktop\mm.gif")
> except:
> print "Unable to load image"
> exit(1)
> # Get a drawing surface for the image
> draw = ImageDraw.Draw(im)
> # Draw the circle
> #draw.ellipse((0,0)+im.size)
> # Draw the line
> #draw.line((0,0)+im.size)
> # and show off the result
> draw.line((0, 0) + (0,55), fill=000, width=22)
> draw.text((50, 50), "hey")
> im.show()
>
> Below is my code for the list box example......
>
> from Tkinter import *
> class ListBoxTest :
> def __init__(self) :
> self.root = Tk()
> self.list_box_1 = Listbox(self.root)
> self.list_box_1.pack()
> self.delete_button = Button(self.root, text="Delete",
> command=self.DeleteSelection)
> self.delete_button.pack()
> def DeleteSelection(self) :
> items = self.list_box_1.curselection()
> pos = 0
> for i in items :
> idx = int(i) - pos
> self.list_box_1.delete( idx,idx )
> pos = pos + 1
> def Show(self) :
> for i in range(0, 10) :
> s = "Item " + str(i)
> self.list_box_1.insert( END,s )
> self.root.mainloop()
> lbt=ListBoxTest()
> lbt.Show()
>
>
> Below is my code for the Canvas and Window BUT the canvas does not hold an
> image I have drew on........
>
> from Tkinter import *
>
> class AppUI(Frame):
>
> def __init__(self, master=None):
> Frame.__init__(self, master, relief=SUNKEN, bd=2)
>
> self.menubar = Menu(self)
>
> menu = Menu(self.menubar, tearoff=0)
> self.menubar.add_cascade(label="File", menu=menu)
> menu.add_command(label="New")
>
> menu = Menu(self.menubar, tearoff=0)
> self.menubar.add_cascade(label="Edit", menu=menu)
> menu.add_command(label="Cut")
> menu.add_command(label="Copy")
> menu.add_command(label="Paste")
>
> try:
> self.master.config(menu=self.menubar)
> except AttributeError:
> # master is a toplevel window (Python 1.4/Tkinter 1.63)
> self.master.tk.call(master, "config", "-menu", self.menubar)
>
> canvas = Canvas(width = 300, height = 200, bg = 'white')
> canvas.pack(expand = YES, fill = BOTH)
>
> gif1 = PhotoImage(file = 'mm.gif')
> canvas.create_image(50, 10, image = gif1, anchor = NW)
> canvas.pack()
>
> root = Tk()
>
> app = AppUI(root)
> app.pack()
>
> root.mainloop()
>
>
> ---- Is there anyone here who can put these elements together and maybe make
> this GUI for me? I'm really stuck and as you can see by the code examples I
> have gave this a shot, but I don't know how to finish it off - If someone
> can do this for me - it would be great as I can look at the code and learn.
> --
> View this message in context: http://old.nabble.com/Desperate-GUI-Help-Please%21%21-tp27915646p27915646.html
> Sent from the Python - image-sig mailing list archive at Nabble.com.
>
> _______________________________________________
> Image-SIG maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.