Try reading https://docs.python.org/3/library/tkinter.html#a-simple-hello-world-program and see what your script is missing to make it run as a complete program.
Cheers Lex On 20 May 2018 at 14:06, Eric Stephan <[email protected]> wrote: > > Hi -- thanks for that info! > > -- I'm embarrassed to say that since I don't usually put longish scripts into > the command line, I'm not sure how to get the many individual commands (with > its odd bind commands etc) into just the command line. merely pasting it > gives "SyntaxError: multiple statements found while compiling a single > statement" > > -- BUT anyway, I think the basic question would then be, if I wanted to write > a python app that used TKinter windows like that, how would I do it so that > Geany would show the results? TKinter is a quite commonly used component... > > -- BTW, that script worked OK to show the TKinter output in both IDLE and > Thonny IDEs > > I'm guessing it's some not-too-complex little configuration or tweak > somewhere... > > thx > Eric > > On Sun, May 20, 2018, at 9:10 AM, Lex Trotman wrote: >> What happens if you run your script from the command line? I suspect >> it will just return the same as it does in Geany. Geany runs things >> exactly as if from the command line, so if your script doesn't run >> there it won't run in Geany. >> >> The other IDE is a specialist Python thingy which may be doing >> something different, possibly helpful for beginners, but not so >> helpful when you actually want your script to run as a separate >> program independent of the IDE. >> >> Cheers >> Lex >> >> On 20 May 2018 at 11:25, Eric Stephan <[email protected]> wrote: >> > >> > Hello all! >> > >> > I have a problem on the Raspberry Pi where Geany will not show the Tkinter >> > window when I am making a simple Python app with tkinter graphics. >> > >> > I tried asking on Stack Exchange but no luck… I am sorry that I will just >> > paste the question below, it’s the easiest way to be clear about it! >> > >> > ====== >> > >> > My problem: When I run my simple graphics tkinter python script (pasted >> > below) in Geany, it "runs" ... BUT it simply shows the white-text-on-black >> > script window proudly announcing that script completed... while the tkinter >> > graphics window created by the script does not appear! *** When I do >> > this in another IDE, Thonny, the graphics window appears. How do I get >> > Geany to show this script's graphics window correctly? THANKS! >> > >> > —— below is the code (from a learn-Python book) >> > >> > from Tkinter import * >> > >> > window = Tk() >> > window.title('Alien') >> > c = Canvas(window, height = 300, width=400) >> > c.pack() >> > body=c.create_oval(100,150,300,250,fill='green') >> > eye=c.create_oval(170,70,230,130,fill='white') >> > eyeball=c.create_oval(190,90,210,110,fill='black') >> > mouth=c.create_oval(150,220,250,240,fill='red') >> > neck=c.create_line(200,150,200,130) >> > hat=c.create_polygon(180,75,220,75,200,20,fill='blue') >> > >> > def mouth_open(): >> > c.itemconfig(mouth,fill='black') >> > def mouth_close(): >> > c.itemconfig(mouth,fill='red') >> > >> > def blink(event): >> > c.itemconfig(eye, fill='green') >> > c.itemconfig(eyeball, state=HIDDEN) >> > def unblink(event): >> > c.itemconfig(eye, fill='white') >> > c.itemconfig(eyeball, state=NORMAL) >> > >> > words=c.create_text(200,280,text='I am an alien!') >> > def steal_hat(): >> > c.itemconfig(hat,state=HIDDEN) >> > c.itemconfig(words, text='Give me my hat back!') >> > >> > window.attributes('-topmost',1) >> > >> > def burp(event): >> > mouth_open() >> > c.itemconfig(words,text="Burp!") >> > c.bind_all('<Button-1>', burp) >> > >> > c.bind_all('<KeyPress-a>',blink) >> > c.bind_all('<KeyPress-z>',unblink) >> > >> > >> > def eye_control(event): >> > key=event.keysym >> > if key=='Up': >> > c.move(eyeball,0,-1) >> > if key=='Down': >> > c.move(eyeball,0,1) >> > if key=='Left': >> > c.move(eyeball,-1,0) >> > if key=='Right': >> > c.move(eyeball,1,0) >> > c.bind_all('<Key>',eye_control) >> > >> > >> > >> > _______________________________________________ >> > Users mailing list >> > [email protected] >> > https://lists.geany.org/cgi-bin/mailman/listinfo/users >> > >> _______________________________________________ >> Users mailing list >> [email protected] >> https://lists.geany.org/cgi-bin/mailman/listinfo/users > _______________________________________________ > Users mailing list > [email protected] > https://lists.geany.org/cgi-bin/mailman/listinfo/users _______________________________________________ Users mailing list [email protected] https://lists.geany.org/cgi-bin/mailman/listinfo/users
