当前位置: 首页>>代码示例>>Python>>正文


Python Gui.add_element方法代码示例

本文整理汇总了Python中gui.Gui.add_element方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.add_element方法的具体用法?Python Gui.add_element怎么用?Python Gui.add_element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gui.Gui的用法示例。


在下文中一共展示了Gui.add_element方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Recorder

# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import add_element [as 别名]
class Recorder(object):
    def __init__(self, num_frames=settings.BUFFER_LENGTH, limit_fps=None):
        if SHOW_WINDOW:
            cv2.namedWindow("preview")

        self.last_video_frame = None

        self.num_frames = num_frames
        self.frames = [None] * self.num_frames
        self.current_jpg_frame = None
        self.buffer_index = 0

        self.keep_running = True
        self.frame_rate = 0
        self.last_frame = time.time()
        self.limit_fps = limit_fps

        self.api = Api(self)
        self.api_lock = threading.Lock()

        self.motion_detector = MotionDetector()

        self.ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
        self.encoding_subprocesses = []
        self.last_serial_command = None
        self.encoding_started = datetime.datetime.now()

        if settings.UI_ENABLED:
            if settings.UI_RESOLUTION:
                self.gui = Gui(width=settings.UI_RESOLUTION[0], height=settings.UI_RESOLUTION[1])
            else:
                self.gui = Gui()

            # Test recording button
            base_state = (
                self.gui.recording_button,
                [150, 150, 90],
                {}
            )
            hover_state = (
                self.gui.recording_button,
                [150, 150, 90],
                {'highlight':True}
            )
            active_state = (
                self.gui.recording_button,
                [150, 150, 90],
                {'active':True}
            )
            callback = lambda: self.log("triggered")#self.calibrate

            self.gui.add_element(element_id=2, base_state=base_state, hover_state=hover_state, active_state=active_state, callback=callback)

            base_state = (
                self.gui.button,
                [100, 100, 200, 30, 'Yeah buttons Baby'],
                {}
            )
            hover_state = (
                self.gui.button,
                [98, 98, 204, 34, 'Yeah buttons Baby'],
               {'fill_color': Color(0.95, 0.95, 0.95), 'bold':True}
            )
            active_state = (
                self.gui.button,
                [98, 98, 204, 34, 'Yeah buttons Baby'],
                {'fill_color': Color(0.9, 0.9, 0.9), 'bold': True}
            )
            callback = self.calibrate
            #self.gui.add_element(element_id=1, base_state=base_state, hover_state=hover_state, active_state=active_state, callback=callback)

            self.gui.update()
        else:
            self.gui = None

    def start_encoding_animation(self):
        self.encoding_started = datetime.datetime.now()
        self.last_serial_command = 'f'
        self.ser.write('f')

    def stop_encoding_animation(self):
        if self.last_serial_command != 's':
            self.last_serial_command = 's'
            self.ser.write('s')

    def log(self, text):
        print text

    def array(self, image):
        return numpy.asarray(image[:,:])

    def threshold(self, grayscale_array, low, high, value=1):
        grayscale_array = value * numpy.logical_and(grayscale_array >= low, grayscale_array < high)
        return grayscale_array

    def update_frame_rate(self):
        # FIXME: save some kind of average for the fps
        self.frame_diff = time.time() - self.last_frame

        if self.limit_fps:
#.........这里部分代码省略.........
开发者ID:kirberich,项目名称:poolrecorder,代码行数:103,代码来源:recorder.py


注:本文中的gui.Gui.add_element方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。