我知道Tkinter不是那么现代,不太酷,也许更好地使用PyQt等.
但有趣的是,Tkinter在Ubuntu(Linux)中看起来并不那么难看.看起来使用内置主题编译的python的Tkinter的brew版本(在OS X中)看起来很好:

但是Ubuntu的Tkinter让我哭了:

我已经读过,为了好主题,我需要使用ttk,但我不确切知道如何.我的代码如下:
from Tkinter import *
class App():
def __init__(self, master):
frame = Frame(master)
frame.pack()
master.title("Just my example")
self.label = Label(frame, text="Type very long text:")
self.entry = Entry(frame)
self.button = Button(frame,
text="Quit", fg="red", width=20,
command=frame.quit)
self.slogan = Button(frame,
text="Hello", width=20,
command=self.write_slogan)
self.label.grid(row=0, column=0)
self.entry.grid(row=0, column=1)
self.slogan.grid(row=1, column=0)
self.button.grid(row=1, column=1)
def write_slogan(self):
print "Tkinter is easy to use!"
root = Tk()
app = App(root)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
如何应用标准的ubuntu主题或至少更好的主题?
谢谢.
我想尝试OVS(软件Linux交换机)http://openvswitch.org/和我的LXC容器,Ubuntu作为主机和访客.所以我安装了它:
# apt-get install openvswitch-switch
Run Code Online (Sandbox Code Playgroud)
根据此文档进行配置https://infologs.wordpress.com/2015/06/19/how-to-attach-lxc-container-to-ovs-openvswitch/
创建测试容器:
# lxc-create -t ubuntu -n veth03-ovs -- -r trusty
Run Code Online (Sandbox Code Playgroud)创建ovs桥并为其分配IP:
# ovs-vsctl add-br switch0
# ip add add 192.168.100.1/24 dev switch0
Run Code Online (Sandbox Code Playgroud)让它成为新的网络192.168.100.0/24和switch0(根据我的理解)将是第一个地址(网关).
看起来很好:
# ip a
...
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
link/ether 52:9d:e1:60:1d:56 brd ff:ff:ff:ff:ff:ff
5: switch0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default
link/ether 16:63:eb:47:13:41 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.1/24 scope global switch0
valid_lft forever preferred_lft forever
Run Code Online (Sandbox Code Playgroud)
桥接接口状态:
# ovs-vsctl show …Run Code Online (Sandbox Code Playgroud) 我有一个问题.我有在Tkinter上写过的程序.
import Tkinter as tk
import ttk
def about_window():
print(root.child_window)
if not root.child_window:
top2 = tk.Toplevel(root)
top2.title("About")
top2.resizable(0,0)
explanation = "This program is my test program"
ttk.Label(top2,justify=tk.LEFT,text=explanation).pack(padx=5,pady=2)
ttk.Button(top2,text='OK',width=10,command=top2.destroy).pack(pady=8)
root = tk.Tk()
root.resizable(0,0)
root.child_window = None
#print(root.child_window)
root.style = ttk.Style()
# ('clam', 'alt', 'default', 'classic')
root.style.theme_use("clam")
menu = tk.Menu(root)
root.config(menu=menu)
fm = tk.Menu(menu, tearoff=0)
menu.add_cascade(label="Settings",menu=fm)
fm.add_command(label="Preferances")
hm = tk.Menu(menu, tearoff=0)
menu.add_cascade(label="Help",menu=hm)
hm.add_command(label="About", command=about_window)
hm.add_command(label="Exit",command=root.quit)
#
tk.mainloop()
Run Code Online (Sandbox Code Playgroud)
所以我可以点击"关于"标签,然后会看到窗口:

但是在Tkinter中是否可以禁用同一窗口的任何下一次启动?

