我一直在学习开发Gtk,大多数在线示例都建议使用Gtk.stock图标.但是,它的使用产生警告,它已被弃用,我找不到这些图标的替代品.
代码示例如下:
open_button:Gtk.ToolButton = new ToolButton.from_stock(Stock.OPEN)
open_button.clicked.connect (openfile)
new_button:Gtk.ToolButton = new ToolButton.from_stock(Stock.NEW)
new_button.clicked.connect (createNew)
save_button:Gtk.ToolButton = new ToolButton.from_stock(Stock.SAVE)
save_button.clicked.connect (saveFile)
Run Code Online (Sandbox Code Playgroud)
这会产生错误:
/tmp/text_editor-exercise_7_1.vala.c:258:2: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations]
_tmp1_ = (GtkToolButton*) gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
Run Code Online (Sandbox Code Playgroud)
哪个是替代方案以及它在上面的代码中的外观?
我想用 knitr 生成一个 Latex 文档,但它不允许我将图形的标签更改为我的语言。编码:
```{r rstudio, echo = FALSE, fig.cap = "RStudio IDE", fig.margin = T}
plot(pressure)
```
Run Code Online (Sandbox Code Playgroud)
这会产生:
但是我希望标题标签读取 Figura: (portuguese) 而不是 Figure: 。我添加了变量lang: pt-br,它在我用 调用它时进行了纠正\@ref(fig:rstudio),但不修复图形标签。
我试图在命令行中打印出一个包含JSON对象的变量的内容,就像在代码中一样:
#! /usr/bin/swift
import Glibc
import Foundation
let albert_op = ProcessInfo.processInfo.environment["ALBERT_OP"]!
if albert_op == "METADATA" {
let metadata = [
["iid": "org.albert.extension.external/v2.0",
"name": "Tomboy",
"version": "0.1",
"author": "Will Timpson",
"dependencies": ["tomboy", "python-pydbus"],
"trigger": "tb "]
]
print(metadata))
}
exit(0)
Run Code Online (Sandbox Code Playgroud)
然而,打印出:
[["trigger": "tb ", "name": "Tomboy", "iid": "org.albert.extension.external/v2.0", "dependencies": ["tomboy", "python-pydbus"], "version": "0.1", "author": "Will Timpson"]]
Run Code Online (Sandbox Code Playgroud)
这是无效的,我期待的是:
{"version": "0.1", "author": "Will Timpson", "iid": "org.albert.extension.external/v2.0", "trigger": "tb ", "dependencies": ["tomboy", "python-pydbus"], "name": "Tomboy"}
Run Code Online (Sandbox Code Playgroud)
我试图将估计值和 CI 的值分成三列,以便包含类型 99.99[-99.9,99.9] 的信息的列转换为三个单独的列。
请考虑数据:
out <-
structure(list(name = c("total_gray_vol_0_to_psychosis_24", "total_gray_vol_24_to_psychosis_48",
"psychosis_0_to_total_gray_vol_24", "psychosis_24_to_total_gray_vol_48"
), Std.Estimate = c(0.304045656442265, 1.48352171485462, 0.673583361513608,
0.703098685562618), Std.SE = c(0.239964279466103, 2.72428816136731,
0.112111316151443, 0.14890331153936), CI = c("0.3 [-0.17, 0.77]",
"1.48 [-3.86, 6.82]", "0.67 [0.45, 0.89]", "0.7 [0.41, 0.99]"
)), class = "data.frame", row.names = c(NA, -4L))
Run Code Online (Sandbox Code Playgroud)
我得到的最远的是提取第一个数字:
library(stringr)
str_match(out$CI, pattern= "([[0-9]+]*)([[0-9]+]*)([[0-9]+]*)")
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为它只返回第一个数字,并且由于某种原因返回四列。
我想将新行添加到系统中现有的 csv 文件中。下面是 MWE。首先,创建一个数据表并将其写入文件:
date <- "2017-08-01"
investPercent<- 20
expenses <- 20000
savings <- 30000
low <- 10
high <- 20
objective <-19000
data<-data.frame(date, investPercent, expenses, savings, low, high, objective)
write.csv(data, file="./finances.csv", row.names = F)
Run Code Online (Sandbox Code Playgroud)
现在执行相反的操作并从现有文件中读取,修改变量并尝试将修改后的数据表附加到现有文件中:
data<-read.csv("./finances.csv",stringsAsFactors = FALSE)
date <- Sys.Date()
investPercent<- 99
expenses <- 29999
savings <- 39999
low <- 19
high <- 29
objective <-19999
dataplus<- data.frame(date, investPercent, expenses, savings, low, high, objective)
write.csv(dataplus, file="./finances.csv", append = T)
Run Code Online (Sandbox Code Playgroud)
这不起作用,finances.csv文件被完全重写,并且追加选项似乎仅在文件是字符串时才起作用。
尽管 Gtk.table 已被弃用,但我用它得到了更好的结果,而不是推荐的 Gtk.Grid。
这可能是我的错误,但我找不到问题所在。
我的目标是创建一个 Gtk 窗口,顶部有一个笔记本,下面有两个按钮。这些按钮应水平对齐。
我的带有表格的代码按预期工作:
uses Gtk
class TestWindow : Window
init
// General characteristics of the window
title = "Gtk Containers"
default_height = 250
default_width = 250
window_position = WindowPosition.CENTER
destroy.connect(Gtk.main_quit)
// Now building the notebook
var notebook = new Gtk.Notebook()
var label1 = new Gtk.Label("Page one")
var label2 = new Gtk.Label("Page two")
var child1 = new Gtk.Label("Go to page 2 for the answer")
var child2 = new Gtk.Label("Go to page 1 for the answer") …Run Code Online (Sandbox Code Playgroud) Is it possible to reproduce a meta-analysis type of flowchart as the one in the picture below using any R tool?

My attempt was using mermaid:
diagram = "
graph LR
subgraph Screening
b1-->b2
end
subgraph Eligibility
c1-->c2
end
subgraph Included
d1-->d2
end
subgraph Identification
a1-->a2
end
"
mermaid(diagram)
Run Code Online (Sandbox Code Playgroud)
Which generated:
But I cannot find a way of connect the nodes accross the subgraphs.
Is there another tool better fitting to this kind of job? I am thinking on …
简单的谷歌搜索就会引导我找到代码:
let fileManager = FileManager.defaultManager()
// Get current directory path
let path = fileManager.currentDirectoryPath
print(path)
Run Code Online (Sandbox Code Playgroud)
但是,defaultManager 在 Linux 中似乎无法访问。