从 examples/basics/visuals/graphy.py 开始,我尝试显示直方图但失败了:
from vispy import app, visuals
import wx
import numpy as np
class snrHistogram(app.Canvas):
def __init__(self, *args, **kwargs):
app.Canvas.__init__(self, title='histogram fail',
keys="interactive", size=(600, 600))
self.snr_hist = visuals.HistogramVisual(np.arange(256), bins=4, color='r', orientation='v')
self.label = visuals.TextVisual("hi", color='blue', pos=[50, 50, 0])
self.configure_transforms()
self.show()
def configure_transforms(self):
vp = (0, 0, self.physical_size[0], self.physical_size[1])
self.context.set_viewport(*vp)
self.label.transforms.configure(canvas=self, viewport=vp)
self.snr_hist.transforms.configure(canvas=self, viewport=vp)
def on_resize(self, event):
self.configure_transforms()
def on_mouse_wheel(self, event):
self.update()
def on_draw(self, event):
self.snr_hist.draw()
self.label.draw()
self.update()
def on_close(self, event):
self.close()
if __name__ == '__main__':
s = snrHistogram()
app.run() …
Run Code Online (Sandbox Code Playgroud) 我有一个客户端和服务器设置为彼此交谈.但每次我尝试回应客户端时套接字似乎已断开连接.大部分代码都是根据yolinux上的套接字教程改编的.另外,我是通过ssh远程运行的.
#include <cerrno>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <netdb.h>
#include <sys/select.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <errno.h>
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include <string>
#include <sstream>
using namespace std;
main(int argc, char *argv[])
{
if (argc != 3) {
cout << "exiting\n";
exit(EXIT_FAILURE);
}
struct sockaddr_in remoteSocketInfo;
struct hostent *hPtr;
int socketHandle;
char *remoteHost = argv[1];
int portNumber = atoi(argv[2]);
cout << "Welcome!\n";
// create socket …
Run Code Online (Sandbox Code Playgroud)