From d_mosthenes at hotmail.com Thu Mar 4 16:30:36 2010 From: d_mosthenes at hotmail.com (D Mosthenes) Date: Thu, 4 Mar 2010 15:30:36 +0000 Subject: [Tkinter-discuss] askdirectory from tkFileDialog Message-ID: Is it possible to ask for a folder (not a file) with the same interface as asking for a file. That is, not with the tree branching. I believe the two interfaces are similar on Mac, so is it possible to emulate this on Windows? _________________________________________________________________ Hotmail: Free, trusted and rich email service. http://clk.atdmt.com/GBL/go/201469228/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Thu Mar 4 16:42:13 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Thu, 04 Mar 2010 10:42:13 -0500 Subject: [Tkinter-discuss] askdirectory from tkFileDialog In-Reply-To: References: Message-ID: <4B8FD4D5.3070504@codebykevin.com> On 3/4/10 10:30 AM, D Mosthenes wrote: > Is it possible to ask for a folder (not a file) with the same interface > as asking for a file. That is, not with the tree branching. I believe > the two interfaces are similar on Mac, so is it possible to emulate this > on Windows? > ------------------------------------------------------------------------ > Hotmail: Free, trusted and rich email service. Get it now. > Tk uses native dialogs on Windows and Mac, so if you don't like the native implementation, you have to roll your own, or use the Unix version. Not sure how to access the Unix version from Tkinter. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From Vasilis.Vlachoudis at cern.ch Fri Mar 5 09:14:27 2010 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Fri, 5 Mar 2010 09:14:27 +0100 Subject: [Tkinter-discuss] Tkinter with extension in C Message-ID: <4B90BD63.7040205@cern.ch> Hi all, I have an application that it requires to plot the result from some heavy calculation. Python is slow, so I am writing the calculation part as a C++ extension for python. Is it possible to draw directly to a Canvas opened from Tkinter from the C++ extension, in order to avoid useless transfer of data from C++ to python to tkinter? vasilis From igor.e.novikov at gmail.com Fri Mar 5 17:22:56 2010 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Fri, 5 Mar 2010 18:22:56 +0200 Subject: [Tkinter-discuss] Tkinter with extension in C In-Reply-To: <4B90BD63.7040205@cern.ch> References: <4B90BD63.7040205@cern.ch> Message-ID: <23f7fc191003050822y2c4e21edq93aff7aa1812162d@mail.gmail.com> Hi Vasilis! You can try using tkpath extension as an example of such drawing. But there is a simpler way. You can use regular Frame configured with empty background value: frame['background']='' Such frame option stops Tk frame refresh so your drawing will not be cleared after different window events. To start drawing you just need to get window ID or XID+Display (for XWin system) from Tcl interpreter. Also you can using multiplatform built-in Tk C-functions for drawing to simplifity your code base. But unfortunately this functionality doesn't provide antialiased graphics. Regards, Igor Novikov sK1 Project http://sk1project.org On Fri, Mar 5, 2010 at 10:14 AM, Vasilis Vlachoudis < Vasilis.Vlachoudis at cern.ch> wrote: > Hi all, > > I have an application that it requires to plot the result from some heavy > calculation. Python is slow, so I am writing the calculation part as a C++ > extension for python. Is it possible to draw directly to a Canvas opened > from Tkinter from the C++ extension, in order to avoid useless transfer of > data from C++ to python to tkinter? > > vasilis > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Thomash04 at hotmail.co.uk Tue Mar 16 11:14:23 2010 From: Thomash04 at hotmail.co.uk (thomas1984) Date: Tue, 16 Mar 2010 03:14:23 -0700 (PDT) Subject: [Tkinter-discuss] Desperate GUI Help Please!! Message-ID: <27915635.post@talk.nabble.com> 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-tp27915635p27915635.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From michael.odonnell at uam.es Tue Mar 16 18:13:55 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 16 Mar 2010 18:13:55 +0100 Subject: [Tkinter-discuss] Desperate GUI Help Please!! In-Reply-To: <27915635.post@talk.nabble.com> References: <27915635.post@talk.nabble.com> Message-ID: <47e491111003161013h3ae43796s296030df953d9268@mail.gmail.com> Hi Thomas, An image will be garbage collected if thee is no pointer to the variable holding the image. You thus need to change the following lines of code: self.gif1 = PhotoImage(file = 'mm.gif') canvas.create_image(50, 10, image = self.gif1, anchor = NW) (by making the gif1 variable a permanent aspect of the AppUI object, it won't be garbage collected) Mick On Tue, Mar 16, 2010 at 11:14 AM, thomas1984 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-tp27915635p27915635.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From michael.odonnell at uam.es Tue Mar 16 18:22:00 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 16 Mar 2010 18:22:00 +0100 Subject: [Tkinter-discuss] Restoring scroll position in a scrolled text window Message-ID: <47e491111003161022v3d5d7b51w426f6b1f3be70a28@mail.gmail.com> Hi all, Under Windows with python 2.6.4 Tkinter 8.5 I am trying to find a way to restore exactly the same scroll position in a scrolled text widget, after deleting all text and re-inserting the same text. Given a text widget in self.text, I can do the following: # record the index of the top visible line in the text widget topidx=self.text.index("@0,0") # redraw the text self.renew() # Restore the scroll self.text.see(topidx) However, "see" does not put this line index at the top of the text widget, but rather some number of lines below (unless it was already visible, in which case it stays where it was) Is there an easy way to put a definite line at the top of a scrolled text widget? I would use self.text.yview(MOVETO, fraction) ...but I cannot find out at what fraction of the window this line is! (my lines are of variable height, so I cannot simply multiply line height). Any other ideas? Mick From msa01 at bitflipper.ca Tue Mar 16 15:26:12 2010 From: msa01 at bitflipper.ca (Cam Farnell) Date: Tue, 16 Mar 2010 11:26:12 -0300 Subject: [Tkinter-discuss] Desperate GUI Help Please!! In-Reply-To: <27915635.post@talk.nabble.com> References: <27915635.post@talk.nabble.com> Message-ID: <4B9F9504.6010700@bitflipper.ca> Thomas, A post which in essence says "please write my application for me" is pretty much a guaranteed way to annoy people - who are generally busy writing their own applications - or to simply be ignored. A better approach would be to figure out what part of Tkinter isn't working as you expect, construct the *smallest* possible code that demonstrates the problem (hint: this will NOT be an entire section of your application) and submit that to this list. Cheers Cam thomas1984 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. From klappnase at web.de Tue Mar 16 21:03:07 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 16 Mar 2010 21:03:07 +0100 Subject: [Tkinter-discuss] Restoring scroll position in a scrolled text window In-Reply-To: <47e491111003161022v3d5d7b51w426f6b1f3be70a28@mail.gmail.com> References: <47e491111003161022v3d5d7b51w426f6b1f3be70a28@mail.gmail.com> Message-ID: <20100316210307.96dd0615.klappnase@web.de> Hi Mick, On Tue, 16 Mar 2010 18:22:00 +0100 "Michael O'Donnell" wrote: > Hi all, > > Under Windows with python 2.6.4 Tkinter 8.5 > > I am trying to find a way to restore exactly the same scroll > position in a scrolled text widget, after deleting all text and > re-inserting the same text. > I think it should work like this: >>> from ScrolledText import ScrolledText >>> s=ScrolledText() >>> s.pack(fill='both', expand=1) >>> s.insert('end', some_text) >>> first, last = s.yview() >>> s.delete(1.0, 'end') >>> s.insert('end', some_text) >>> s.yview_moveto(first) I hope this helps Michael From joebarfett at yahoo.ca Sun Mar 28 18:55:29 2010 From: joebarfett at yahoo.ca (Joe Barfett) Date: Sun, 28 Mar 2010 09:55:29 -0700 (PDT) Subject: [Tkinter-discuss] macPython, menubar won't display, new windows will not display widgets Message-ID: <470422.35265.qm@web59402.mail.ac4.yahoo.com> Hello, I've had problems getting menus to appear in my Tkinter applications using python 2.5.2 and Mac OSX tiger and leopard. I've extensively searched for help and found only this link: http://www.learningpython.com/2006/03/27/using-menus-in-tkinter/ someone else has had the same problem but no solution is posted. Additionally, I find that if I make a new window with toplevel, widgets on the window will not display immediately, but will after the window is refreshed. With Tile so easily available, I really don't want to invest in learning another GUI toolkit for python. Tkinter solves all my needs (I'm a scientific programmer) and really I just want to make a more friendly and user oriented scientific application. Thanks if you can help! I can post source code if needed, but I'm hoping someone has just heard of the problem before and can point me in the right direction. Cheers from Canada! joe ? __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Sun Mar 28 19:28:21 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Sun, 28 Mar 2010 13:28:21 -0400 Subject: [Tkinter-discuss] macPython, menubar won't display, new windows will not display widgets In-Reply-To: <470422.35265.qm@web59402.mail.ac4.yahoo.com> References: <470422.35265.qm@web59402.mail.ac4.yahoo.com> Message-ID: <4BAF91B5.5000301@codebykevin.com> On 3/28/10 12:55 PM, Joe Barfett wrote: > Thanks if you can help! I can post source code if needed, but I'm hoping > someone has just heard of the problem before and can point me in the > right direction. Cheers from Canada! > There are no systematic issues with Tkinter on OS X that I'm aware of: if a menu isn't displaying there's probably an issue with your code. Please post a code sample to help us reproduce the problem. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com