我画了一条线tkinter.Canvas,现在我想移动一端。这可能itemconfig吗,例如与?
import tkinter
tk = tkinter.Tk()
canvas = tkinter.Canvas(tk)
canvas.pack()
line = canvas.create_line(0, 0, 100, 100)
tk.mainloop()
Run Code Online (Sandbox Code Playgroud)
现在我想将行尾更改为75, 25. 有没有更好的方法来删除该行并创建一个新行?
我想为项目中的所有对话框设置滚动策略。我测试了一个对话框的行为
@Component({
selector: 'app-main',
templateUrl: './main.component.html',
styleUrls: ['./main.component.scss']
})
export class MainComponent {
constructor(public dialog: MatDialog, private overlay: Overlay) {}
showHelpDialog() {
const dialogConfig = new MatDialogConfig();
dialogConfig.scrollStrategy = this.overlay.scrollStrategies.noop();
this.dialog.open(DialogComponent, dialogConfig);
}
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作。在Angular Material上,我读到了有关注入令牌的内容MAT_DIALOG_SCROLL_STRATEGY。它可能应该是这样的:
@NgModule({
/* ... */
providers: [
{
provide: MAT_DIALOG_SCROLL_STRATEGY,
useValue: /* ??? */
}
]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
但我不知道如何设置该值。滚动策略可以在@angular/cdk/overlay/scroll/scroll-stratey-options.ts类中找到ScrollStrategyOptions,但成员函数是非静态的,我无法实例化 的对象ScrollStrategyOptions,因为我没有必要的构造函数参数。所以基本上我正在寻找一种方法来做类似的事情
@NgModule({
/* ... */
providers: [
{
provide: MAT_DIALOG_SCROLL_STRATEGY,
useValue: ScrollStrategyOptions.noop() …Run Code Online (Sandbox Code Playgroud) 我正在学习析构函数,复制和克隆,因此我编写了这段代码.一切都很清楚,但一行.它是第5行中的析构函数Destructor myClass1 0x28fec0.它来自哪里,为什么叫它?
控制台输出:
Constructor myClass1 0x28fe98
Constructor myClass2 0x28fe88
Constructor myClass3 0x28fe78
operator=
Destructor myClass1 0x28fec0
clone
Constructor clone 0x28fed0
operator=
Destructor clone 0x28fed0
Destructor myClass3 0x28fe78
Destructor myClass2 0x28fe88
Destructor myClass1 0x28fe98
Run Code Online (Sandbox Code Playgroud)
main.cpp中:
#include <iostream>
#include "MyClass.h"
int main(){
MyClass myClass1("myClass1"), myClass2("myClass2"), myClass3("myClass3");
myClass2 = myClass1;
myClass3 = myClass1.clone();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
MyClass.h:
#ifndef MYCLASS_H
#define MYCLASS_H
#include <iostream>
#include <string>
class MyClass{
private:
int *values;
int size;
int *copies;
std::string name;
public:
MyClass();
MyClass(std::string name); …Run Code Online (Sandbox Code Playgroud) 我的项目目录中有一个自己的模块,我将其导入到我的代码中.
main.py:
from my_module import Test
print(Test.test())
Run Code Online (Sandbox Code Playgroud)
my_module.py:
class Test:
@staticmethod
def test():
return '123'
Run Code Online (Sandbox Code Playgroud)
在PyCharm中运行代码没有问题.但是当我尝试"在控制台中执行选择"时,我得到了
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.4\helpers\pydev\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'my_module'
如何在PyCharm控制台中导入自己的模块?
在我们的代码库中,我们有一个模板
template<typename DT>
void f(const DT&) {}
Run Code Online (Sandbox Code Playgroud)
有一些专业。一个专业是
template<>
void f(const int*&) {}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用它时,clang 给了我
error: no function template matches function template specialization 'f'
void f(const int*&) {}
note: candidate template ignored: cannot deduce a type for 'DT' that would make 'const DT' equal 'const int *'
void f(const DT&) {}
Run Code Online (Sandbox Code Playgroud)
示例代码是
template<typename DT>
void f(const DT&) {}
template<>
void f(const int*&) {}
int main() {
const int *a = nullptr;
f(a);
}
Run Code Online (Sandbox Code Playgroud)
为什么不能将此模板专门用于指针类型?我怎样才能达到专业化?
我有一个对象数组,如下所示:
[
{ "FirstName": "John",
"LastName": "Parker",
"Age": "23",
"Cat": "23g",
"SOP": "Active"
},
{ "FirstName": "Rose",
"LastName": "Jackson",
"Age": "44",
"Cat": "44g",
"SOP": "InActive"
}
]
Run Code Online (Sandbox Code Playgroud)
我正在使用excel4node创建对象的数据并将其写入 excel
async generateExclReport(req, res) {
try {
var wb = new xl.Workbook();
// Add Worksheets to the workbook
var ws = wb.addWorksheet('Report');
ws.cell(1, 1).string('FirstName');
ws.cell(1, 2).string('LastName');
ws.cell(1, 3).string('Age');
ws.cell(1, 4).string('Cat');
ws.cell(1, 5).string('SOP');
var fileName = "Report" + Date.now().toString() + '.xlsx';
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.setHeader("Content-Disposition", "attachment; filename=" + fileName);
wb.write(fileName, res);
} …Run Code Online (Sandbox Code Playgroud) 是否总是在 C++ 中class并且struct仅在默认访问说明符上有所不同?或者在某些早期版本中,C++struct更像 C struct?
如果元素在数组中,函数应该返回元素的索引,如果元素不在数组中,则返回 -1。
int function(int a[], int length, int number)
{
for(int i=0; i<length; i++)
{
if(a[i]==number)
return i;
else
return -1;
}
}
Run Code Online (Sandbox Code Playgroud)