小编Aqu*_*ing的帖子

Tkinter Menu命令以参数为目标函数?

我想知道,我如何制作一个Tkinter(在Python中)菜单,该菜单以参数为目标,例如foo("what")

def foo(arg):
    print "Foo, %s." % arg

popup = Menu()
popup.add_command(label="Spam!", command=foo("spam")) # Doesn't work.
popup.add_command(label="Turkey!", command=foo("turkey")) # Doesn't work.
popup.post(50, 50)
Run Code Online (Sandbox Code Playgroud)

python command tk-toolkit tkinter

3
推荐指数
2
解决办法
3375
查看次数

获取与tkinter文本小部件关联的所有标签?

我想知道如何一次获取一个Text小部件中的所有标签.所以让我们说这是我的内容:


(假设每次我放("标签",文本),我的意思是文本有标签标签.)

("keyword", print) ("string", "Hello world!")
("keyword", print) ("string", "You are"), ("support", raw_input())


现在让我们说这是我的每个标签的代码:

self.text.tag_config('keyword', foreground="orange")
self.text.tag_config('operator', foreground="blue")
self.text.tag_config('number', foreground="red")
self.text.tag_config('string', foreground="red")
self.text.tag_config('support', foreground="blue")
self.text.tag_config('comment', foreground="violet")
self.text.tag_config('error', background="red")
self.text.tag_config('warning', background="yellow")
Run Code Online (Sandbox Code Playgroud)

现在,是否有任何函数/常量只能获取我的字符串中当前的标签?它会报告['keyword', 'string', 'support'].

(注意:大多数情况下我只是想知道这个因为我很好奇.如果不存在,那就不是世界末日.:P)

注意:第二个代码块是用Python编写的,我希望在Python中得到答案.:)

python tk-toolkit tkinter

1
推荐指数
1
解决办法
2050
查看次数

如何制作带编号的段落(HTML5 / CSS3)

我正在研究HTML5中的QuickBASIC 4.5指南,并且一直在使它起作用,但是我想知道如何对我的代码行进行编号(或停止文本包装)。现在,我的代码如下所示:

1. PRINT "Hello World!"
2. INPUT "Who are you? ", myName$
3. PRINT "Hello, " + myName$
4-7. (Stuff)
8. PRINT "Did you know that " + STR$(num1%) + " + " + STR$(num2%) + " = " + STR(total%) + "?"
Run Code Online (Sandbox Code Playgroud)

因此,您将看到如何在其中滚动代码时如何使用滚动条?我想拥有它,但是我还需要知道如何使编号自动..现在它在我的<p>的..外观中:

<p class="code">1. PRINT "Hello World!" <br />
2. INPUT "Who are you? ", myName$ <br />
(...)</p>
Run Code Online (Sandbox Code Playgroud)

我希望能够做一些事情,也许在CSS部分中,可以进行滚动,最好是数字。如果您能解决任何一个问题,请告诉我。.我还查看了CSS3,发现没有在任何主流浏览器上使用text-wrap属性(到目前为止),所以也许我不能这样做,但是然后再次滚动将对此有所帮助。:P


只要有人想知道,这就是代码类的CSS代码:

 .code {
    font-family: Courier;
    margin-left: 35px;
    margin-right: 35px;
    background: #F0EFE9;
    border-style: inset;
    border-width: 5px;
    resize: vertical; …
Run Code Online (Sandbox Code Playgroud)

html css html5 css3

0
推荐指数
1
解决办法
1992
查看次数

标签 统计

python ×2

tk-toolkit ×2

tkinter ×2

command ×1

css ×1

css3 ×1

html ×1

html5 ×1