我试过这个/sf/answers/1742076451/但没有成功.
我想在提交GitLab(git面板)后自动开始构建Jenkins.
所以我设置了这个插件https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin并配置它:
然后我将webhook添加到GitLab:
现在我可以通过http-request(例如来自浏览器)启动Jenkins任务,但是没有来自Gitlab的成功(通过按钮"Test Hook").为什么?
GitLab的webhook与http请求不一样吗?
由于Jenkins的标准git插件的限制,我可以通过https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin自动发布这个Jenkins工作但不能.
目前,我正在处理Web应用程序的历史记录页面。应用程序(在Flask上编写)将历史记录保存在sqlite中,并通过SQLAlchemy与db一起使用。它看起来如下:
如您在最新单元格中看到的,有很多文本数据。
更重要的是,我想在历史页面上列出此数据。现在,我的代码如下所示:
{% extends "_base.html" %}
{% block content %}
<div id="div1" class="col-md-3">
<p><a href='/' class='btn btn-primary btn-block' role='button'><span class='glyphicon glyphicon-chevron-left'></span> Back</a></p>
</div>
<div class="bs-example col-md-12">
<br>
<table class="table table-hover">
<thead>
<tr>
<th>Task ID</th>
<th>Date</th>
<th>Host</th>
<th>User</th>
<th>Playbook</th>
<th>Log</th>
</tr>
</thead>
<tbody>
{% for history in histories %}
<tr>
<td>{{ history.task_id }}</td>
<td>{{ history.date.strftime("%d/%m/%y %H:%M") }} UTC</td>
<td>{{ history.hostname }}</td>
<td>{{ history.username }}</td>
<td>{{ history.playbook }}</td>
<td>{{ history.output }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %} …Run Code Online (Sandbox Code Playgroud) 是否可以像这样导入 LDIF
dn: cn=vpupkin,cn=people,ou=company,dc=domain,dc=com
c: UA
cn: vpupkin
employeetype: Indoor Front-end developer
gidnumber: 500
givenname: Vasya
homedirectory: /home/vpupkin
host: example.com
l: Kyiv
loginshell: /bin/bash
mail: vpupkin@domain.com
o: Microsoft
objectclass: inetOrgPerson
objectclass: posixAccount
objectclass: top
objectclass: shadowAccount
objectclass: ldapPublicKey
objectclass: extensibleObject
labeleduri: skype://test
sn: Pupkin
sshpublickey: ssh-rsa key
st: Trudova, 15
telephonenumber: 7777777777
uid: vpupkin
uidnumber: 1000
userpassword: {SHA}fEqNCco3Yq9h5ZUglD3CZJT4lBs=
Run Code Online (Sandbox Code Playgroud)
使用 python-ldap 库(http://www.python-ldap.org/)?
是的,我可以以这种方式向 LDAP 添加新记录http://www.grotan.com/ldap/python-ldap-samples.html#add但我不确定这样的文本 ldif 文件。
附注。完整答案在这里http://pastebin.com/eQU7xBfj
我用下一个方式在最终剧本中描述了我的标签:
roles:
- { role: common, tags: ["common"] }
- { role: redis, tags: ["redis"] }
Run Code Online (Sandbox Code Playgroud)
除了在同一剧本中我有前/后任务部分:
pre_tasks:
- include: pre_post_tasks/create_lock.yml
post_tasks:
- include: pre_post_tasks/remove_lock.yml
Run Code Online (Sandbox Code Playgroud)
问题是前/后任务仅在包含所有标签的情况下启动(无标签参数):
ansible-playbook -vv -l host -i inventory/dev --extra-vars '@temporary/additional_inventory' playbook.yml
Run Code Online (Sandbox Code Playgroud)
并且不要使用标签:
ansible-playbook -vv -l host -i inventory/dev --extra-vars '@temporary/additional_inventory' playbook.yml --tags "redis"
Run Code Online (Sandbox Code Playgroud)
为什么?它是按设计的吗?怎么避免这个?我想在所有情况下执行前/后任务.