Re: Tkinter custom drawing

2007-06-09 Thread Xavier Bérard
Thank you this is nice code. I never thought of using the move_pending
method..

Still it doesn't answer my question (which I ensure is very unclear).
But do not worry, I found some way to get throught my dilemma and I
can live easily with it. Thanks for your help.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter custom drawing

2007-06-08 Thread Xavier Bérard
 from Tkinter import Invisiblecanvas

?

The whole web never mentions this Invisiblecanvas.
Do you have anything alike to share ? ;)

Xavier

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter custom drawing

2007-06-08 Thread Xavier Bérard


  Now, the problem, is that I have already plenty of widgets on my
  screen. I just want to draw over them, which is a bit difficult in my
  comprehension of things.

 What are you trying to achieve by drawing over widgets?


Want I want to do is a sort of GUI builder for Tkinter. I already
finished a rough version, but for now I'm making a lighter version of
this project. So, my intent, is to create a widget under the widget.
While dragging the mouse, I want to see this rectangle that defines
the boundaries of the new widget I'm creating.

Sorry for being unclear.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter custom drawing

2007-06-08 Thread James Stroud
Xavier Bérard wrote:
from Tkinter import Invisiblecanvas
 
 
 ?
 
 The whole web never mentions this Invisiblecanvas.
 Do you have anything alike to share ? ;)
 
 Xavier
 

I figured that if you were sincere, you'd call me on this one.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter custom drawing

2007-06-08 Thread James Stroud
Xavier Bérard wrote:
Now, the problem, is that I have already plenty of widgets on my
screen. I just want to draw over them, which is a bit difficult in my
comprehension of things.

What are you trying to achieve by drawing over widgets?
 
 
 
 Want I want to do is a sort of GUI builder for Tkinter. I already
 finished a rough version, but for now I'm making a lighter version of
 this project. So, my intent, is to create a widget under the widget.
 While dragging the mouse, I want to see this rectangle that defines
 the boundaries of the new widget I'm creating.
 
 Sorry for being unclear.
 

You may want to look into the place() method. The python mega widgets 
(PMW) has a PanedWidget that implements this smoothly. You may want to 
emulate that approach:


#! /usr/bin/env python

from Tkinter import *

def button_pressed(e):
   moved = e.widget
   moved.move_pending = True
   moved['cursor'] = 'hand1'
   moved.press_x = e.x
   moved.press_y = e.y

def button_moved(e):
   moved = e.widget
   if moved.move_pending:
 moved.after_idle(lambda e=e: _button_moved(e))
 moved.move_pending = False

def _button_moved(e):
   moved = e.widget
   delta_x = e.x - moved.press_x
   delta_y = e.y - moved.press_y
   size, wx, wy = moved.winfo_geometry().split('+')
   new_x = int(wx) + delta_x
   new_y = int(wy) + delta_y
   moved.place(x=new_x, y=new_y)
   moved.update_idletasks()
   moved.move_pending = True

def button_up(e):
   e.widget['cursor'] = ''

def register(widget):
   widget.bind('ButtonPress-3', button_pressed)
   widget.bind('B3-Motion', button_moved)
   widget.bind('Any-ButtonRelease-3', button_up)
   widget.update_idletasks()

def test():
   tk = Tk()

   b = Button(tk, text='Button')
   b.pack()
   c = Button(tk, text='Another Button')
   c.pack()
   x = Label(tk, text='Drag Me', relief=RIDGE, border=1)
   register(x)
   x.pack()

   tk.geometry('200x200')
   tk.mainloop()

if __name__ == __main__:
   test()


James
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter custom drawing

2007-06-07 Thread Xavier Bérard
Hello everyone,

I am wondering if there is a way to use custom drawing in Tkinter.
I've been using it for few months, and all I know about custom drawing
is to draw directly on a Canvas with such methods as create_line,
create_rectangle, etc.

Now, the problem, is that I have already plenty of widgets on my
screen. I just want to draw over them, which is a bit difficult in my
comprehension of things.

My perfect solution was to put temporary invisible Canvas when I want
do use draw methods, but such thing doesn't exist (as far as I could
search in this community's posts).

Anyone have a clue ?

Thanks,
Xavier Berard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter custom drawing

2007-06-07 Thread Kevin Walzer
Xavier Bérard wrote:
 
 Now, the problem, is that I have already plenty of widgets on my
 screen. I just want to draw over them, which is a bit difficult in my
 comprehension of things.
 

What are you trying to achieve by drawing over widgets?

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter custom drawing

2007-06-07 Thread James Stroud
Xavier Bérard wrote:
 Hello everyone,
 
 I am wondering if there is a way to use custom drawing in Tkinter.
 I've been using it for few months, and all I know about custom drawing
 is to draw directly on a Canvas with such methods as create_line,
 create_rectangle, etc.
 
 Now, the problem, is that I have already plenty of widgets on my
 screen. I just want to draw over them, which is a bit difficult in my
 comprehension of things.
 
 My perfect solution was to put temporary invisible Canvas when I want
 do use draw methods, but such thing doesn't exist (as far as I could
 search in this community's posts).
 
 Anyone have a clue ?
 
 Thanks,
 Xavier Berard
 

Are you sure you are spelling it right? The C is not capitalized:

from Tkinter import Invisiblecanvas

etc.

James
-- 
http://mail.python.org/mailman/listinfo/python-list