我正在尝试在 frame1 中显示我的实时视频。我想知道为什么它不像在 cv2.imshow 中那样工作,我已经写了 frame1。任何人都可以帮我吗?
我的框架/窗口代码:
from tkinter import Tk, Text, BOTH, W, N, E, S
from tkinter.ttk import Frame, Button, Label, Style
from tkinter import *
# from tkinter import *
class Example(Frame):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.master.title("Nav Track app")
self.pack(fill=BOTH, expand=True)
self.style = Style()
self.style.theme_use("clam")
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(4, weight=1)
self.rowconfigure(8, pad=7)
lbl = Label(self, text="Keep your eyes on screen")
lbl.grid(sticky=W, pady=4, padx=5)
frame1 = Frame(self, bg="")
frame1.grid(row=1, column=0, columnspan=2, rowspan=6, padx=8, sticky=E + …
Run Code Online (Sandbox Code Playgroud) 我正在尝试Point<T>
为小尺寸实现通用类型。
为了实现这一点,我编写了一个宏,它采用新类型的名称和点的维度(因为,据我所知,Rust 不允许数字泛型)。
macro_rules! define_point {
($type_name: ident, $dimension: expr) => {
pub struct $type_name<T> {
coords: [T; $dimension]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我像这样使用它:
define_point!(Point2, 2);
define_point!(Point3, 3);
Run Code Online (Sandbox Code Playgroud)
这工作正常。我还在Index
这个宏中在我的 Point 类型上实现了trait 来直接访问坐标。
现在我想要一些方便的函数来访问我的点的坐标,如下所示:p.x()
,p.y()
或者p.z()
取决于维度。
为此,我有另一个宏:
macro_rules! impl_point_accessors {
($type_name: ident, $coord_name: ident, $coord_index: expr) => {
impl<T> $type_name<T> {
pub fn $coord_name(&self) -> T {
&self[$coord_index]
}
}
};
($type_name: ident, $coord_name: ident, $coord_index: expr, $($extra_coord_name: ident, $extra_coord_index: expr),+) => {
impl_point_accessors!($type_name, …
Run Code Online (Sandbox Code Playgroud)