English 中文(简体)
Tkinter文本中的超链接植被?
原标题:Hyperlink in Tkinter Text widget?

我正在重新设计我目前软件项目的一部分,希望使用hyperlinks而不是Buttons。 我确实不想使用<条码>Text植被,但我会发现这一点。 不管怎么说,我发现了这方面的一个例子,但还是不断发现这一错误:

TclError: bitmap "blue" not defined

在我加入这一法典时(使用IDLE)

hyperlink = tkHyperlinkManager.HyperlinkManager(text)

该单元的代码为:here,该笔文字的代码为here

没有人有什么想法?

给出问题的那部分内容是foreground="blue”,在Tkinter被称作“肤色”的那部分是没有的?

最佳回答

如果你不希望使用一纸张,你就不需要。 另一种办法是使用标签,对烟.点进行点击。 尽管它贴上了标签,但它仍然对事件作出反应。

例如:

import tkinter as tk

class App:
    def __init__(self, root):
        self.root = root
        for text in ("link1", "link2", "link3"):
            link = tk.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 = tk.Tk()
app = App(root)
root.mainloop()

如果你想要的话,你可以找到并增加附加约束力的<代码><Enter>和<Leave>事件,以便你能够改变使用者的眼光。 当然,如果你选择的话,你可以改变行文。

Tk是个好奇的工具包,它使你能够仅就你们想要的东西做事。 你们只需要看一看get子,不要把它看作是一套预先制造的围墙和门,而更像是一堆 l、砖和迫击炮。

问题回答

"blue> should be actual be approved (因为您重新登在Windows, Tkinter应当使用其已建的彩色名称表——这或许是一种在X11上而不是在Windows上的系统错误配置);因此,这是一个棘手的问题(可能是Tkinter错config......)。 如果你使用<代码>foreground=”#00F",那么情况如何? 这并没有解释这一问题,但可能让你围绕该问题开展工作,至少......





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签