Using Tkinter Canvas to teach High School Geometry
with A LOT of success.
My drawing gets very slow after a lot of actions.
For instance I have created code to rotate a set of objects
about a rotation point.
rotate 360 degrees starts to get slow
after 720 degrees its crawling.
I checked the item list with with find_all: IT GROWS!
OK, I create 3 lines using a line Class I created.
When I rotate these 3 lines thru 360 degrees it creates
360 lines times 3. But each new instance of line REPLACES
the old instance. The line class has a destructor to delete
the drawn object.
class line:
count = 0
def __init__(s,glob ,argl,color='') :
line.count = line.count + 1
##
## buncha code here
##
s.obj = glob.can.create _line(x0,y0,x1, y1,
width=glob.widt h,fill=s.color)
def __del__(s):
line.count = line.count - 1
## delete the line object if the
## class instance is deleted
s.glob.can.dele te(s.obj)
After the rotation I check line.count and it is 3
But find_all returns a tuple ofover 1000 items.
The drawn objects are not being deleted.
Which is kinda weird because the rotation works.
That is they appear to be deleted.
Is find_all() fooling me?
Is this the reason drawing slows down? Is it refreshing
invisible objects?
This slowing down also occurs when I draw a lot of objects.
Lets say I draw a sine wave, say 1000 individual points.
If I draw 4 or 5 sine waves it gets really slow.
I should mention I call update() after each drawing action.
This is necessary for the students to watch the progress.
I might be drawing objects in a lengthy loop and without
update() they only appear at the end of the loop.
Thanks for any help.
-- Confused 3 2226
"phil" <ph***********@ anvilcom.com> wrote in message
news:ma******** *************** **************@ python.org... Using Tkinter Canvas to teach High School Geometry with A LOT of success.
Can you post a link to your code.
I'd like to see what you are doing.
Thx,
Alan Isaac
phil wrote: def __del__(s): line.count*=*li ne.count*-*1
##*delete*the*l ine*object*if*t he ##*class*instan ce*is*deleted s.glob.can.dele te(s.obj)
After the rotation I check line.count and it is 3
Did you know that exceptions are ignored in the __del__() method?
One way to verify that your __del__() runs to completion would be to make
the line.count decrement the last statement, and check the total line.count
after the rotation again.
Generally speaking the __del__() method is not the most robust cleanup
mechanism. Maybe you can add a line.delete() method and change your program
flow for it to be called explicitly when the line should no longer be
visible.
Peter
I think the answer you should find under Subject: Tkinter slowes down
---
geon
Exception is rule.
phil napsal(a): Using Tkinter Canvas to teach High School Geometry with A LOT of success.
My drawing gets very slow after a lot of actions.
For instance I have created code to rotate a set of objects about a rotation point. rotate 360 degrees starts to get slow after 720 degrees its crawling.
I checked the item list with with find_all: IT GROWS!
OK, I create 3 lines using a line Class I created. When I rotate these 3 lines thru 360 degrees it creates 360 lines times 3. But each new instance of line REPLACES the old instance. The line class has a destructor to delete the drawn object.
class line: count = 0 def __init__(s,glob ,argl,color='') : line.count = line.count + 1 ## ## buncha code here ## s.obj = glob.can.create _line(x0,y0,x1, y1, width=glob.widt h,fill=s.color) def __del__(s): line.count = line.count - 1
## delete the line object if the ## class instance is deleted s.glob.can.dele te(s.obj)
After the rotation I check line.count and it is 3 But find_all returns a tuple ofover 1000 items. The drawn objects are not being deleted. Which is kinda weird because the rotation works. That is they appear to be deleted.
Is find_all() fooling me? Is this the reason drawing slows down? Is it refreshing invisible objects?
This slowing down also occurs when I draw a lot of objects. Lets say I draw a sine wave, say 1000 individual points. If I draw 4 or 5 sine waves it gets really slow.
I should mention I call update() after each drawing action. This is necessary for the students to watch the progress. I might be drawing objects in a lengthy loop and without update() they only appear at the end of the loop.
Thanks for any help.
-- Confused
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Zhang Le |
last post by:
Hello,
Is there a quick way to replace the content of a single item in
tkinter's listbox? Currently my solution is to first delete the item,
then insert a new item at the same position. I think there may be
better way.
Zhang Le
|
by: steve |
last post by:
In a nutshell, my problem is that I am getting this runtime error, and
I have no clue why. Please bear in mind its my first python program:
"localvariable 'currentAbility' referenced before asignment"
in this function which is a callback for a button:
def nextThing():
if lookingAtAbilities == 1:
currentAbility = currentAbility + 1
|
by: Harlin Seritt |
last post by:
I've created a ghetto-ized ComboBox that should work nicely for Tkinter
(unfortunately no dropdown capabilities yet).
I've found why it's such a pain in the @ss to create one. You have to
re-create common methods and make sure they're mapped to the right
component (inside this widget are frame, entry, listbox, and scrollbar
widgets). I...
|
by: phil |
last post by:
>> Using Tkinter Canvas to teach High School Geometry
>> with A LOT of success.
>Can you post a link to your code.
>I'd like to see what you are doing.
>Thx,
>Alan Isaac
Yes, I will release it open source at the end of may.
|
by: Andrew Trevorrow |
last post by:
Our app uses embedded Python to allow users to run arbitrary scripts.
Scripts that import Tkinter run fine on Windows, but on Mac OS X there
is a serious problem. After a script does "root = Tk()" our app's menus
are permanently changed in the following way:
- The top item in the application menu changes to "About Tcl & Tk...".
- The Quit...
| |
by: vedran_dekovic |
last post by:
Hi,
I need help about Tkinter listbox widget.I want,when somebody click on
any item(file) in Listbox,then in new Label widget text must be
selected item from server.
my program (wrong example):
import ftputil
import Tkinter
root=Tkinter.Tk()
|
by: alivip |
last post by:
I integrat program to be GUI using Tkinter I try browser direction
as you can see
# a look at the Tkinter Text widget
# use ctrl+c to copy, ctrl+x to cut selected text,
# ctrl+v to paste, and ctrl+/ to select all
# count words in a text and show the first ten items
|
by: J-Burns |
last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in
programming itself... :P. Need some help here.
Problem 1:
How do I make something appear on 2 separate windows using Tkinter? By
this I mean that the format would be something like this:
You have Page1 : This has 2-3 buttons on it.
Clicking on each button opens up a new...
|
by: Mudcat |
last post by:
I've tried quite a few things to get this correct but have hit a
couple of sticking points that I can't figure out. I need to ge the
Text box to function like the 'wraplength' option in a Label.
I've been able to adjust the height of the text by calculating the
number of lines needed to display the text. That's fairly simple. I
know the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |