小编qed*_*qed的帖子

vimscript中的a:arg是什么意思?

这是一个例子:

function! Mynumber(arg)
  echo line(".") . " " . a:arg
endfunction
Run Code Online (Sandbox Code Playgroud)

当您使用时1,3call Mynumber(getline(".")),它将打印行号和当前缓冲区的前三行。

vim

2
推荐指数
1
解决办法
100
查看次数

在emacs python模式下自定义窗口拆分

每当我在emacs python-mode中向python控制台发送一行代码时,它都会执行下面的split-window-below,如下所示:

在此处输入图片说明

在大多数计算机屏幕上,垂直尺寸都很严格,因此更希望触发“向右分割窗口”,如下所示:

在此处输入图片说明

这可以手动完成(cx 1 cx 3 cx o cx b),但是一旦您从源文件执行了任何python代码,布局就会返回到令人讨厌的布局。

有没有一种方法可以持久地对此进行自定义?


编辑:

我已经尝试了一些方法,包括以下评论中建议的答案。到目前为止,它在.emacs“排序”工作中看起来像下面几行:

(setq split-height-threshold nil)
(setq split-width-threshold 0)
Run Code Online (Sandbox Code Playgroud)

除了它们将在下面添加一个额外的窗口:

在此处输入图片说明

emacs user-interface elisp

2
推荐指数
1
解决办法
1100
查看次数

如何使ESS默认水平分割窗口?

我总是喜欢水平分割,因为屏幕有更多的水平空间.在python模式中,我可以通过设置来实现

 (py-split-windows-on-execute-function (quote split-window-horizontally))
Run Code Online (Sandbox Code Playgroud)

在ESS模式中有类似的东西吗?

emacs r ess

2
推荐指数
1
解决办法
359
查看次数

引用类字段列表中的多个可接受的类

例如:

Mycls = setRefClass(
    "Mycls",
    fields = list(
    # this is just a mock up
    colorvec = "numeric" | "factor" | "matrix"
    )
)
Run Code Online (Sandbox Code Playgroud)

在这个例子中,我想允许colorvec数字或因子或矩阵.有没有办法做到这一点?

r reference-class

2
推荐指数
1
解决办法
293
查看次数

这个例子中是否有内存泄漏?

从官方D书:

import std.stdio;

void main()
{
    double[] slice1 = [ 1, 1, 1 ];
    double[] slice2 = [ 2, 2, 2 ];
    double[] slice3 = [ 3, 3, 3 ];

    slice2 = slice1;      // ? slice2 starts providing access
                          //   to the same elements that
                          //   slice1 provides access to

    slice3[] = slice1;    // ? the values of the elements of
                          //   slice3 change

    writeln("slice1 before: ", slice1);
    writeln("slice2 before: ", slice2);
    writeln("slice3 before: ", slice3);

    slice2[0] = 42;       // …
Run Code Online (Sandbox Code Playgroud)

memory-leaks d

2
推荐指数
1
解决办法
93
查看次数

为什么在这个D例子中到达EOF之前还有一个额外的循环?

以下是官方D书中的一个例子:

import std.stdio;
import std.string;

void main()
{
    File file = File("student_records", "w");

    file.writeln("Name  : ", "Zafer");
    file.writeln("Number: ", 123);
    file.writeln("Class : ", "1A");
    file.close();

    File file1 = File("student_records", "r");

    while (!file1.eof()) {
        string line = (chomp(file1.readln()));
        writeln("read line -> |", line);
    }
}
Run Code Online (Sandbox Code Playgroud)

如果你运行它,你会得到:

ldc2 -run file.d
read line -> |Name  : Zafer
read line -> |Number: 123
read line -> |Class : 1A
read line -> |
Run Code Online (Sandbox Code Playgroud)

请注意,打印出一个空行.现在,如果我将第三个writeln更改为write,

import std.stdio;
import std.string;

void main()
{
    File file = …
Run Code Online (Sandbox Code Playgroud)

io d

2
推荐指数
1
解决办法
79
查看次数

如何使用新语法将自定义信号连接到pyside中的插槽?

这是视频教程中的一个示例:

#!/usr/bin/env python3

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class ZeroSpinBox(QSpinBox):

    zeros = 0

    def __init__(self):
        super().__init__()
        self.valueChanged.connect(self.checkzero)

    def checkzero(self):
        if self.value() == 0:
            self.zeros += 1
            self.emit(SIGNAL("atzero(int)"), self.zeros)



class Form(QDialog):

    def __init__(self):
        super().__init__()

        dial = QDial()
        dial.setNotchesVisible(True)
        zerospinbox = ZeroSpinBox()
        layout = QHBoxLayout()
        layout.addWidget(dial)
        layout.addWidget(zerospinbox)
        self.setLayout(layout)

        dial.valueChanged.connect(zerospinbox.setValue)
        zerospinbox.valueChanged.connect(dial.setValue)
        # zerospinbox.atzero.connect(self.announce)
        self.connect(zerospinbox, SIGNAL("atzero(int)"), self.announce)

        self.setWindowTitle("Signals")

    def announce(self, zeros):
        print("zerospinbox has been at zero " + str(zeros) + " times.")



app = QApplication(sys.argv)
form …
Run Code Online (Sandbox Code Playgroud)

python user-interface signals-slots pyside

2
推荐指数
1
解决办法
3624
查看次数

cxfreeze 在带有视网膜显示屏的 macbook pro 上产生模糊的图形用户界面

我正在带有 Retina 显示屏的 macbook pro 上构建一个 pyside 应用程序,这是我的安装文件:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "sys", "PySide", "datetime", "subprocess"], "excludes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"


options = {
    'build_exe': {
        'includes': 'atexit'
    }
}

executables = [
    Executable('countdown.py', base=base)
]

setup(  name …
Run Code Online (Sandbox Code Playgroud)

python macos qt pyside cx-freeze

2
推荐指数
1
解决办法
337
查看次数

在R中全局打开和关闭调试消息?

我在考虑这样的事情:

> fx = function(x, y) {
+     if (exists("debugging")) {
+         print(x)
+         print(y)
+     }
+     x+y
+ }
> fx(1, 2)
[1] 3
> debugging = 1
> fx(2, 3)
[1] 2
[1] 3
[1] 5
Run Code Online (Sandbox Code Playgroud)

通过这种方式,您可以根据需要编写尽可能多的调试消息,当您想要关闭它们时,您就可以了

rm(debugging)
Run Code Online (Sandbox Code Playgroud)

问题是变量调试(或任何你给它的名称)可以随时被任何其他包删除或创建,这很难控制.有任何想法吗?

debugging r

2
推荐指数
1
解决办法
94
查看次数

使用javafx发送无通知的通知

您可以像这样使用JavaFx发送桌面通知(需要jdk 8u20或更高版本):

package sample;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import org.controlsfx.control.Notifications;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
//        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        Button notifyButton = new Button("Notify");
        notifyButton.setOnAction(e -> {
            Notifications.create().title("Test").text("Test Notification!").showInformation();
        });
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(notifyButton, 100, 50));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是这种方式你必须创建一个主窗口(阶段),是否可以避免这种情况?我正在寻找一种方法来发送通知,比如在bash中使用zenity:大部分代码都是非gui,但是使用一些gui元素以非常基本的方式通知用户或与用户交互.

java user-interface notifications javafx

2
推荐指数
1
解决办法
6036
查看次数