我正在尝试更改我的Tkinter应用程序的背景颜色,但对于某些小部件,它会在边缘留下白色边框.
例如,这个:
from tkinter import *
COLOR = "black"
root = Tk()
root.config(bg=COLOR)
button = Button(text="button", bg=COLOR)
button.pack(padx=5, pady=5)
entry = Entry(bg=COLOR, fg='white')
entry.pack(padx=5, pady=5)
text = Text(bg=COLOR, fg='white')
text.pack(padx=5, pady=5)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
如何设置某些Tkinter小部件的边框颜色?
我不确定如何说出这个问题.假设我正在尝试传递tmpfiles的路径,我想捕获有不同格式的tmpfile的想法,并且每个函数仅适用于其中一个.这有效:
data FileFormat
= Spreadsheet
| Picture
| Video
deriving Show
data TmpFile = TmpFile FileFormat FilePath
deriving Show
videoPath :: TmpFile -> FilePath
videoPath (TmpFile Video p) = p
videoPath _ = error "only works on videos!"
Run Code Online (Sandbox Code Playgroud)
但是必须有更好的方法来编写没有运行时错误的权利吗?我想到了两个选择,这个:
type TmpSpreadsheet = TmpFile Spreadsheet
type TmpPicture = TmpFile Picture
type TmpVideo = TmpFile Video
videoPath :: TmpVideo -> FilePath
Run Code Online (Sandbox Code Playgroud)
或这个:
data TmpFile a = TmpFile a FilePath
deriving Show
videoPath :: TmpFile Video -> FilePath
Run Code Online (Sandbox Code Playgroud)
但显然他们没有编译.这样做的正确方法是什么?其他一些想法,没有特别吸引人:
TmpFile行格式而不是相反,所以值Video …我在我的python程序中的SPARQL查询中使用此行:
FILTER regex(?name, "%s", "i" )
Run Code Online (Sandbox Code Playgroud)
(%s用户输入的搜索文本在哪里)
我想要匹配任何一个?name或?featurename包含%s,但我似乎无法找到任何使用regex()的文档或教程.我尝试了几件似乎合理的事情:
FILTER regex((?name | ?featurename), "%s", "i" )
FILTER regex((?name || ?featurename), "%s", "i" )
FILTER regex((?name OR ?featurename), "%s", "i" )
FILTER regex((?name, ?featurename), "%s", "i" )
Run Code Online (Sandbox Code Playgroud)
而且每个人都没有 ()
FILTER regex(?name, "%s", "i" ) || regex(?featurename, "%s", "i" )
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?谢谢
更新:使用UNION工作.但我发现如果你只重复regex()部分它也会起作用:
FILTER (regex(?name, "%s", "i") || regex(?featurename, "%s", "i" ))
Run Code Online (Sandbox Code Playgroud)
这两个解决方案看起来有点混乱,因为你必须使用一个2元素的元组和相同字符串的副本来填充两个%ss.
Python 2.5不允许我使用这种语法:
try:
code_that_raises_exception()
except Exception as e:
print e
raiseRun Code Online (Sandbox Code Playgroud)
那么我该如何打印有关异常的信息呢?
谢谢
编辑:我正在为一个包含伪python解释器的程序编写一个插件.它打印print语句但根本不显示异常.
我已经为我正在开发的特定领域语言编写了两个monad.第一个是Lang,它应该包括逐行解析语言所需的所有内容.我知道我会想要读者,作家和国家,所以我使用了RWSmonad:
type LangLog = [String]
type LangState = [(String, String)]
type LangConfig = [(String, String)]
newtype Lang a = Lang { unLang :: RWS LangConfig LangLog LangState a }
deriving
( Functor
, Applicative
, Monad
, MonadReader LangConfig
, MonadWriter LangLog
, MonadState LangState
)
Run Code Online (Sandbox Code Playgroud)
第二个是Repl,它使用Haskeline与用户交互:
newtype Repl a = Repl { unRepl :: MaybeT (InputT IO) a }
deriving
( Functor
, Applicative
, Monad
, MonadIO
)
Run Code Online (Sandbox Code Playgroud)
似乎都独立工作(他们编译和我与他们在GHCI行为玩耍了),但我一直无法嵌入Lang …
在可能的情况下,Shake并行构建事物,但如果单个构建步骤本身可并行化会发生什么?例如,我正在运行BLAST命令.每个命令都比较两个物种的基因组.几个比较可以并行运行,但也有一个标志将比较分成N个块并并行运行.我是否需要选择一种方法来分割作业并坚持下去,或者我可以告诉Shake"整体使用N个线程,以及每个特定任务自己占用N个线程的方式"?
(当比较许多小细菌基因组和一些较大的真核细胞基因组时会出现这种情况)
编辑:问题可以简化为"如何判断Shake当前正在运行/排队的Shake线程数量?"
这应该很容易,但我已经尝试了一个小时.我的代码将Ansible复制.vimrc到每个主机,但是会.vim被忽略.
---
- name: vim pkg
apt: pkg=vim state=installed
- name: vim dirs
file: path=/home/jefdaj/.vim state=directory
file: path=/root/.vim state=directory
- name: vim files
# these work
copy: src=vim/vimrc dest=/home/jefdaj/.vimrc force=yes
copy: src=vim/vimrc dest=/root/.vimrc force=yes
# but these don't
copy: src=vim/bundle dest=/home/jefdaj/.vim/bundle force=yes recurse=yes
copy: src=vim/bundle dest=/root/.vim/bundle force=yes recurse=yes
Run Code Online (Sandbox Code Playgroud)
那是怎么回事?我在路径上尝试了很多变化.它发生在Debian上的ansible 1.5.5中,也发生在当前的git版本上.
编辑:现在它尝试复制,但总是失败,同时创建一个错误的多个目录之一 OSError: [Errno 2] No such file or directory: '/root/.vim/bundle/bundle/vim-easymotion/autoload/vital/Over'
我正在编写一个C库,它将特定于域的数据解析并序列化为RDF/XML.解析文件并再次将其写回后,我希望能够检查内容是否未更改.
我可以再次解析所有内容,将其写为NTriples,并逐行比较两个Ntriples文件但是必须有更好的方法吗?
谢谢!
我正在用Python编写Tkinter GUI.它有一个用于在其下方搜索结果ListBox的条目.ListBox还有一个滚动条.如何使用鼠标和箭头键滚动才能在ListBox中工作,而无需将焦点从搜索字段中移开?IE我希望用户能够键入搜索,滚动并继续键入,而无需在窗口小部件之间来回切换.谢谢
我正在制作一个动态生成的实验室实验图.这就是现在的样子:

