[Tkinter-discuss] Tkinter-discuss Digest, Vol 35, Issue 15
Vasilis Vlachoudis
Vasilis.Vlachoudis at cern.ch
Tue Jan 23 11:32:18 CET 2007
Hi Harlin,
sorry but I didn't quite understand, you need the full code of the
project I am writing or on the specific example that I've send to the list?
The full code of the project together with screenshots, documentation
etc can be found at http://www.fluka.org/flair
while for the specific question on resetting the background color, I
will have to make the configuration dialog as a standalone program.
Regards
Vasilis
Harlin Seritt wrote:
> Vasilis,
>
> Would you mind posting your full code for this?
>
> Thanks,
>
> Harlin Seritt
>
>
> */tkinter-discuss-request at python.org/* wrote:
>
> Send Tkinter-discuss mailing list submissions to
> tkinter-discuss at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> or, via email, send a message with subject or body 'help' to
> tkinter-discuss-request at python.org
>
> You can reach the person managing the list at
> tkinter-discuss-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tkinter-discuss digest..."
>
>
> Today's Topics:
>
> 1. more info on find_closest problem (Jeff Cagle)
> 2. Re: Find_closest, bbox, and weirdness (Russell E Owen)
> 3. more find_closest followup (Jeff Cagle)
> 4. Re: Find_closest, bbox, and weirdness (Cameron Laird)
> 5. Resetting to default background color (Vasilis Vlachoudis)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 18 Jan 2007 14:24:24 -0500
> From: Jeff Cagle
> Subject: [Tkinter-discuss] more info on find_closest problem
> To: tkinter-discuss at python.org
> Message-ID: <45AFC968.8010806 at juno.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Well, I take one thing back: There was a text object at the point
> (30,10) -- a text object that was updated with mouse x,y coords every
> time a event fired. When without that text object,
> find_closest() works well. With it, find_closest gets confused again.
>
> It should be possible, I hope, to work around this issue by means of
> tags for the text objects. But I'm curious: why is this happening?
>
> Here's the code, with updated output:
>
> [code="seems like it oughta work"]
> def display(self):
> self.mainw = Tk()
> self.mainw.f = Frame(self.mainw)
> self.mainw.f.c = Canvas(self.mainw.f,width=400,height=400)
> # remove next line for success with find_closest()
> self.mainw.f.c.mouse_text =
> self.mainw.f.c.create_text(30,10,text='')
>
> ...
> self.print_canvas()
> print "Center coords: (%.1f,%.1f) and (%.1f, %.1f)" % (x0,y0,x1,y1)
> f = mathutils.line_func((x0,y0),(x1,y1))
> g = mathutils.inv_line_func((x0,y0),(x1,y1))
>
> print "Objects near (%.1f,%.1f)" % (x0,y0), \
> self.mainw.f.c.find_closest(x0,y0)
> start_id = self.mainw.f.c.find_closest(x0,y0)[0]
> print "start_id: ", start_id
> start_x0,start_y0,start_x1,start_y1 = self.mainw.f.c.bbox(start_id)
> print "Bounding box near (%.1f,%.1f): (%.1f,%.1f) x (%.1f,%.1f)" % \
> (x0,y0,start_x0,start_y0,start_x1,start_y1)
>
> print "Objects near (%.1f,%.1f)" % (x1,y1), \
> self.mainw.f.c.find_closest(x1,y1)
> end_id = self.mainw.f.c.find_closest(x1,y1)[0]
> print "end_id: ", end_id
> end_x0,end_y0,end_x1,end_y1 = self.mainw.f.c.bbox(end_id)
> print "Bounding box near (%.1f,%.1f): (%.1f,%.1f) x (%.1f,%.1f)" % \
> (x1,y1,end_x0,end_y0,end_x1,end_y1)
>
> raw_input("Press to continue...")
> ...
> [/code]
> [output="without offending text object"]
> >>> p.display()
> The canvas contains
> ------------------
> Item_ID Type coords
> 1 text [200.0, 20.0]
> 2 text [278.09907304116047, 37.825603777564567]
> 3 text [340.72966684424534, 87.771835665427943]
> 4 text [375.48702419272826, 159.94623188786341]
> 5 text [375.48702419272826, 240.05376811213657]
> 6 text [340.72966684424534, 312.22816433457206]
> 7 text [278.09907304116047, 362.17439622243546]
> 8 text [200.00000000000003, 380.0]
> 9 text [121.90092695883955, 362.17439622243546]
> 10 text [59.270333155754656, 312.22816433457206]
> 11 text [24.512975807271744, 240.05376811213659]
> 12 text [24.512975807271744, 159.94623188786343]
> 13 text [59.270333155754628, 87.771835665428]
> 14 text [121.90092695883949, 37.825603777564567]
> Center coords: (278.1,37.8) and (375.5, 159.9)
> Objects near (278.1,37.8) (2,)
> start_id: 2
> Bounding box near (278.1,37.8): (269.0,32.0) x (288.0,45.0)
> Objects near (375.5,159.9) (4,)
> end_id: 4
> Bounding box near (375.5,159.9): (362.0,154.0) x (388.0,167.0)
> Press to continue...
> [/output]
>
> [output="with offending text object"]
> >>> p.display()
> The canvas contains
> ------------------
> Item_ID Type coords
> 1 text [30.0, 10.0]
> 2 text [200.0, 20.0]
> 3 text [278.09907304116047, 37.825603777564567]
> 4 text [340.72966684424534, 87.771835665427943]
> 5 text [375.48702419272826, 159.94623188786341]
> 6 text [375.48702419272826, 240.05376811213657]
> 7 text [340.72966684424534, 312.22816433457206]
> 8 text [278.09907304116047, 362.17439622243546]
> 9 text [200.00000000000003, 380.0]
> 10 text [121.90092695883955, 362.17439622243546]
> 11 text [59.270333155754656, 312.22816433457206]
> 12 text [24.512975807271744, 240.05376811213659]
> 13 text [24.512975807271744, 159.94623188786343]
> 14 text [59.270333155754628, 87.771835665428]
> 15 text [121.90092695883949, 37.825603777564567]
> Center coords: (278.1,37.8) and (375.5, 159.9)
> Objects near (278.1,37.8) (1,)
> start_id: 1
> Bounding box near (278.1,37.8): (29.0,4.0) x (31.0,17.0)
> Objects near (375.5,159.9) (1,)
> end_id: 1
> Bounding box near (375.5,159.9): (29.0,4.0) x (31.0,17.0)
> Press to continue...
> [/output]
>
> Thanks for any insights,
> Jeff Cagle
>
>
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 18 Jan 2007 12:36:18 -0800
> From: Russell E Owen
> Subject: Re: [Tkinter-discuss] Find_closest, bbox, and weirdness
> To: tkinter-discuss at python.org
> Message-ID:
>
> In article <45AF2253.2080903 at juno.com>, Jeff Cagle
> wrote:
>
> > So I was trying to pretty up a GUI. It took 20 minutes to write
> code to
> > place names in a circle and draw arrows to the names that are
> related
> > (actually, the names are filenames, and the arrows represent
> 'import' or
> > 'from ... import' statements).
> >
> > It's taken a couple of hours to try to clean it up so that the
> arrows go
> > up to the bounding box of the text, but not inside.
> >
> > Here was the plan: Compute the line that connects the centers of
> the
> > text objects. Figure out where that line intersects the bounding
> boxes
> > of the texts, and draw the lines to the intersection points
> instead of
> > center-to-center.
> >
> > It all works ... except that I don't get the right bounding boxes.
> > Here's the code:
>
> it sounds like object with ID 1 may be overlapping all the other
> objects. Tk's find_closest is primitive in how it handles overlap.
>
> Unless you can guarantee that your text objects will never overlap I
> suggest you find the closest one yourself. Keep a list of object
> coords
> and scan through them. If the objects can be moved around then use a
> callback to update the position.
>
> -- Russell
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 18 Jan 2007 16:16:23 -0500
> From: Jeff Cagle
> Subject: [Tkinter-discuss] more find_closest followup
> To: tkinter-discuss at python.org
> Message-ID: <45AFE3A7.3060905 at juno.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> In the end, find_closest was giving odd results even when the
> offending
> mouse_text object was not created.
>
> So I fired it and replaced it with a 'find_closest_label()' that
> searches only the text labels for the closest match. Problem
> solved ...
> errr ... worked around.
>
> Jeff
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 18 Jan 2007 21:21:49 +0000
> From: Cameron Laird
> Subject: Re: [Tkinter-discuss] Find_closest, bbox, and weirdness
> To: Russell E Owen
> Cc: tkinter-discuss at python.org
> Message-ID: <20070118212149.GB24852 at lairds.us>
> Content-Type: text/plain; charset=us-ascii
>
> On Thu, Jan 18, 2007 at 12:36:18PM -0800, Russell E Owen wrote:
> .
> .
> .
> > > Here was the plan: Compute the line that connects the centers
> of the
> > > text objects. Figure out where that line intersects the
> bounding boxes
> > > of the texts, and draw the lines to the intersection points
> instead of
> > > center-to-center.
> > >
> > > It all works ... except that I don't get the right bounding
> boxes.
> > > Here's the code:
> >
> > it sounds like object with ID 1 may be overlapping all the other
> > objects. Tk's find_closest is primitive in how it handles overlap.
> >
> > Unless you can guarantee that your text objects will never
> overlap I
> > suggest you find the closest one yourself. Keep a list of object
> coords
> > and scan through them. If the objects can be moved around then
> use a
> > callback to update the position.
> .
> .
> .
> ? I've had *great* results with "closest". While I agree
> that your approach should be kept in mind, it's not the
> first one I try when I'm in the situation I understand from
> the original description. Do you have any details on how
> "closest" has failed for you?
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 19 Jan 2007 10:14:43 +0100
> From: "Vasilis Vlachoudis"
> Subject: [Tkinter-discuss] Resetting to default background color
> To:
> Message-ID:
> <2AACD4EB2F123248A064A23843B3A173020BDE at cernxchg47.cern.ch>
> Keywords: CERN SpamKiller Note: -50 Charset: west-latin
> Content-Type: text/plain; charset="us-ascii"
>
> Dear All,
>
>
>
> How can I reset the background color of widget to the default one?
>
>
>
> Imagine that I create an entry widget with a specific background color
> i.e. white
>
> e=Entry(root, background="white")
>
> e.pack()
>
> ...
>
> and at a later state I want to configure the color to the default
> system
> one (equivalent like when I create it: e=Entry(root))
>
> I've tried
>
> e["background"] = "" # didn't work
>
> e["background"] = None # nothing
>
> del e["background"] # neither
>
>
>
> Cheers
>
> Vasilis
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.python.org/pipermail/tkinter-discuss/attachments/20070119/8b722144/attachment.html
>
>
> ------------------------------
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>
> End of Tkinter-discuss Digest, Vol 35, Issue 15
> ***********************************************
>
>
> ------------------------------------------------------------------------
> Food fight?
> <http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396545367>
> Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink Q&A.
> <http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396545367>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Vasilis.Vlachoudis.vcf
Type: text/x-vcard
Size: 312 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tkinter-discuss/attachments/20070123/4afab079/attachment.vcf
More information about the Tkinter-discuss
mailing list