Jack Eisenbach | 6 Jun 2011 18:44
Picon

Version conflict for Tcl running 2.7.1 on Windows

Hi,
 
I installed Python 2.7.1 on my Windows 7 32-bit version. I get the following error when I run my
Tkinter application. I can run the same application on both Python 2.6.5 and 2.6.6 without the problem below.
 
c:\ISS\ledmatrix>led-display.py
Traceback (most recent call last):
  File "ledmatrix.py", line 2263, in <module>
    LEDMatrix()
  File "ledmatrix.py", line 1427, in LEDMatrix
    root = Tk()
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1643, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    {C:\Python27\tcl\tcl8.5} C:/Python26/lib/tcl8.5 C:/lib/tcl8.5 C:/lib/tcl8.5 C:/library C:/library C:/tcl8.5.8/library C:/tcl8.5.8/library
 
C:/Python27/tcl/tcl8.5/init.tcl: version conflict for package "Tcl": have 8.5.8, need exactly 8.5.2
version conflict for package "Tcl": have 8.5.8, need exactly 8.5.2
    while executing
"package require -exact Tcl 8.5.2"
    (file "C:/Python27/tcl/tcl8.5/init.tcl" line 20)
    invoked from within
"source C:/Python27/tcl/tcl8.5/init.tcl"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list source $tclfile]"
 
 
This probably means that Tcl wasn't installed properly.
 
 
Can this be corrected in 2.7.1?
 
Thanks in advance,
Jack
 
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
alexxxm | 7 Jun 2011 15:03
Picon
Favicon

newbie request for help


Hi everybody,
I need some help to understand if tkinter is in fact the right tool to use
for me.

I intend to write a very bare-bone wiki in python. It should be able to:

1) open a text file
2) display the text file, with links in the form {{image.jpg}} replaced by
the image, and [[linkname|linkfile.txt]] replaced by linkname
3) when clicking on linkname, save the current text file and open in its
place the file linkfile.txt

really, I'm not interested in nothing more.

Do you believe it can be easily accomplished with tkinter, or do I need some
more complicated widget?

Thanks for any help...

alessandro

--

-- 
View this message in context: http://old.nabble.com/newbie-request-for-help-tp31791699p31791699.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Cam | 7 Jun 2011 16:05
Picon

Re: newbie request for help

You should be able to accomplish this easily with the tkinter "Text" widget.

Cam Farnell

On 11-06-07 10:03 AM, alexxxm wrote:
>
> Hi everybody,
> I need some help to understand if tkinter is in fact the right tool to use
> for me.
>
> I intend to write a very bare-bone wiki in python. It should be able to:
>
> 1) open a text file
> 2) display the text file, with links in the form {{image.jpg}} replaced by
> the image, and [[linkname|linkfile.txt]] replaced by linkname
> 3) when clicking on linkname, save the current text file and open in its
> place the file linkfile.txt
>
> really, I'm not interested in nothing more.
>
> Do you believe it can be easily accomplished with tkinter, or do I need some
> more complicated widget?
>
> Thanks for any help...
>
>
> alessandro
>
Cameron Laird | 7 Jun 2011 19:35

Re: newbie request for help

On Tue, Jun 07, 2011 at 11:05:09AM -0300, Cam wrote:
			.
			.
			.
> You should be able to accomplish this easily with the tkinter "Text" widget.
> 
> Cam Farnell
> 
> On 11-06-07 10:03 AM, alexxxm wrote:
			.
			.
			.
> >Do you believe it can be easily accomplished with tkinter, or do I need 
> >some
> >more complicated widget?
			.
			.
			.
Text() is indeed a powerhouse.  Its capabilities might astonish you.
In particular, it can do all you describe for your model of a Wiki.
While studying Text(), make a point of learning about its powerful
notion of "tag".
John W. Shipman | 7 Jun 2011 19:23

Re: newbie request for help

+--
| 1) open a text file
| 2) display the text file, with links in the form {{image.jpg}} replaced by
| the image, and [[linkname|linkfile.txt]] replaced by linkname
| 3) when clicking on linkname, save the current text file and open in its
| place the file linkfile.txt
+--

Tkinter can do all that.  A few suggestions:

- You will want to use a Text widget for your main display.
   Conceptually, this widget displays a sequence of lines of text.
   An image is treated as a single character: it is displayed on a
   line between the text that comes before it and the text that
   comes after it.

- Use tags to change the appearance of links so the reader will
   know they are clickable.  You can apply named tags to any
   number of regions in your Text widget.  Each tag is associated
   with options such as text color, background color, and font.