理想情况下,我希望蓝色节点在顶部排成一行,这样无论导致它们的历史有多大,当前的实验都是可见的.有没有办法在GraphViz中做到这一点?我正在使用PyDot,但也打开手动编辑点图.
我在这里发现了一个可能相关的问题,是否会将它们放在子图帮助中?
编辑:这是当前的点代码.
digraph depgraph {
rankdir=BT;
dpi=400;
"/experiments/2013-12-19_planmacro" [shape=rectangle, href="/experiments/2013-12-19_planmacro", fontsize=11, color="#61BD4D", label="Plan 96-well plate montage macro", penwidth=2];
"/experiments/2013-07-01_fluoromax" [shape=rectangle, href="/experiments/2013-07-01_fluoromax", fontsize=11, color="#cccccc", label="Testing OD730", penwidth=2];
"/experiments/2013-06-12_cloning" [shape=rectangle, href="/experiments/2013-06-12_cloning", fontsize=11, color="#cccccc", label="Re-cloning TFs", penwidth=2];
"/experiments/2014-01-02_startwt" [shape=rectangle, href="/experiments/2014-01-02_startwt", fontsize=11, color="#61BD4D", label="Start WT Cultures", penwidth=2];
"/experiments/2013-06-04_learning" [shape=rectangle, href="/experiments/2013-06-04_learning", fontsize=11, color="#cccccc", label="Learning R + Bioconductor", penwidth=2];
"/experiments/2013-07-xx_induction" [shape=rectangle, href="/experiments/2013-07-xx_induction", fontsize=11, color="#61BD4D", label="induction again", penwidth=2];
"/experiments/2013-06-04_bg11" [shape=rectangle, href="/experiments/2013-06-04_bg11", fontsize=11, color="#cccccc", label="BG11 Media + Plates", penwidth=2];
"/experiments/2013-06-13_chipseq" [shape=rectangle, href="/experiments/2013-06-13_chipseq", fontsize=11, color="#61BD4D", …Run Code Online (Sandbox Code Playgroud)