我想知道,我如何制作一个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) 我想知道如何一次获取一个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中得到答案.:)
我正在研究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)