Here's a Tkinter reference that may help you:

     http://www.nmt.edu/tcc/help/pubs/tkinter

Read closely the sections of "The Text Widget", especially
the subsections "Text widget tags" and "Methods on Text
widgets".  In the latter subsection, note these methods:

.tag_add:  For applying a specific tag to a region of text.
.tag_bind:  Make regions tagged with a certain tag respond to
             events such as mouse clicks.
.tag_config:  Change the appearance of all regions tagged
               with a certain tag.

Best regards,
John Shipman (john <at> nmt.edu), Applications Specialist, NM Tech Computer Center,
Speare 119, Socorro, NM 87801, (575) 835-5735, http://www.nmt.edu/~john
   ``Let's go outside and commiserate with nature.''  --Dave Farber
alexxxm | 8 Jun 2011 08:42
Picon
Favicon

Re: newbie request for help


I thank you all for your help and I'm looking forward to implement it.
At the moment however I'm unable to do it since it appears I'm missing a
basic piece:

trying to approach the links, at first I used the code found at
http://effbot.org/zone/tkinter-text-hyperlink.htm:
<code>
import tkHyperlinkManager
from Tkinter import *

root = Tk()
root.title("hyperlink-1")

text = Text(root)
text.pack()

hyperlink = tkHyperlinkManager.HyperlinkManager(text)

def click1():
    print "click 1"

text.insert(INSERT, "this is a ")
text.insert(INSERT, "link", hyperlink.add(click1))
text.insert(INSERT, "\n\n")

def click2():
    print "click 2"

text.insert(INSERT, "this is another ")
text.insert(INSERT, "link", hyperlink.add(click2))
text.insert(INSERT, "\n\n")

mainloop()
</code>

but I get this:
ImportError: No module named tkHyperlinkManager

I work on Linux Fedora13, and my Tkinter version is
tkinter-2.6.4-27.fc13.x86_64
Probably tkHyperlinkManager is not included by default in the Tkinter
distribution?

As approach #2 I tried this (courtesy of StackOverflow):
<code>
import Tkinter

class App:
    def __init__(self, root):
        self.root = root
        for text in ("link1", "link2", "link3"):
            link = Tkinter.Label(text=text, foreground="#0000ff")
            link.bind("<1>", lambda event, text=text: \
                          self.click_link(event, text))
            link.pack()
    def click_link(self, event, text):
        print "you clicked '%s'" % text

root=Tkinter.Tk()
app = App(root)
root.mainloop()
</code>

and this works. Do you recommend this approach?

alessandro

alexxxm wrote:
> 
> Hi everybody,
> I need some help to understand if tkinter is in fact the right tool to use
> for me.
> 
> I intend to write a very bare-bone wiki in python. It should be able to:
> 
> 1) open a text file
> 2) display the text file, with links in the form {{image.jpg}} replaced by
> the image, and [[linkname|linkfile.txt]] replaced by linkname
> 3) when clicking on linkname, save the current text file and open in its
> place the file linkfile.txt
> 
> really, I'm not interested in nothing more.
> 
> Do you believe it can be easily accomplished with tkinter, or do I need
> some more complicated widget?
> 
> Thanks for any help...
> 
> 
> alessandro
> 
> 

--

-- 
View this message in context: http://old.nabble.com/newbie-request-for-help-tp31791699p31798108.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
alexxxm | 8 Jun 2011 08:48
Picon
Favicon

Re: newbie request for help


ooops, I just found out:
the code for tkHyperlinkManager is at http://pastebin.com/mWfDm7eZ

alessandro

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

alexxxm wrote:
> 
> I thank you all for your help and I'm looking forward to implement it.
> At the moment however I'm unable to do it since it appears I'm missing a
> basic piece:
> 
> trying to approach the links, at first I used the code found at
> http://effbot.org/zone/tkinter-text-hyperlink.htm:
> <code>
> import tkHyperlinkManager
> from Tkinter import *
> 
> root = Tk()
> root.title("hyperlink-1")
> 
> text = Text(root)
> text.pack()
> 
> hyperlink = tkHyperlinkManager.HyperlinkManager(text)
> 
> def click1():
>     print "click 1"
> 
> text.insert(INSERT, "this is a ")
> text.insert(INSERT, "link", hyperlink.add(click1))
> text.insert(INSERT, "\n\n")
> 
> def click2():
>     print "click 2"
> 
> text.insert(INSERT, "this is another ")
> text.insert(INSERT, "link", hyperlink.add(click2))
> text.insert(INSERT, "\n\n")
> 
> mainloop()
> </code>
> 
> 
> but I get this:
> ImportError: No module named tkHyperlinkManager
> 
> I work on Linux Fedora13, and my Tkinter version is
> tkinter-2.6.4-27.fc13.x86_64
> Probably tkHyperlinkManager is not included by default in the Tkinter
> distribution?
> 
> 
> As approach #2 I tried this (courtesy of StackOverflow):
> <code>
> import Tkinter
> 
> class App:
>     def __init__(self, root):
>         self.root = root
>         for text in ("link1", "link2", "link3"):
>             link = Tkinter.Label(text=text, foreground="#0000ff")
>             link.bind("<1>", lambda event, text=text: \
>                           self.click_link(event, text))
>             link.pack()
>     def click_link(self, event, text):
>         print "you clicked '%s'" % text
> 
> root=Tkinter.Tk()
> app = App(root)
> root.mainloop()
> </code>
> 
> and this works. Do you recommend this approach?
> 
> alessandro
> 
> 
> 
> alexxxm wrote:
>> 
>> Hi everybody,
>> I need some help to understand if tkinter is in fact the right tool to
>> use for me.
>> 
>> I intend to write a very bare-bone wiki in python. It should be able to:
>> 
>> 1) open a text file
>> 2) display the text file, with links in the form {{image.jpg}} replaced
>> by the image, and [[linkname|linkfile.txt]] replaced by linkname
>> 3) when clicking on linkname, save the current text file and open in its
>> place the file linkfile.txt
>> 
>> really, I'm not interested in nothing more.
>> 
>> Do you believe it can be easily accomplished with tkinter, or do I need
>> some more complicated widget?
>> 
>> Thanks for any help...
>> 
>> 
>> alessandro
>> 
>> 
> 
> 

--

-- 
View this message in context: http://old.nabble.com/newbie-request-for-help-tp31791699p31798134.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Kevin Buchs | 8 Jun 2011 14:29
Picon

Re: newbie request for help

Alessandro,
The suggestion on this email list has been to use the Text widget,
making use of tags. The second option you gave is going a different
direction than that by using Labels. I do not think that will take you
where you want to go. It may be that tkHyperlinkManager is the optimal
choice when implementing hyperlinked text using Text, but I am unsure.
I got the impression through brief review of the dialog here that
there was a capability native to Text that would give you what you
need.

To get tkHyperlinkManager installed here is what I would recommend. If
the command easy_install is not currently available, then you may be
able to install the corresponding "distutils" module for Python using
Fedora's package maintenance capability. Probably installing something
like "Python distutils" should do the job. Once that is done then you
should have the command easy_install. Then it is simply a matter of
using this command line: easy_install tkHyperlinkManager. Depending on
the OS setup, you may need to run that as su/sudo to have the
permissions to write into the Python packages directories.

Kevin
Kevin Walzer | 8 Jun 2011 14:55
Favicon

Re: newbie request for help

On 6/8/11 8:29 AM, Kevin Buchs wrote:

>
> To get tkHyperlinkManager installed here is what I would recommend. If
> the command easy_install is not currently available, then you may be
> able to install the corresponding "distutils" module for Python using
> Fedora's package maintenance capability. Probably installing something
> like "Python distutils" should do the job. Once that is done then you
> should have the command easy_install. Then it is simply a matter of
> using this command line: easy_install tkHyperlinkManager. Depending on
> the OS setup, you may need to run that as su/sudo to have the
> permissions to write into the Python packages directories.

tkHyperlinkManager is just a single module at effbot's site. Just copy 
the code and put it in site-packages.

--Kevin

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Cameron Laird | 8 Jun 2011 15:55

Re: newbie request for help

On Wed, Jun 08, 2011 at 08:55:39AM -0400, Kevin Walzer wrote:
			.
			.
			.
> >To get tkHyperlinkManager installed here is what I would recommend. If
> >the command easy_install is not currently available, then you may be
> >able to install the corresponding "distutils" module for Python using
> >Fedora's package maintenance capability. Probably installing something
> >like "Python distutils" should do the job. Once that is done then you
> >should have the command easy_install. Then it is simply a matter of
> >using this command line: easy_install tkHyperlinkManager. Depending on
> >the OS setup, you may need to run that as su/sudo to have the
> >permissions to write into the Python packages directories.
> 
> tkHyperlinkManager is just a single module at effbot's site. Just copy 
> the code and put it in site-packages.
			.
			.
			.
Alessandro, do you understand what Kevin is saying?  This is
important:  *it's just source*, and in this case, brief and
simply-organized source.  Alessandro, make sure you look over
<URL: http://effbot.org/zone/tkinter-text-hyperlink.htm >.

Gmane