Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Asrarahmed Kadri

I want to change the coordinates because I was under the wrong impression;
when I gave some thought then only I realised that the COORDINATES need to
be changed in order to increase the dimensions of the GRAPH and in turn the
entire frame, canvas, and the toplevel window that is holding the frame and
the canvas..

Is there a method that redraws the toplevel windows that is holding the
widgets

If yes, then can you suggest me how to do it..

Thanks in anticipation.

Regards,
Asrarahmed Kadri


On 1/16/07, Alan Gauld [EMAIL PROTECTED] wrote:



Asrarahmed Kadri [EMAIL PROTECTED] wrote

 I want to provide with a functionality of changing the font size, in
 this
 case the width of the lines.
Its not really the font size. fonts only apply to text, its only
the line width you want to change. However todo that I
think the easiest way is just to elete the existing line
(and maybe the whole graph) and redraw with the new
parameters. Provideed the data has been precalculated
then this should be a rapid operation.


 Is it possible to do it dynamically; I mean the graph is
 already drawn, now with a Menu, suppose I want to
 provide the user with options of 50%, 100%
 and 200% font size.

You will need to store the line thicknesses in variables
so that the drawing routine can be parameter driven. Then
simply delete the existing graph and redraw it with the
new thickness - remember you may need to rescale
your axis to cater for thicker/thinner lines.

If you are using a filled Rectangle rather than a real line
(which is what I would actually expect to see in a bar chart)
then obviously the line thickness simply involves setting
the difference in the y coordinates appropriately.

Alan G.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor





--
To HIM you shall return.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Michael Lange
On Tue, 16 Jan 2007 00:33:20 -
Alan Gauld [EMAIL PROTECTED] wrote:

 
 Asrarahmed Kadri [EMAIL PROTECTED] wrote
 
  I want to provide with a functionality of changing the font size, in 
  this
  case the width of the lines.
 Its not really the font size. fonts only apply to text, its only
 the line width you want to change. However todo that I
 think the easiest way is just to elete the existing line
 (and maybe the whole graph) and redraw with the new
 parameters. Provideed the data has been precalculated
 then this should be a rapid operation.
 

I am not sure if the OP meant to increase the graph elements according
to the font size, so the graph does not look tiny next to a huge font.

Anyway, there is no need to delete and recreate the items, just calculate
the new coordinates and pass them to Canvas.coords()

 
  Is it possible to do it dynamically; I mean the graph is
  already drawn, now with a Menu, suppose I want to
  provide the user with options of 50%, 100%
  and 200% font size.
 
 You will need to store the line thicknesses in variables
 so that the drawing routine can be parameter driven. Then
 simply delete the existing graph and redraw it with the
 new thickness - remember you may need to rescale
 your axis to cater for thicker/thinner lines.
 

This is probably not necessary either, you can query the size of canvas elements
dynamically, use Canvas.bbox() to query width and height of rectangles or
Canvas.itemcget(item, 'width') and again Canvas.bbox() for line elements.

 If you are using a filled Rectangle rather than a real line
 (which is what I would actually expect to see in a bar chart)
 then obviously the line thickness simply involves setting
 the difference in the y coordinates appropriately.
 

If you only want to be able to resize the graph elements into half and double 
size
it is probably easiest to use the Canvas.scale() method for this, like

 from Tkinter import *
 c=Canvas()
 c.pack(fill='both', expand=1)
 r = c.create_rectangle(20, 20, 70, 30, fill='red')
 c.scale(r, 20, 20, 2, 2)
 c.scale(r, 20, 20, 0.5, 0.5)

However, text, image and window items cannot be scaled.
If you want to scale text items, it might be the best to pre-define
e.g. three pixel-sized fonts, like

fonts = {'small':'helvetica -10', 'normal':'helvetica -12', 'big':'helvetica 
-14'}

and then provide a callback that will both change the font size for the
text elements and scale the graph elements (and the x- and y-axis).

I hope this helps

Michael



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread ALAN GAULD

--- Asrarahmed Kadri [EMAIL PROTECTED] wrote:

 Is there a method that redraws the toplevel windows that is
 holding the widgets

Yes, you can issue an update() command to any widget.
Usually you don't need to as Tkinter figures out when 
things have changed and updates itself, but 
occasionally you may need to fo it manually.

Alan G.



___ 
The all-new Yahoo! Mail goes wherever you go - free your email address from 
your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Michael Lange
On Tue, 16 Jan 2007 09:56:27 + (GMT)
ALAN GAULD [EMAIL PROTECTED] wrote:

 
 --- Asrarahmed Kadri [EMAIL PROTECTED] wrote:
 
  Is there a method that redraws the toplevel windows that is
  holding the widgets
 
 Yes, you can issue an update() command to any widget.
 Usually you don't need to as Tkinter figures out when 
 things have changed and updates itself, but 
 occasionally you may need to fo it manually.
 

Or, if you mean to change the toplevel's size, use 
Toplevel.configure(width=..., height=...)

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-15 Thread Alan Gauld

Asrarahmed Kadri [EMAIL PROTECTED] wrote

 I want to provide with a functionality of changing the font size, in 
 this
 case the width of the lines.
Its not really the font size. fonts only apply to text, its only
the line width you want to change. However todo that I
think the easiest way is just to elete the existing line
(and maybe the whole graph) and redraw with the new
parameters. Provideed the data has been precalculated
then this should be a rapid operation.


 Is it possible to do it dynamically; I mean the graph is
 already drawn, now with a Menu, suppose I want to
 provide the user with options of 50%, 100%
 and 200% font size.

You will need to store the line thicknesses in variables
so that the drawing routine can be parameter driven. Then
simply delete the existing graph and redraw it with the
new thickness - remember you may need to rescale
your axis to cater for thicker/thinner lines.

If you are using a filled Rectangle rather than a real line
(which is what I would actually expect to see in a bar chart)
then obviously the line thickness simply involves setting
the difference in the y coordinates appropriately.

Alan G. 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor