我正在尝试创建一个按钮,其中包括一个与左边对齐的图像和一个与右边对齐的文本.我只想通过参数"text"更改文本,而不是通过修改整个图像.这有可能吗?
这是一个简单的例子,我的意思.
http://img651.imageshack.us/img651/3776/previewrv.png
希望我解释得很好
谢谢
假设我有一个测试,如下所示:
import pytest
import copy
@pytest.fixture(scope='session')
def session_tool(request):
tool = request.config.tool
# Build is the critical part and may fail, raising an exception
tool.build()
return tool
@pytest.fixture
def tool(session_tool):
return copy.deepcopy(session_tool)
def test_tool(tool, args):
assert tool.run(args) == 0
Run Code Online (Sandbox Code Playgroud)
它构建一个会话范围的工具,然后为每个测试用例创建它的副本。但是,当构建失败时,session_tool下一个测试用例将再次执行固定装置,该测试用例再次失败......直到所有测试用例都失败。由于测试用例较多,因此需要一些时间才能完成该过程。
有没有办法告诉 pytest 跳过session_fixture第一次尝试构建失败后使用的所有测试?
我想知道如何用一个"绑定"绑定多个小部件.
例如:
我有三个按钮,我想在悬停后改变颜色.
from Tkinter import *
def SetColor(event):
event.widget.config(bg="red")
return
def ReturnColor(event):
event.widget.config(bg="white")
return
root = Tk()
B1 = Button(root,text="Button 1", bg="white")
B1.pack()
B2 = Button(root, text="Button2", bg="white")
B2.pack()
B3 = Button(root, text= "Button 3", bg="white")
B3.pack()
B1.bind("<Enter>",SetColor)
B2.bind("<Enter>",SetColor)
B3.bind("<Enter>",SetColor)
B1.bind("<Leave>",ReturnColor)
B2.bind("<Leave>",ReturnColor)
B3.bind("<Leave>",ReturnColor)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
我的目标是只有两个绑定(用于"Enter"和"Leave"事件)而不是上面的六个.
谢谢你的任何想法