From jacob at blindza.co.za Thu Jan 1 04:10:39 2015 From: jacob at blindza.co.za (Jacob Kruger) Date: Thu, 1 Jan 2015 11:10:39 +0200 Subject: Why For Loop Skips the Last element? In-Reply-To: References: Message-ID: <8ED4CB03BF5A47809A69E43E8C4E5345@JakesPC> Not sure after quick skim/scan, but, I would generally use either for I in range(len(inlist)): or just for it in inlist, instead of using while, etc. Stay well Jacob Kruger Blind Biker Skype: BlindZA "Roger Wilco wants to welcome you...to the space janitor's closet..." ----- Original Message ----- From: Thuruv V To: python-list at python.org Sent: Wednesday, December 31, 2014 11:25 PM Subject: Why For Loop Skips the Last element? Hi all, Here's the list. . inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)", 'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial (62625241)', 'Fortune NYC Ladies Quilted Dial Watch: Brown', 'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band (62623659)', 'Swiss Legend Commander Chronograph: Watch Orange/Black (SL-10067-01-ORS)', 'Debussy Ladies Watch: Brown/Gray/Silver 14070 - 62625292', '#2 Swiss Legend Commander Chronograph: Green (SL-10067-BB-017)', 'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)' ] My code : i = 0 while i <= len(inlist): if 'watch' in str(inlist[i]).lower() or 'watches' in str(inlist[i]).lower(): if 'women' in str(inlist[i]).lower() or 'female' in str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower(): print 'FEMale Watch', inlist.index(i),str(i) elif 'men' in str(inlist[i]).lower() or 'male' in str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower(): print 'Male Watch',inlist.index(i),str(i) i = next(inlist) When on executing python skips the last element('Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)') in the list. But when accessing through 'print inlist[0]' is possible,i.e it shows the e;lement. but the list skips it. . Please enlighten me. . Thanks. ------------------------------------------------------------------------------ -- https://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Thu Jan 1 04:28:06 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 01 Jan 2015 09:28:06 +0000 Subject: Why For Loop Skips the Last element? In-Reply-To: References: Message-ID: On 31/12/2014 21:25, Thuruv V wrote: > Hi all, > > Here's the list. . > > inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)", > 'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial (62625241)', > 'Fortune NYC Ladies Quilted Dial Watch: Brown', > 'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band > (62623659)', > 'Swiss Legend Commander Chronograph: Watch Orange/Black (SL-10067-01-ORS)', > 'Debussy Ladies Watch: Brown/Gray/Silver 14070 - 62625292', > '#2 Swiss Legend Commander Chronograph: Green (SL-10067-BB-017)', > 'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)' > ] > > My code : > i = 0 > while i <= len(inlist): > if 'watch' in str(inlist[i]).lower() or 'watches' in > str(inlist[i]).lower(): > if 'women' in str(inlist[i]).lower() or 'female' in > str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower(): > print 'FEMale Watch', inlist.index(i),str(i) > elif 'men' in str(inlist[i]).lower() or 'male' in > str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower(): > print 'Male Watch',inlist.index(i),str(i) > i = next(inlist) > > When on executing python skips the last element('Auguste Jaccard 3 > Timezone Watch: Black Band/ Gray & Black Dial (62625184)') in the list. > > But when accessing through 'print inlist[0]' is possible,i.e it shows > the e;lement. but the list skips it. . > Please enlighten me. . > Thanks. > > Why don't you show us your actual code? There is no for loop above and running the actual code gives "ValueError: 0 is not in list" on the first pass through the while loop. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From jpiitula at ling.helsinki.fi Thu Jan 1 04:31:08 2015 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: 01 Jan 2015 11:31:08 +0200 Subject: Why For Loop Skips the Last element? References: Message-ID: Thuruv V writes: > Here's the list. . > > inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)", > 'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial (62625241)', > 'Fortune NYC Ladies Quilted Dial Watch: Brown', > 'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band > (62623659)', > 'Swiss Legend Commander Chronograph: Watch Orange/Black (SL-10067-01-ORS)', > 'Debussy Ladies Watch: Brown/Gray/Silver 14070 - 62625292', > '#2 Swiss Legend Commander Chronograph: Green (SL-10067-BB-017)', > 'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial (62625184)' > ] > > My code : > i = 0 > while i <= len(inlist): > if 'watch' in str(inlist[i]).lower() or 'watches' in > str(inlist[i]).lower(): > if 'women' in str(inlist[i]).lower() or 'female' in > str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower(): > print 'FEMale Watch', inlist.index(i),str(i) > elif 'men' in str(inlist[i]).lower() or 'male' in > str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower(): > print 'Male Watch',inlist.index(i),str(i) > i = next(inlist) > > When on executing python skips the last element('Auguste Jaccard 3 > Timezone Watch: Black Band/ Gray & Black Dial (62625184)') in the > list. Looks like it should raise an exception at the first element, as soon as it tries to print inlist.index(0). And looks like you are confusing the element and the index of the element all the way through. Also, re subject line, that's not a for loop. That's a while loop. But since you mean it to go through all elements of the list, a for loop is indeed preferable: for line in inlist: print(line) To walk each line and its index together, use enumerate: for i, line in enumerate(inlist): print(i, line) (The "i = next(inlist)" in your while loop wants to be "i += 1", and it really doesn't want to be inside the if-statement. But since your while loop wants to be a for loop, the whole update of the index should go away.) > But when accessing through 'print inlist[0]' is possible,i.e it > shows the e;lement. but the list skips it. . > Please enlighten me. . > Thanks. I suspect you didn't post quite the version of the code you ran, but maybe the above suggestions help you get on track again. Best wishes. From steve+comp.lang.python at pearwood.info Thu Jan 1 05:15:20 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 01 Jan 2015 21:15:20 +1100 Subject: Why For Loop Skips the Last element? References: Message-ID: <54a51e39$0$12998$c3e8da3$5496439d@news.astraweb.com> Thuruv V wrote: > Hi all, > > Here's the list. . The exact details of the list are not important. Please simplify your code to something easier to handle than this: > inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)", > 'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial (62625241)', > 'Fortune NYC Ladies Quilted Dial Watch: Brown', > 'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band > (62623659)', > 'Swiss Legend Commander Chronograph: Watch Orange/Black > (SL-10067-01-ORS)', 'Debussy Ladies Watch: Brown/Gray/Silver 14070 - > 62625292', '#2 Swiss Legend Commander Chronograph: Green > (SL-10067-BB-017)', 'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & > Black Dial (62625184)' ] For your testing, try this first: inlist = ['Female 1', 'male 1', 'Male 2', 'ladies 2'] When you have your code working with the simple test data, then you can go on with the more complicated real data. > My code : Why are you using a while loop? I don't understand where this comes from. So many beginners keep doing things the hard way, using a while loop. Iterate over the list like this: for item in inlist: item = item.lower() if "female" in item or "ladies" in item: print("Female") elif "man" in item or "male" in item: print("Male") > i = 0 > while i <= len(inlist): > if 'watch' in str(inlist[i]).lower() or 'watches' in > str(inlist[i]).lower(): > if 'women' in str(inlist[i]).lower() or 'female' in > str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower(): > print 'FEMale Watch', inlist.index(i),str(i) > elif 'men' in str(inlist[i]).lower() or 'male' in > str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower(): > print 'Male Watch',inlist.index(i),str(i) > i = next(inlist) > > When on executing python skips the last element('Auguste Jaccard 3 > Timezone Watch: Black Band/ Gray & Black Dial (62625184)') in the list. Your code skips that last item because the second-last item doesn't have the word "watch" in it, so the loop never advances and it just loops forever. But really, the code you show us is not the code you are actually using. Why do you show us something different from what you actually use? I know that the code you show cannot possibly be the code you are using, because the code you show fails. If you ran this code, it would raise TypeError. -- Steven From breamoreboy at yahoo.co.uk Thu Jan 1 05:34:10 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 01 Jan 2015 10:34:10 +0000 Subject: Why For Loop Skips the Last element? In-Reply-To: <54a51e39$0$12998$c3e8da3$5496439d@news.astraweb.com> References: <54a51e39$0$12998$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 01/01/2015 10:15, Steven D'Aprano wrote: > > I know that the code you show cannot possibly be the code you are using, > because the code you show fails. If you ran this code, it would raise > TypeError. > Traceback (most recent call last): File "C:\Users\Mark\Documents\MyPython\mytest.py", line 16, in print('FEMale Watch', inlist.index(i),str(i)) ValueError: 0 is not in list Sinner, but as it's New Year's Day I'll let you off :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From wxjmfauth at gmail.com Thu Jan 1 05:39:42 2015 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Thu, 1 Jan 2015 02:39:42 -0800 (PST) Subject: [ANN] EasyGUI_Qt version 0.9 In-Reply-To: <4c3dbebe-0184-4ca7-9d7d-30462ae2a578@googlegroups.com> References: <4c3dbebe-0184-4ca7-9d7d-30462ae2a578@googlegroups.com> Message-ID: <1c8ee08b-f60c-4482-9176-3537f3b7956a@googlegroups.com> Le mercredi 31 d?cembre 2014 23:24:50 UTC+1, Andr? Roberge a ?crit?: > EasyGUI_Qt version 0.9 has been released. This is the first announcement about EasyGUI_Qt on this list. > > Like the original EasyGUI (which used Tkinter), > EasyGUI_Qt seeks to provide simple GUI widgets > that can be called in a procedural program. > > EasyGUI_Qt is NOT event-driven: all GUI interactions are invoked by simple function calls. > > The archetype is get_string(message) > which pops a box whose purpose is exactly the same as Python's input(prompt), > that is, present the user with a question/prompt, have the user enter an > answer, and return the provided answer as a string. Thus > easygui_qt.get_string() can be used as a drop-in replacement for > input(). > > Similarly, instead of using a print() function to display a message, > show_message() is used which pops a message window. > > EasyGUI_Qt requires PyQt4 and is really targeted for Python 3.3+ - although it can work (possibly with some unicode problems ...) using Python 2.7. > > More information can be found at > http://easygui-qt.readthedocs.org/en/latest/index.html > > Feedback is most welcome, including reporting bugs to > https://github.com/aroberge/easygui_qt/issues > > Happy 2015 everyone, > > Andr? Roberge If it works like eric6, I quickly tested yesterday morning, it will not work. jmf From breamoreboy at yahoo.co.uk Thu Jan 1 06:01:25 2015 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 01 Jan 2015 11:01:25 +0000 Subject: Why For Loop Skips the Last element? In-Reply-To: <8ED4CB03BF5A47809A69E43E8C4E5345@JakesPC> References: <8ED4CB03BF5A47809A69E43E8C4E5345@JakesPC> Message-ID: On 01/01/2015 09:10, Jacob Kruger wrote: > Not sure after quick skim/scan, but, I would generally use either for I > in range(len(inlist)): or just for it in inlist, instead of using while, > etc. > Stay well > As a rule of thumb if you're writing range(len(inlist)) you're doing it wrong. For an example of how to do things correctly see the pairwise recipe here https://docs.python.org/3/library/itertools.html#itertools-recipes. This is available in more-itertools here https://pythonhosted.org/more-itertools/api.html As an aside would you please not top post on this list, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence From steve+comp.lang.python at pearwood.info Thu Jan 1 07:38:17 2015 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: Thu, 01 Jan 2015 23:38:17 +1100 Subject: Why For Loop Skips the Last element? References: <54a51e39$0$12998$c3e8da3$5496439d@news.astraweb.com> Message-ID: <54a53fba$0$13014$c3e8da3$5496439d@news.astraweb.com> Mark Lawrence wrote: > On 01/01/2015 10:15, Steven D'Aprano wrote: >> >> I know that the code you show cannot possibly be the code you are using, >> because the code you show fails. If you ran this code, it would raise >> TypeError. >> > > Traceback (most recent call last): > File "C:\Users\Mark\Documents\MyPython\mytest.py", line 16, in > print('FEMale Watch', inlist.index(i),str(i)) > ValueError: 0 is not in list > > Sinner, but as it's New Year's Day I'll let you off :) I was thinking of the next(inlist). -- Steven From denismfmcmahon at gmail.com Thu Jan 1 09:24:37 2015 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Thu, 1 Jan 2015 14:24:37 +0000 (UTC) Subject: Why For Loop Skips the Last element? References: Message-ID: On Thu, 01 Jan 2015 02:55:49 +0530, Thuruv V wrote: > Hi all, > > Here's the list. . > > inlist = ["Fossil Women's Natalie Stainless Steel Watch Brown (JR1385)", > 'Balmer Swiss Made Veyron Mens Watch: Black Band/ Black Dial > (62625241)', > 'Fortune NYC Ladies Quilted Dial Watch: Brown', > 'Jeanne Collection w/ Swarovski Elements Watch: Dark Purple Band > (62623659)', > 'Swiss Legend Commander Chronograph: Watch Orange/Black > (SL-10067-01-ORS)', > 'Debussy Ladies Watch: Brown/Gray/Silver 14070 - 62625292', > '#2 Swiss Legend Commander Chronograph: Green (SL-10067-BB-017)', > 'Auguste Jaccard 3 Timezone Watch: Black Band/ Gray & Black Dial > (62625184)' > ] > > My code : > i = 0 while i <= len(inlist): > if 'watch' in str(inlist[i]).lower() or 'watches' in > str(inlist[i]).lower(): > if 'women' in str(inlist[i]).lower() or 'female' in > str(inlist[i]).lower() or 'ladies' in str(inlist[i]).lower(): > print 'FEMale Watch', inlist.index(i),str(i) > elif 'men' in str(inlist[i]).lower() or 'male' in > str(inlist[i]).lower() or 'chronograph' in str(inlist[i]).lower(): > print 'Male Watch',inlist.index(i),str(i) > i = next(inlist) ..........^ If the indents are correct, i will only increment if watch or watches are found. Your last but 1 item doesn't match these strings (chronograph instead of watch). It would still be better as others have posted to use a for loop. -- Denis McMahon, denismfmcmahon at gmail.com From jsf80238 at gmail.com Thu Jan 1 12:09:13 2015 From: jsf80238 at gmail.com (Jason Friedman) Date: Thu, 1 Jan 2015 10:09:13 -0700 Subject: Logger not logging Message-ID: What am I missing? I expect logger.info("hello") to emit. $ python Python 3.4.0 (default, Apr 18 2014, 19:16:28) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import logging >>> logger = logging.getLogger() >>> logger.setLevel(logging.INFO) >>> logger.info("hello") >>> logger.warn("hello") hello >>> From dan at tombstonezero.net Thu Jan 1 12:25:22 2015 From: dan at tombstonezero.net (Dan Sommers) Date: Thu, 1 Jan 2015 17:25:22 +0000 (UTC) Subject: Logger not logging References: Message-ID: On Thu, 01 Jan 2015 10:09:13 -0700, Jason Friedman wrote: > What am I missing? > > I expect logger.info("hello") to emit. > > $ python > Python 3.4.0 (default, Apr 18 2014, 19:16:28) > [GCC 4.8.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import logging >>>> logger = logging.getLogger() >>>> logger.setLevel(logging.INFO) >>>> logger.info("hello") >>>> logger.warn("hello") > hello >>>> By default, loggers only log warnings and errors. Add this: logger.setLevel(logging.INFO) HTH, Dan From joel.goldstick at gmail.com Thu Jan 1 12:49:15 2015 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Thu, 1 Jan 2015 12:49:15 -0500 Subject: Logger not logging In-Reply-To: References: Message-ID: On Thu, Jan 1, 2015 at 12:25 PM, Dan Sommers wrote: > On Thu, 01 Jan 2015 10:09:13 -0700, Jason Friedman wrote: > > > What am I missing? > > > > I expect logger.info("hello") to emit. > > > > $ python > > Python 3.4.0 (default, Apr 18 2014, 19:16:28) > > [GCC 4.8.1] on linux > > Type "help", "copyright", "credits" or "license" for more information. > >>>> import logging > >>>> logger = logging.getLogger() > >>>> logger.setLevel(logging.INFO) > >>>> logger.info("hello") > >>>> logger.warn("hello") > > hello > >>>> > > By default, loggers only log warnings and errors. Add this: > > logger.setLevel(logging.INFO) > > HTH, > Dan > Looks like op did that? > -- > https://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Jan 1 12:59:42 2015 From: __peter__ at web.de (Peter Otten) Date: Thu, 01 Jan 2015 18:59:42 +0100 Subject: Logger not logging References: Message-ID: Jason Friedman wrote: > I expect logger.info("hello") to emit. > > $ python > Python 3.4.0 (default, Apr 18 2014, 19:16:28) > [GCC 4.8.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import logging >>>> logger = logging.getLogger() >>>> logger.setLevel(logging.INFO) >>>> logger.info("hello") >>>> logger.warn("hello") > hello >>>> > What am I missing? The handler also filters. The easiest way to get one that is configured appropriately is to use basicConfig(): >>> import logging >>> logging.basicConfig(level=logging.INFO) >>> root = logging.getLogger() >>> root.info("hello") INFO:root:hello From jsf80238 at gmail.com Thu Jan 1 13:22:41 2015 From: jsf80238 at gmail.com (Jason Friedman) Date: Thu, 1 Jan 2015 11:22:41 -0700 Subject: Logger not logging In-Reply-To: References: Message-ID: >> Python 3.4.0 (default, Apr 18 2014, 19:16:28) >> [GCC 4.8.1] on linux >> Type "help", "copyright", "credits" or "license" for more information. >>>>> import logging >>>>> logger = logging.getLogger() >>>>> logger.setLevel(logging.INFO) >>>>> logger.info("hello") >>>>> logger.warn("hello") >> hello >>>>> > >> What am I missing? > > The handler also filters. The easiest way to get one that is configured > appropriately is to use basicConfig(): > >>>> import logging >>>> logging.basicConfig(level=logging.INFO) >>>> root = logging.getLogger() >>>> root.info("hello") > INFO:root:hello Thank you From lucasvfxdood at gmail.com Thu Jan 1 13:43:57 2015 From: lucasvfxdood at gmail.com (lucasvfxdood at gmail.com) Date: Thu, 1 Jan 2015 10:43:57 -0800 (PST) Subject: Moving 1 Picture in a Programm - How to? Message-ID: Hey Guys! I need your help! So i want to make a programm like the app called "Feed Me" There are 2 Pictures (I got that) than you can click the food picture and drag it on the boys mouth and than the sad boys face disappears and a happy face shows up. Heres the code ive wrtiten from tkinter import * f = Tk() f.title('Give the boy the apple.') f.geometry('500x500') c = Canvas(master=f,width=500,height=500,bg='white') c.place(x=0,y=0) p = PhotoImage(file='traurigsmiley.png') #sad smiley i = c.create_image(250,320,image=p) #position p2 = PhotoImage(file='essen.png') #food i2 = c.create_image(70,100,image=p2) f.geometry('500x500') f.mainloop() Please Help! From auriocus at gmx.de Thu Jan 1 14:36:46 2015 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 01 Jan 2015 20:36:46 +0100 Subject: Moving 1 Picture in a Programm - How to? In-Reply-To: References: Message-ID: Am 01.01.15 um 19:43 schrieb lucasvfxdood at gmail.com: > Hey Guys! I need your help! So i want to make a programm like the app > called "Feed Me" There are 2 Pictures (I got that) than you can click > the food picture and drag it on the boys mouth and than the sad boys > face disappears and a happy face shows up. Have a look at the canvasplot.py demo of the Tk canvas. It shows how to do basic drag'n'drop with items on a canvas. Can be downloaded from here: http://tkinter.unpythonic.net/wiki/A_tour_of_Tkinter_widgets Christian From rantingrickjohnson at gmail.com Thu Jan 1 14:50:21 2015 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 1 Jan 2015 11:50:21 -0800 (PST) Subject: Moving 1 Picture in a Programm - How to? In-Reply-To: References: Message-ID: On Thursday, January 1, 2015 12:44:13 PM UTC-6, lucas mvm wrote: > Hey Guys! I need your help! So i want to make a program > like the app called "Feed Me" There are 2 Pictures (I got > that) than you can click the food picture and drag it on > the boys mouth and than the sad boys face disappears and a > happy face shows up. This interactivity will require mastering a few basic events. The Tkinter canvas offers a few extra methods of binding events besides the normal "widget level" event bindings. Since you are beginning you should focus on the ubiquitous bindings at the "widget level" -- master those before moving on to "tag level bindings". First step: FORGET ABOUT PICTURES, because they will only get in your way at this time. First step is to create three events that map mouse clicks, mouse drags, and mouse releases to print messages to stdout. THEN, and only then you can move to the next step! DIVIDE AND CONQUER... in teeny tiny baby steps! But first allow me to critique your code. > Heres the code ive wrtiten > from tkinter import * Oh no... I would not suggest importing everything (even though the library can be) since doing so pollutes your namespace with many names you'll never use. Instead do: "import tkinter as tk" and prefix every class with "tk.". For the constants you do either "from tkinter.constants import *" or individually import only the names you will use (the second option is obviously better) But for now, let's just get this code working, shall we? > f = Tk() Why would you use "f" as a variable for a tkinter window? A better symbol would be "root" or "topwin". Make sure your symbols are describing succinctly what they reference (THIS IS VERY IMPORTANT!) Even though Tkinter allows you to use a "frame" as a "window" (frame.mainloop()), it only works because there is some "magic" going on behind the scenes. You must understand that "frames != windows". > f.title('Give the boy the apple.') > f.geometry('500x500') > c = Canvas(master=f,width=500,height=500,bg='white') > c.place(x=0,y=0) The "place" geometry manager should only be use in *extremely* specific circumstances. And since your code does not require such "needs" i suggest you replace "c.place" with "c.pack(fill=BOTH, expand=YES)". There are three geometry managers in Tkinter: 1. Pack 2. Grid 3. Place When your trying to decide which manager to use, start with the "pack manager" first, if it cannot solve your needs then contemplate the "grid manager", and only after deciding that the "pack manager" and "grid manager" won't work, then you can us the "place manager". > p = PhotoImage(file='traurigsmiley.png') #sad smiley > i = c.create_image(250,320,image=p) #position > p2 = PhotoImage(file='essen.png') #food > i2 = c.create_image(70,100,image=p2) > f.geometry('500x500') > f.mainloop() > > Please Help! First, rewrite your code in the manner i suggest, then expand it with the following. 1. Bind three events to your canvas object: c.bind("