Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #1  
Old February 2nd, 2013, 12:41 AM
joytoilet joytoilet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 joytoilet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 58 m 23 sec
Reputation Power: 0
Sizing canvas in IDLE

Hi everyone,

I'm trying to create the illusion of an interface in python. I'm only using IDLE to write the code right now which I believe has tkinter build in. I want to create a test game with the canvas being set inside of a tick black border with text rolling at the bottom below the canvas. How does that work exactly? And what if I wanted to use the mouse to select options on the canvas? thanks!

Reply With Quote
  #2  
Old February 2nd, 2013, 10:30 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,384 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 48 m 49 sec
Reputation Power: 383
scrolled text example

Also investigate events and bindings
Code:
import sys

if '2' == sys.version[0]:
    import Tkinter as tkinter
else:
    import tkinter

root = tkinter.Tk()
canvas = tkinter.Canvas(root,width=400,height=100)
canvas.pack()
y = 100
scroll = canvas.create_text(0,y,anchor=tkinter.NW,text="""$ python3 q.py
Traceback (most recent call last):
  File "q.py", line 12, in <module>
    scroll.pack(tkinter.BOTTOM)
  File "/usr/lib/python3.2/tkinter/__init__.py", line 1819, in pack_configure
    + self._options(cnf, kw))
  File "/usr/lib/python3.2/tkinter/__init__.py", line 1066, in _options
    for k, v in cnf.items():
AttributeError: 'str' object has no attribute 'items'""")

def f(*args,**kwargs):
    global y
    y -= 1
    canvas.coords(scroll,0,y)
    if y < -160:
        root.destroy()
    else:
        canvas.after(20,f)

canvas.after(40,f)

root.mainloop()
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old February 2nd, 2013, 03:03 PM
joytoilet joytoilet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 joytoilet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 58 m 23 sec
Reputation Power: 0
Hey thanks I'll sit and look over this! Seems much more obvious now

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Sizing canvas in IDLE

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap