小编use*_*531的帖子

如何使用 winapi crate 为 Windows 制作托盘图标?

我正在尝试使用 Rust 的 winapi crate 来制作一个简单的托盘图标。我之前在 C 中设法做到了,但我不能让 Rust 高兴。稍后我将包含 C 代码以显示NOTIFYICONDATA我想要使​​用的部件的哪些部分。

超基本目标:

  • 让它说的话

  • 使它成为这样的默认图标

    默认图标

    这是最简单的;稍后我可以找出其他内置图标。

  • 更新单词

  • 程序完成后删除它

链接到 Rust 的 winapi 库(带有搜索功能!)

https://docs.rs/winapi/*/x86_64-pc-windows-msvc/winapi/um/wincon/fn.GetConsoleWindow.html

我真的根本不知道 Windows API,所以对我来说都是希腊语,我只是匹配我在其他示例中找到的语法等。所以请不要跳过任何内容,因为我可能不知道隐含的是什么那里(例如使用 std:: 或其他东西)!

  • Rust 版本 1.3.1

  • winapi 板条箱版本 0.3.6

  • 视窗 10

这是我到目前为止管理的 Rust 代码(但不起作用!):

//-----Import Libraries (called crates)-----
extern crate winapi;
//-----Import Built-in Libraries (not called crates)-----
use std::process::Command; //use cmd.exe
use std::mem::size_of; //get size of stuff

fn main()
{
// to navigate calling with the winapi "crate" use the …
Run Code Online (Sandbox Code Playgroud)

winapi trayicon rust

5
推荐指数
1
解决办法
1826
查看次数

使用 Numba 的 @jit 导致数学与 Python 中使用的 Numpy 的 float32 不一致

当将 Numba@jit与 Numpy 的float32数据类型一起使用时,我收到“截断”?问题。这在很大程度上是噪音,因为它远远超过了我关心的小数点——大约第七位或第八位——但知道发生了什么以及我是否可以修复它仍然是件好事。

float32顺便说一句,我必须使用数据类型来节省内存!

这是我用作测试的代码:

import numpy as np
from test_numba import test_numba

np.random.seed(seed=1774);
number = 150;
inArray = np.round(np.float32((np.random.rand(number)-.5)*2),4); #set up a float32 with 4 decimal places
numbaGet = test_numba(inArray); #run it through
print("Get:\t"+str(numbaGet)+" Type: "+str(type(numbaGet)));
print("Want:\t"+str(np.mean(inArray))+" Type: "+str(type(np.mean(inArray)))); #compare to expected
Run Code Online (Sandbox Code Playgroud)

结合以下函数

import numpy as np
from numba import jit #, float32

@jit(nopython=True) #nopython=True, nogil=True, parallel=True, cache=True , nogil=True, parallel=True #float32(float32),
def test_numba(inArray):

    #outArray = np.float32(np.mean(inArray)); #forcing float32 did not change it …
Run Code Online (Sandbox Code Playgroud)

python numpy numba

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

标签 统计

numba ×1

numpy ×1

python ×1

rust ×1

trayicon ×1

winapi ×1