Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 28th, 2003, 02:01 PM
theparasiticmin theparasiticmin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 theparasiticmin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
problems with tkinter, are while loops possible?

im making a very simple game where right now the controllable character is a rectangle on a canvas. i bound function for the movement to the arrow keys, and the rectangle is moved by canvas.move()

my problem is that i want the arrow keys to simple change the direction of the movement and have the rectangle always move in that direction without key presses. so i tried a while loop which seemed like the natural solution, but the problem is the entire loop has to be executed before the window is created and while 1: loops make it freeze. is there any solution to this?

Reply With Quote
  #2  
Old November 28th, 2003, 05:18 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
while loops are possable in GUI's , that i do know! I guess what you should be doing is calling your 'move this way' function inside your while loop.. if you have some code i'll take a look

Oh, in Python 2.3+ you should use the True keyword instead of 1 (as long as you arnt bothered about back compatability), so your while loop should look like this..

while True:
...
do whatever
...

Also, if you want to make games with Python can i suggest you try Pygame, its allot more powerful and this is what it was built for!

http://www.pygame.org/

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old November 28th, 2003, 05:59 PM
theparasiticmin theparasiticmin is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 theparasiticmin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i know of pygame, i learned a bit and to be honest i dont like it a lot. for this simple game i know i can avoid it. heres thing the thing, there is no while loop. in tkinter, the only way i know of making things work is in events, and i tried puting a while loop in an event but again its as if the loop finishes in one go and and then everything is displayed, its in explicable. does anyone ahve any experience with this?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > problems with tkinter, are while loops possible?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway