def __OnTick(self, evt):
        s = 0
        newList = []

        for frame, height, tmo in self.displayedFrames:
            if frame.GetParent():
                dx, dy = frame.GetParent().GetPosition()
                dw, dh = frame.GetParent().GetSizeTuple()
            else:
                dx, dy, dw, dh = wx.ClientDisplayRect()

            bottom = dy + dh - self.notificationMargin

            if s == 0:
                if tmo == 1:
                    frame.Close()
                    s = 1
                    continue

                newList.append((frame, height, tmo - 1 if tmo is not None else None))
                bottom -= height + self.notificationMargin
            else:
                if tmo == 1:
                    frame.Close()
                else:
                    newList.append((frame, height, tmo - 1 if tmo is not None else None))
                    x, y = frame.GetPositionTuple()
                    AnimatedMove(frame, (x, bottom - height - self.notificationMargin))
                    bottom -= height + self.notificationMargin

        self.displayedFrames = newList
        self.CheckWaiting()
Beispiel #2
0
 def __init__(self, parent):
     super().__init__(
         parent, style=wx.SIMPLE_BORDER
     )  # wx.SIMPLE_BORDER wx.RAISED_BORDER wx.SUNKEN_BORDER wx.NO_BORDER
     framex, framey, framew, frameh = wx.ClientDisplayRect()
     rm = [
         "All files (*.*)", "Python files (*.py)", "csv files (*.csv)",
         "txt files (*.txt)"
     ]
     self.Manage_type = wx.ComboBox(self,
                                    121,
                                    value="All files (*.*)",
                                    choices=rm,
                                    style=wx.CB_READONLY)
     self.dir = wx.GenericDirCtrl(
         self, 122, os.path.dirname(os.path.abspath(__file__)),
         wx.DefaultPosition, (framew / 5, frameh / 2), wx.DIRCTRL_MULTIPLE,
         "All files (*.*)|*.*")
     self.Manage_sizer = wx.BoxSizer(wx.VERTICAL)
     self.Manage_sizer.Add(self.dir, proportion=1, flag=wx.ALL, border=10)
     self.Manage_sizer.Add(self.Manage_type, 0, wx.EXPAND | wx.ALL, 10)
     self.SetSizer(self.Manage_sizer)
     self.Manage_type.Bind(wx.EVT_COMBOBOX, self.OnCombo)
     self.dir.Bind(wx.EVT_DIRCTRL_SELECTIONCHANGED, self.OnSelect)
     self.Layout()
     self.Hide()
Beispiel #3
0
    def __init__(self):
        # 添加画板和工具标题
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "天猫精灵语音测试工具 " + version,
                          size=(800, 800))
        # frame = wx.Frame(self)
        # frame.SetMinSize((300,600))   #设定UI可变化的最小尺寸,还存在问题
        # 添加画布,获取桌面尺寸,并最大化、居中、保持在其它窗口顶部显示
        self.panel = wx.Panel(self)
        c_x, c_y, c_w, c_h = wx.ClientDisplayRect()
        # self.fromx = c_w
        print(c_x, c_y, c_w, c_h)
        # logging.basicConfig(level=logging.DEBUG)
        # self.logger_UI.debug('屏幕尺寸:%d %d %d %d' % (c_x, c_y, c_w, c_h))
        # self.SetSize(wx.Size(c_w, c_h))
        # self.Center()
        self.SetBackgroundColour("LIGHT GREY")
        # self.ToggleWindowStyle(wx.STAY_ON_TOP)

        # 加快调试效率,屏蔽初始化检查
        self.Cfginit()

        self.AddMenu()
        self.AddPanel()
        self.AddSizer()
Beispiel #4
0
    def OnResizeFrame(self, event):

        # Proportionally constrained resize.  Nice trick from http://stackoverflow.com/questions/6005960/resizing-a-wxpython-window
        # hsize = event.GetSize()[0] * 0.75
        # self.frame.SetSizeHints(minW=-1, minH=hsize, maxH=hsize)
        # self.frame.SetTitle(str(event.GetSize()))

        # print("GetClientSize()", self.GetClientSize(), wx.ClientDisplayRect(), wx.DisplaySize())
        msg = f" <--- ClientDisplayRect() changed/broken?" if self.original != wx.ClientDisplayRect(
        ) else ""
        self.wv.WriteText(
            f"frame.GetClientSize() {self.GetClientSize()}     "
            f"wx.ClientDisplayRect() {wx.ClientDisplayRect()} {msg}\n")
        # if self.original != wx.ClientDisplayRect():
        #     self.wv.WriteText(f"BROKEN!!! ClientDisplayRect has always been {self.original} but now is {wx.ClientDisplayRect} !!?\n")

        if self.GetClientSize() == wx.DisplaySize():
            print("FULLSCREEN!!!")

        # Make random rectangles
        if not self.rectangles:
            w = self.GetClientSize().width
            h = self.GetClientSize().height
            if w < 600: w = 600
            if h < 400: h = 400
            self.rectangles = makeRandomRectangles(w, h, 200)

        event.Skip()
Beispiel #5
0
    def alignToBottomRight(self):
        _, _, _, dh = wx.ClientDisplayRect()
        position = wx.GetMousePosition()

        w, h = self.GetSize()
        x = position[0] - (w / 2)
        y = dh - h
        self.SetPosition((x, y))
Beispiel #6
0
    def GetDisplayRect(self):
        """
        Returns the geometry of the main application frame's display
        """

        dpyIndex = wx.Display.GetFromWindow(wx.GetApp().GetTopWindow())
        if dpyIndex == wx.NOT_FOUND:
            return wx.ClientDisplayRect()
        return wx.Display(dpyIndex).GetClientArea()
Beispiel #7
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          "",
                          style=wx.FRAME_SHAPED | wx.FRAME_NO_TASKBAR
                          | wx.STAY_ON_TOP)

        im = Image.open(get_fp())  # 读图标的二进制数据,转为PIL对象
        bmp = wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1],
                                       im.tobytes())  # PIL对象转为wx.Bitmap对象
        icon = wx.Icon()  # 创建空图标
        icon.CopyFromBitmap(bmp)  # wx.Bitmap数据复制到wx.Icon对象

        x, y, w, h = wx.ClientDisplayRect()  # 屏幕显示区域
        x0, y0 = (w - 820) // 2, (h - 620) // 2  # 录像窗口位置(默认大小820x620,边框10像素)

        self.SetPosition((x, y))  # 无标题窗口最大化:设置位置
        self.SetSize((w, h))  # 无标题窗口最大化:设置大小
        self.SetDoubleBuffered(True)  # 启用双缓冲
        self.taskBar = wx.adv.TaskBarIcon()  # 添加系统托盘
        self.taskBar.SetIcon(icon, "屏幕录像机")

        self.box = [x0, y0, 820, 620]  # 屏幕录像窗口大小
        self.xy = None  # 鼠标左键按下的位置
        self.recording = False  # 正在录制标志
        self.saveing = False  # 正在生成GIF标志
        self.imgs = list()  # 每帧的图片列表
        self.timer = wx.Timer(self)  # 创建录屏定时器
        self.cfg = self.ReadConfig()  # 读取配置项
        self.SetWindowShape()  # 设置不规则窗口

        self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)  # 鼠标事件
        self.Bind(wx.EVT_PAINT, self.OnPaint)  # 窗口重绘
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBG)  # 擦除背景
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)  # 定时器

        self.taskBar.Bind(wx.adv.EVT_TASKBAR_RIGHT_UP,
                          self.OnTaskBar)  # 右键单击托盘图标
        self.taskBar.Bind(wx.adv.EVT_TASKBAR_LEFT_UP,
                          self.OnTaskBar)  # 左键单击托盘图标
        self.taskBar.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK,
                          self.OnTaskBar)  # 左键双击托盘图标

        self.taskBar.Bind(wx.EVT_MENU, self.OnRec, id=self.MENU_REC)  # 开始/停止录制
        self.taskBar.Bind(wx.EVT_MENU, self.OnShow, id=self.MENU_SHOW)  # 显示窗口
        self.taskBar.Bind(wx.EVT_MENU, self.OnHide, id=self.MENU_HIDE)  # 隐藏窗口
        self.taskBar.Bind(wx.EVT_MENU, self.OnOpenFolder,
                          id=self.MENU_FOLFER)  # 打开输出目录
        self.taskBar.Bind(wx.EVT_MENU, self.OnConfig,
                          id=self.MENU_CONFIG)  # 设置
        self.taskBar.Bind(wx.EVT_MENU, self.OnExit, id=self.MENU_EXIT)  # 退出

        self.RegisterHotKey(self.MENU_REC, MOD_CONTROL, VK_F2)  # 注册热键
        self.Bind(wx.EVT_HOTKEY, self.OnRec, id=self.MENU_REC)  # 开始/停止录制热键
Beispiel #8
0
    def SetProperties(self):

        # self.SetTitle(u"涉华英语自动提取及检索平台_%s_%s"%(gl.USER_NAME,gl.USER_POWER))
        self.icon = wx.Icon("img/logo.ico", wx.BITMAP_TYPE_ICO)
        self.SetIcon(self.icon)

        self.SetWindowStyle(wx.DEFAULT_FRAME_STYLE
                            ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
        c_x, c_y, c_w, c_h = wx.ClientDisplayRect()
        print c_w, c_h, c_x, c_y
        self.SetSize((900, 600))
Beispiel #9
0
 def CalculateBestPosition(self,widget):
     "When dealing with a Top-Level window position it absolute lower-right"
     if isinstance(widget, wx.Frame):
         screen = wx.ClientDisplayRect()[2:]
         left,top = widget.ClientToScreenXY(0,0)
         right,bottom = widget.ClientToScreenXY(*widget.GetClientRect()[2:])
         size = self.GetSize()
         xpos = right
         ypos = bottom - size[1]
         self.SetPosition((xpos,ypos))
     else:
         STT.ToolTipWindow.CalculateBestPosition(self, widget)
    def __init__(self, mw, name, text, buddy):
        wx.Frame.__init__(self,
                          mw,
                          style=wx.FRAME_NO_TASKBAR | wx.NO_BORDER
                          | wx.STAY_ON_TOP)
        self.panel = wx.Panel(self, style=wx.SIMPLE_BORDER)
        self.panel.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK))
        sizer = wx.BoxSizer()
        self.panel.SetSizer(sizer)

        if buddy.profile_avatar_object <> None:
            bitmap = buddy.profile_avatar_object
        else:
            bitmap = wx.Bitmap(os.path.join(config.ICON_DIR, "torchat.png"),
                               wx.BITMAP_TYPE_PNG)
        static_image = wx.StaticBitmap(self.panel, -1, bitmap)
        sizer.Add(static_image, 0, wx.ALL, 5)

        self.label = wx.StaticText(self.panel)
        self.label.SetForegroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOTEXT))
        self.label.SetLabel("%s\n\n%s" % (name, text))
        sizer.Add(self.label, 0, wx.ALL, 5)

        wsizer = wx.BoxSizer()
        wsizer.Add(self.panel, 0, wx.ALL, 0)
        self.SetSizerAndFit(wsizer)
        self.Layout()

        # initialize animation
        cx, cy, maxx, maxy = wx.ClientDisplayRect()
        self.w, self.h = self.GetSize()
        self.x_end = maxx - self.w - 20
        self.y_end = maxy - self.h - 20

        self.x_pos = -self.w
        self.y_pos = self.y_end
        self.phase = 0

        self.SetPosition((self.x_pos, self.y_pos))

        # the following will prevent the focus
        # stealing on windows
        self.Disable()
        self.Show()
        self.Enable()

        self.timer = wx.Timer(self, -1)
        self.Bind(wx.EVT_TIMER, self.onTimer)

        # start animation
        self.timer.Start(10, True)
    def NotifyFrame(self, frm, timeout=None):
        """
        Present a new notification frame.

        @param frm: The frame to show
        @param timeout: Time to display the frame before automatically
            hiding it; in seconds.
        """

        if frm.GetParent():
            dx, dy = frm.GetParent().GetPosition()
            dw, dh = frm.GetParent().GetSizeTuple()
        else:
            dx, dy, dw, dh = wx.ClientDisplayRect()

        w, h = frm.GetSizeTuple()
        w = w if w > self.notificationWidth else self.notificationWidth

        bottom = dy + dh - self.notificationMargin

        for otherFrame, height, tmo in self.displayedFrames:
            bottom -= height + self.notificationMargin
            if bottom - h < 0:
                self.waitingFrames.append((frm, timeout))
                return

        if frm.GetParent():
            x = min(wx.ClientDisplayRect()[2] - self.notificationMargin - w,
                    dx + dw + self.notificationMargin)
        else:
            x = dx + dw - w - self.notificationMargin

        frm.SetDimensions(x,
                          bottom - h - self.notificationMargin,
                          w, h)
        self.displayedFrames.append((frm, h, timeout))

        frm.Layout()

        AnimatedShow(frm)
Beispiel #12
0
    def init_ui(self):
        """
        Creates and initializes the main working area.
        """
        # cover the whole desktop, except the taskbar
        self.SetSize(wx.ClientDisplayRect())

        menuBar = SFMenuBar()
        self.SetMenuBar(menuBar)
        menuBar.bind_events()

        self.SetTitle("Shader Flow")
        self.Show()
Beispiel #13
0
def getTaskbarPos():
    d_w, d_h = wx.DisplaySize()
    c_x, c_y, c_w, c_h = wx.ClientDisplayRect()

    l = [(c_y, "top"), (d_h - c_y - c_h, "bottom"), (c_x, "left"),
         (d_w - c_x - c_w, "right")]

    def sorter(a, b):
        if a[0] < b[0]: return 1
        if a[0] > b[0]: return -1
        return 0

    l.sort(sorter)
    return l[0][1]
Beispiel #14
0
 def CalculateBestPosition(self, widget):
     screen = wx.ClientDisplayRect()[2:]
     left, top = widget.ClientToScreenXY(0, 0)
     right, bottom = widget.ClientToScreenXY(*widget.GetClientRect()[2:])
     size = self.GetSize()
     if right + size[0] > screen[0]:
         xpos = left - size[0]
     else:
         xpos = right
     if bottom + size[1] > screen[1]:
         ypos = top - size[1]
     else:
         ypos = bottom
     self.SetPosition((xpos, ypos))
Beispiel #15
0
    def OnButton(self, evt):
        global FenHelp
        
        CloseFenHelp()
        
        w = 400
        ws, hs = wx.ClientDisplayRect()[2:]
        FenHelp = md_util.MDFrame(wx.GetActiveWindow(), self.titre, self.md, 
                                  pos = (ws-w, 0), size = (w, hs))
        FenHelp.SetIcon(GetIconHelp())
        FenHelp.Bind(wx.EVT_CLOSE, self.OnClose)
#        print self.titre
#        print FenHelp.GetBestHeight()
#        self.Fit()
#        print self.GetClientSize ()
        FenHelp.Show()
        FenHelp.Fit()
Beispiel #16
0
 def __init__(self):
     # tune size and position to look like messenger
     X, Y, W, H = wx.ClientDisplayRect()
     # create main frame
     wx.Frame.__init__(self,
                       None,
                       -1,
                       sys.argv[0],
                       size=(W / 4, H / 2),
                       pos=(W - W / 4, H - H / 2))
     # style tune
     self.icon = wx.ArtProvider.GetIcon(wx.ART_ADD_BOOKMARK)
     self.SetIcon(self.icon)
     self.SetBackgroundColour(wx.BLACK)
     # set visible
     self.Show()
     # make GUI taskbared
     self.tbIcon = TaskBar(self)
Beispiel #17
0
    def ShowTip(self, x, y):
        # Ensure we're not too big (in the Y direction anyway) for the
        # desktop display area. This doesn't work on Linux because
        # ClientDisplayRect() returns the whole display size, not
        # taking the taskbar into account...

        _, displayY, _, displayHeight = wx.ClientDisplayRect()
        tipWidth, tipHeight = self.__tip.GetSizeTuple()

        if tipHeight > displayHeight:
            # Too big. Take as much space as possible.
            y = 5
            tipHeight = displayHeight - 10
        elif y + tipHeight > displayY + displayHeight:
            # Adjust y so that the whole tip is visible.
            y = displayY + displayHeight - tipHeight - 5

        self.__tip.Show(x, y, tipWidth, tipHeight)
Beispiel #18
0
    def OnSizeChange(self):
        """ Adjust the size of the video window based on the size of the original video and the
            Options > Video Size setting. """
        # If Auto-Arrange is un-checked, we ignot this whole routine!
        if TransanaGlobal.configData.autoArrange:
            #  Determine the screen size
            rect = wx.ClientDisplayRect()
            #  Get the Menu Height, which is where the top of the window should be.
            top = 24

            bounds = self.movie.GetDefaultMovieSize()

            #  Establish the minimum width of the media player control (if media is audio-only, for example)
            minWidth = max(bounds.x, 350)

            # use Movie Height
            minHeight = max(bounds.y, 14)

            if self.FileName == 'images/splash.gif':
                sizeAdjust = 100
            else:
                sizeAdjust = TransanaGlobal.configData.videoSize

            # Take Video Size Menu spec into account (50%, 66%, 100%, 150%, 200%)
            minWidth = int(minWidth * sizeAdjust / 100.0)
            minHeight = int(minHeight * sizeAdjust / 100.0)

            #  Set the dimensions of the video window as follows:
            #    left:    right-justify to the screen (left side of screen - media player width - 3 pixel margin)
            #    top:     leave top position unchanged
            #    width:   use minimum media player width established above
            #    height:  use height of Movie  + 10 pixels for the player controls
            self.SetDimensions(rect[2] - minWidth - 3, top, minWidth,
                               minHeight)
            self.parentVideoWindow.UpdateVideoWindowPosition(
                rect[2] - minWidth - 3, top, minWidth, minHeight + 38)
        else:
            # The video needs to be adjusted to the size of the window.  This tries to do that by resizing the window slightly.
            pos = self.GetPositionTuple()
            size = self.GetSize()
            self.SetDimensions(pos[0], pos[1], size[0] - 1, size[1] - 1)
            self.SetDimensions(pos[0], pos[1], size[0], size[1])
Beispiel #19
0
    def init_ui(self):
        """
        Creates and initializes the main working area.
        """
        # cover the whole desktop, except the taskbar
        self.SetSize(wx.ClientDisplayRect())

        menuBar = SFMenuBar()
        self.SetMenuBar(menuBar)
        menuBar.bind_events()

        # setup node editing workspace
        nodeview = SFNEW(self)

        # setup 3D view
        view3d = Window3D(self,
                          title='3D View',
                          style=wx.CAPTION | wx.RESIZE_BORDER)

        self.Show()
Beispiel #20
0
    def run(self):
        (cx, cy, maxx, maxy) = wx.ClientDisplayRect()
        (w, h) = self.win.GetSize()
        self.x_end = maxx - w - 20
        self.y_end = maxy - h - 20
        self.win.SetPosition((-w, self.y_end))
        wx.CallAfter(self.win.Show)
        for x in range(-w, self.x_end, 20):
            wx.CallAfter(self.win.SetPosition, (x, self.y_end))
            time.sleep(0.01)
        wx.CallAfter(self.win.SetPosition, (self.x_end, self.y_end))

        time.sleep(5)

        (w, h) = self.win.GetSize()
        for y in reversed(range(-h, self.y_end, 20)):
            wx.CallAfter(self.win.SetPosition, (self.x_end, y))
            time.sleep(0.01)
        wx.CallAfter(self.win.Hide)
        wx.CallAfter(self.win.Close)
Beispiel #21
0
    def OnInit(self):
        # Load the Frame
        x, y, X, Y = wx.ClientDisplayRect()
        maxWidth = X - x
        maxHeight = Y - y
        self.regFrame = V_regression.guiRegView(results=self.results)
        width, height = self.regFrame.GetSize()
        if height > maxHeight:
            height = maxHeight - DOCK_SIZE
            width += 15  # Scroll bar width
        if width > maxWidth:
            width = maxWidth
        if (width, height) != self.regFrame.GetSize():
            self.regFrame.SetClientRect((0, 0, width, height))
            self.regFrame.SetPosition((x, y))

        self.regFrame.Show()
        self.SetTopWindow(self.regFrame)
        self.regFrame.scroll.SetVirtualSize((570, 647))
        self.regFrame.scroll.SetScrollRate(1, 1)
        return True
Beispiel #22
0
    def __init__(self):
        self.path = ""
        framex, framey, framew, frameh = wx.ClientDisplayRect()
        wx.Frame.__init__(self,
                          None,
                          title=u"ATS Manager",
                          size=(framew, frameh))
        self.SetMinSize((framew / 2, frameh / 1.5))
        pub.subscribe(self.update_path_via_pubsub, "path")

        self.Bind(wx.EVT_CLOSE, self.OnQuit)

        self.tool = Tool(self)
        self.manage = Manage(self)
        self.auiframe = AuiFrame(self)
        self.taskmode = Task_mode(self)
        self.displaymode = Display_mode(self)
        self.analysismode = Analysis_mode(self)

        self.Menu()
        self.Status()
        self.InitUI()
Beispiel #23
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Demo",
                          size=(900, 800),
                          style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        self.original = wx.ClientDisplayRect()

        self.pnl = DrawPanel(self, self.draw_test)

        self.wv = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        font1 = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL, False, 'Consolas')
        self.wv.SetFont(font1)

        self.sp = wx.TextCtrl(self)
        font2 = wx.Font(28, wx.MODERN, wx.NORMAL, wx.NORMAL, False, 'Consolas')
        self.sp.SetFont(font2)

        sizer.Add(self.pnl, 2, wx.GROW)
        sizer.Add(self.sp, 1, wx.ALL | wx.EXPAND, 5)
        sizer.Add(self.wv, 2, wx.GROW)
        self.SetSizer(sizer)
        self.Layout()

        self.wv.WriteText(f"DisplaySize() = {wx.DisplaySize()}\n--------\n")
        self.rectangles = None

        self.Bind(wx.EVT_SIZE, self.OnResizeFrame)
        self.Bind(wx.EVT_IDLE, self.idle)

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)
Beispiel #24
0
    def OnSizeChange(self):
        """ Adjust the size of the video window based on the size of the 
        original video and the Options > Video Size setting. """
        #  Determine the screen size
        rect = wx.ClientDisplayRect()
        #  Get the current position of the Video Window
        pos = self.GetPosition()
        #  Establish the minimum width of the media player control
        # (if media is audio-only, for example)
        minWidth = max(self.ax.imagesourcewidth, 300)
        # use Movie Height
        minHeight = self.ax.imagesourceheight
        # Adjust Video Size, unless you are showing the Splash Screen
        if self.ax.filename == 'images\\splash.gif':
            sizeAdjust = 100
        else:
            sizeAdjust = TransanaGlobal.configData.videoSize
        # Take Video Size Menu spec into account (50%, 66%, 100%, 150%, 200%)
        minWidth = int(minWidth * sizeAdjust / 100.0)
        minHeight = int(minHeight * sizeAdjust / 100.0)

        # We need to know the height of the Window Header to adjust the size of the Graphic Area
        headerHeight = self.GetSizeTuple()[1] - self.GetClientSizeTuple()[1]

        #  Set the dimensions of the video window as follows:
        #    left:    right-justify to the screen
        #           (left side of screen - media player width - 3 pixel margin)
        #    top:     leave top position unchanged
        #    width:   use minimum media player width established above
        #    height:  use height of Movie  + 45 + headerHeight pixels for the player controls
        # rect[0] compensates if the Start Menu is on the left side of the screen
        self.SetDimensions(rect[0] + rect[2] - minWidth - 3, pos[1], minWidth,
                           minHeight + 45 + headerHeight)
        self.parentVideoWindow.UpdateVideoWindowPosition(
            rect[0] + rect[2] - minWidth - 3, pos[1], minWidth,
            minHeight + 45 + headerHeight)
    def __init__(self, mw, name, text, buddy, color):
        wx.Frame.__init__(self,
                          mw,
                          style=wx.FRAME_NO_TASKBAR | wx.NO_BORDER
                          | wx.STAY_ON_TOP)

        # Set the buddy
        self.buddy = buddy
        message = "Torchat: %s\n\n%s\n%s" % (config.getProfileShortName(),
                                             name, text)

        # Get the window color
        if not len(color):
            color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK)

        # Recycle old window if we can
        if buddy.address in notificationToasterWindows:
            window = notificationToasterWindows[buddy.address]
            window.resetTimer()
            window.setMessage(message)
            window.setColor(color)
            self.Destroy()
            return

        # Layout
        self.panel = wx.Panel(self, style=wx.SIMPLE_BORDER)
        self.panel.SetMinSize((250, 74))
        self.setColor(color)

        sizer = wx.BoxSizer()
        self.panel.SetSizer(sizer)

        if buddy.profile_avatar_object <> None:
            bitmap = buddy.profile_avatar_object
        else:
            bitmap = wx.Bitmap(os.path.join(config.ICON_DIR, "torchat.png"),
                               wx.BITMAP_TYPE_PNG)
        static_image = wx.StaticBitmap(self.panel, -1, bitmap)
        sizer.Add(static_image, 0, wx.ALL, 5)

        self.label = wx.StaticText(self.panel)
        self.setMessage(message)
        sizer.Add(self.label, 0, wx.ALL, 5)

        wsizer = wx.BoxSizer()
        wsizer.Add(self.panel, 0, wx.ALL, 0)
        self.SetSizerAndFit(wsizer)
        self.Layout()

        # we don't need them to overlap
        self.locidx = self.findLocation()
        self.margin = 10

        # initialize animation
        self.cx, self.cy, self.tx, self.ty = wx.ClientDisplayRect()
        self.w, self.h = self.GetSize()

        self.offsety = self.locidx * self.h + self.locidx * self.margin

        self.x_pos = self.tx - self.w - 20
        self.y_pos = self.ty + self.h + 20
        self.y_max = self.ty - 85 - self.offsety
        self.y_end = self.y_pos
        self.phase = 0

        self.SetPosition((self.x_pos, self.y_pos))

        # the following will prevent the focus
        # stealing on windows
        self.Disable()
        self.Show()
        self.Enable()

        self.timer = wx.Timer(self, -1)
        self.Bind(wx.EVT_TIMER, self.onTimer)

        # start animation
        self.timer.Start(10, True)

        # we need this
        notificationToasterPositions.append(self.locidx)
        notificationToasterWindows[self.buddy.address] = self
Beispiel #26
0
 def testReallyBigTip(self):
     width, height = wx.ClientDisplayRect()[2:]
     tipWindow = DummyToolTipWindow((2 * width, 2 * height))
     self.tooltipMixin.DoShowTip(0, 0, tipWindow)
     self.assertEqual((5, 5, 2 * width, height - 10), tipWindow.rect)
Beispiel #27
0
 def testTipThatFallsOfBottomOfScreen(self):
     _, displayY, _, height = wx.ClientDisplayRect()
     tipWindow = DummyToolTipWindow((10, 100))
     self.tooltipMixin.DoShowTip(0, height - 10, tipWindow)
     self.assertEqual((0, height - 105 + displayY, 10, 100), tipWindow.rect)
Beispiel #28
0
    def __init__(self, *args, **kwds):

        # Metricas de deteccion y tiempo
        self.tmin = 100
        self.tmax = 0
        self.ttot = 0
        self.tcount = 0
        self.dmin = 100
        self.dmax = 0
        self.dboxtot = 0
        self.davgtot = 0
        self.dcount = 0

        # begin wxGlade: MyFrame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((812, 522))

        # Menu Bar
        self.frame_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        item = wxglade_tmp_menu.Append(wx.ID_ANY, u"Configuración", "")
        self.Bind(wx.EVT_MENU, self.configuraciónClick, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Acerca de...", "")
        self.Bind(wx.EVT_MENU, self.acercaDeClick, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Salir", "")
        self.Bind(wx.EVT_MENU, self.salirClick, id=item.GetId())
        self.frame_menubar.Append(wxglade_tmp_menu, "Menu")
        wxglade_tmp_menu = wx.Menu()
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Start/Stop", "")
        self.Bind(wx.EVT_MENU, self.cambiarEstadoCNN, id=item.GetId())
        self.frame_menubar.Append(wxglade_tmp_menu, "CNN")
        self.SetMenuBar(self.frame_menubar)
        # Menu Bar end
        self.label_1 = wx.StaticText(self, wx.ID_ANY, "Ubicaciones:")
        self.cantUbicaciones = wx.StaticText(self, wx.ID_ANY, "0")
        self.label_2 = wx.StaticText(self, wx.ID_ANY, "Ocupadas: ")
        self.cantOcupadas = wx.StaticText(self, wx.ID_ANY, "0")
        self.label_3 = wx.StaticText(self, wx.ID_ANY, "Libres:")
        self.cantLibres = wx.StaticText(self, wx.ID_ANY, "0")

        self.__set_properties()
        self.__do_layout()

        # end wxGlade

        #Create objects

        self.CaptureWidth = 640
        self.CaptureHeight = 480

        #Para Camara en vivo
        self.Screen1Width = 550
        self.Screen1Height = 300
        self.Screen1 = wx.StaticBitmap(
            self,
            size=(self.Screen1Width,
                  self.Screen1Height))  # Static bitmaps for OpenCV images

        img = wx.Image('imagenes/bancaLibre.png').Scale(
            self.Screen1Width, self.Screen1Height, wx.IMAGE_QUALITY_HIGH)
        self.wxbmp = img.ConvertToBitmap()
        self.num = -1
        self.boxes = 0
        self.scores = 0
        self.classes = 0

        self.sizer_2.Add(self.Screen1, 1, wx.FIXED_MINSIZE | wx.ALL, 5)

        self.Screen1.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground)
        self.Screen1.Bind(wx.EVT_PAINT, self.onPaint)

        # Add objects to sizer
        #self.sizer_2.Add(self.Screen1, 0, wx.EXPAND | wx.ALL, 10)

        #Para resultado del analisis
        self.Screen2Width = 550
        self.Screen2Height = 270

        #Maximizo ventana para que ocupe todo el escritorio menos la barra de tareas
        c_x, c_y, c_w, c_h = wx.ClientDisplayRect()
        self.SetSize((c_w, c_h))
        self.SetPosition((c_x, c_y))

        #Ventana mitad de escritorio
        self.SetSize((c_w / 2, c_h))
        self.SetPosition((c_w / 2, c_y))

        #Obtengo la posicion, dentro de la toma completa, de cada ubicacion
        path_locations = 'configuracion'
        self.images_location = self.xml_to_locations(path_locations)
        self.cantUbicaciones.Label = str(len(self.images_location))
        self.cantLibres.Label = str(len(self.images_location))
        #Lista para guardar el estado de cada banca:
        # [OK] = ocupada
        # [ ] = libre
        # [?] = indeterminado
        self.locations_state = []

        self.imagenes_bancas_select = {
            "ocupada": 'imagenes/bancaOcupadaSelect.png',
            "libre": 'imagenes/bancaLibreSelect.png',
            "indeterminado": 'imagenes/bancaIndeterminadoSelect.png'
        }

        #Creo tantas bancas como posiciones guardadas en el xml y las guardo en una lista
        #Las StaticBitmap contendran las imagenes de los estados de las bancas
        self.screen_list = []
        for i in self.images_location:
            sb = wx.StaticBitmap(self,
                                 size=(self.Screen2Width, self.Screen2Height))
            #sb.SetPosition(wx.Point(0,0))
            self.screen_list.append(
                banca.Banca(sb, i[0], i[1], i[2], i[3], i[4]))

        #Creo un diccionario para consultar datos de cada banca, al hacer click en una banca
        self.dict_bancas = {}  # create an empty dictionary
        for i in range(len(self.screen_list)):
            self.dict_bancas[
                self.screen_list[i].staticBitmap] = self.screen_list[i]

        #Seteo estado,posicion y evento de cada StaticBitmap
        for i in self.screen_list:

            #Seteo posicion proporcional al tamaño del screen y al tamaño de la captura
            xmin, ymin = i.getPosicionXML()
            xpos = int((xmin / self.CaptureWidth) * self.Screen2Width)
            ypos = int((ymin / self.CaptureHeight) * self.Screen2Height)
            x, y = self.sizer_3.GetPosition()
            i.setPosicionVentana(x + xpos, y + ypos)

            #Seteo el eventos
            i.staticBitmap.Bind(wx.EVT_LEFT_UP, self.bancaClick)
            i.staticBitmap.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOverBanca)
            i.staticBitmap.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseOutBanca)

            #Seteo cursor sobre la banca
            i.staticBitmap.SetCursor(wx.Cursor(wx.CURSOR_HAND))

        self.tiempo1 = time.now()

        #ipcamUrl = 'http://*****:*****@192.168.43.1:8081'
        ipcamUrl = 'IMG_2633.MOV'
        ipcam = {}
        ipcamDesc = 'Celular'
        ipcam[ipcamDesc] = urlparse(ipcamUrl)
        print(time.now())

        # Prueba la conexión al destino ip
        if len(ipcamUrl) > 5:
            err, errMsg = self.urlTest(ipcam[ipcamDesc].hostname,
                                       ipcam[ipcamDesc].port)
            if err > 0:
                print(time.now(), "Falló conexión. ", errMsg)
                exit(1)

        try:
            self.capture = cv2.VideoCapture(ipcamUrl)
            #print("FPS:",self.capture.get(cv2.CAP_PROP_FPS))
            '''width = self.capture.get(3)
          height = self.capture.get(4)
          size = (width,height)'''

            self.capture.set(3, self.CaptureWidth)  #1024 640 1280 800 384
            self.capture.set(4, self.CaptureHeight)  #600 480 960 600 288

            #self.out = cv2.VideoWriter('project.avi',cv2.VideoWriter_fourcc(*'DIVX'), 15, size)

            sys.path.append("..")

            # Importación del módulo de detección de objetos.
            from object_detection.utils import label_map_util
            from object_detection.utils import visualization_utils as vis_util

            PATH_TO_CKPT = 'modelo_congelado/frozen_inference_graph.pb'

            PATH_TO_LABELS = os.path.join('configuracion', 'label_map.pbtxt')

            NUM_CLASSES = 2

            self.detection_graph = tf.Graph()
            with self.detection_graph.as_default():
                od_graph_def = tf.GraphDef()
                with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
                    serialized_graph = fid.read()
                    od_graph_def.ParseFromString(serialized_graph)
                    tf.import_graph_def(od_graph_def, name='')

            label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
            categories = label_map_util.convert_label_map_to_categories(
                label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
            self.category_index = label_map_util.create_category_index(
                categories)

        except IOError as e:
            print(time.now(), "Error abriendo socket: ", ipcamUrl)
        except KeyboardInterrupt as e:
            print(time.now(), "Detenido por teclado.")
        except BaseException as e:
            print(time.now(), "Error desconocido: ", e)
        #    if e.number == -138:
        #        print("Compruebe la conexión con '" + ipcamUrl + "'")
        #    else:
        #        print("Error: " + e.message)
        finally:
            #self.capture.release()
            cv2.destroyAllWindows()

        with self.detection_graph.as_default():
            with tf.Session(graph=self.detection_graph) as sess:
                self.sess = tf.Session()
                self.image_tensor = self.detection_graph.get_tensor_by_name(
                    'image_tensor:0')
                # Each box represents a part of the image where a particular object was detected.
                self.detection_boxes = self.detection_graph.get_tensor_by_name(
                    'detection_boxes:0')
                # Each score represent how level of confidence for each of the objects.
                # Score is shown on the result image, together with the class label.
                self.detection_scores = self.detection_graph.get_tensor_by_name(
                    'detection_scores:0')
                self.detection_classes = self.detection_graph.get_tensor_by_name(
                    'detection_classes:0')
                self.num_detections = self.detection_graph.get_tensor_by_name(
                    'num_detections:0')

                #Creo un timer para:
                # 1) Actualizar la información en pantalla
                # 2) Activar la CNN y obtener datos del analisis
                self.timer = wx.Timer(self)
                self.Bind(wx.EVT_TIMER, self.OnTimer)

                #Inicialmente la CNN está inactiva
                self.analisis = False

                self.Bind(wx.EVT_CLOSE, self.onClose)
                self.Bind(wx.EVT_LEFT_UP, self.VentanaClick)

                #Estado del programa
                self.STATE_RUNNING = 1
                self.STATE_CLOSING = 2
                self.state = self.STATE_RUNNING

                #Cantidad de ciclos del timer que la CNN no trabaja
                #Esto es para evitar lag
                self.FREC = 0
                self.FRECUENCIA_CNN = 0

                #Seteo cada cuanto tiempo se activará el timer
                self.fps = 100
                self.timer.Start(1000. / self.fps)  # timer interval
                self.imagenes = 0
Beispiel #29
0
    def __init__(self, *args, **kwds):

        # begin wxGlade: MyFrame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((812, 522))

        self.Bind(wx.EVT_KEY_DOWN, self.KeyDown)

        # Menu Bar
        self.frame_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        item = wxglade_tmp_menu.Append(wx.ID_ANY, u"Configuración", "")
        self.Bind(wx.EVT_MENU, self.configuraciónClick, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Acerca de...", "")
        self.Bind(wx.EVT_MENU, self.acercaDeClick, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Salir", "")
        self.Bind(wx.EVT_MENU, self.salirClick, id=item.GetId())
        self.frame_menubar.Append(wxglade_tmp_menu, "Menu")
        wxglade_tmp_menu = wx.Menu()
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Start/Stop", "")
        self.Bind(wx.EVT_MENU, self.cambiarEstadoCNN, id=item.GetId())
        self.frame_menubar.Append(wxglade_tmp_menu, "CNN")
        self.SetMenuBar(self.frame_menubar)
        # Menu Bar end
        self.label_1 = wx.StaticText(self, wx.ID_ANY, "Ubicaciones:")
        self.cantUbicaciones = wx.StaticText(self, wx.ID_ANY, "0")
        self.label_2 = wx.StaticText(self, wx.ID_ANY, "Ocupadas: ")
        self.cantOcupadas = wx.StaticText(self, wx.ID_ANY, "0")
        self.label_3 = wx.StaticText(self, wx.ID_ANY, "Libres:")
        self.cantLibres = wx.StaticText(self, wx.ID_ANY, "0")

        self.__set_properties()
        self.__do_layout()

        # end wxGlade

        self.PATH_VIDEOS_TUTORIAL = 'videos/Tutorial/Tuto.mp4'
        self.PATH_VIDEOS_ADULTOS = 'videos/Adultos'
        self.listaAdultos = [
            f for f in listdir(self.PATH_VIDEOS_ADULTOS)
            if isfile(join(self.PATH_VIDEOS_ADULTOS, f)) and os.path.splitext(
                join(self.PATH_VIDEOS_ADULTOS, f))[1] == ".mp4"
        ]
        self.listaVideosAdultos = cycle(self.listaAdultos)

        self.PATH_VIDEOS_MENORES = 'videos/Menores'
        self.listaMenores = [
            f for f in listdir(self.PATH_VIDEOS_MENORES)
            if isfile(join(self.PATH_VIDEOS_MENORES, f)) and os.path.splitext(
                join(self.PATH_VIDEOS_MENORES, f))[1] == ".mp4"
        ]
        self.listaVideosMenores = cycle(self.listaMenores)

        self.personas = 0
        self.pause = False
        self.forzarPausa = False
        self.personasTotales = 0
        self.Genero = "Adultos"
        self.MostrarGenero = False

        #Create objects
        self.CaptureWidth = 640
        self.CaptureHeight = 480

        #Para Camara en vivo
        self.Screen1Width = 550
        self.Screen1Height = 300
        self.Screen1 = wx.StaticBitmap(
            self,
            size=(self.Screen1Width,
                  self.Screen1Height))  # Static bitmaps for OpenCV images

        img = wx.Image('imagenes/negro.png').Scale(self.Screen1Width,
                                                   self.Screen1Height,
                                                   wx.IMAGE_QUALITY_HIGH)
        self.wxbmp = img.ConvertToBitmap()
        self.num = -1
        self.boxes = 0
        self.scores = 0
        self.classes = 0

        self.sizer_2.Add(self.Screen1, 1, wx.FIXED_MINSIZE | wx.ALL, 5)

        self.Screen1.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground)
        self.Screen1.Bind(wx.EVT_PAINT, self.onPaint)

        # Add objects to sizer
        #self.sizer_2.Add(self.Screen1, 0, wx.EXPAND | wx.ALL, 10)

        #Para resultado del analisis
        self.Screen2Width = 550
        self.Screen2Height = 270

        #Maximizo ventana para que ocupe todo el escritorio menos la barra de tareas
        c_x, c_y, c_w, c_h = wx.ClientDisplayRect()
        self.SetSize((c_w, c_h))
        self.SetPosition((c_x, c_y))

        #Ventana mitad de escritorio
        self.SetSize((c_w / 2, c_h))
        self.SetPosition((c_w / 2, c_y))

        #Obtengo la posicion, dentro de la toma completa, de cada ubicacion
        path_locations = 'configuracion'
        self.images_location = self.xml_to_locations(path_locations)
        self.cantUbicaciones.Label = str(len(self.images_location))
        self.cantLibres.Label = str(len(self.images_location))
        #Lista para guardar el estado de cada banca:
        # [OK] = ocupada
        # [ ] = libre
        # [?] = indeterminado
        self.locations_state = []

        self.tiempo1 = time.now()
        #ipcamUrl = 'http://*****:*****@192.168.43.1:8081'
        ipcamUrl = 'http://*****:*****@192.168.43.93:8081'
        ipcam = {}
        ipcamDesc = 'Celular'
        ipcam[ipcamDesc] = urlparse(ipcamUrl)
        print(time.now())

        try:
            #self.capture = cv2.VideoCapture(ipcamUrl)
            self.capture = cv2.VideoCapture(0)
            self.capture.set(3, self.CaptureWidth)  #1024 640 1280 800 384
            self.capture.set(4, self.CaptureHeight)  #600 480 960 600 288
            global x2, y2
            x2 = self.CaptureWidth
            y2 = self.CaptureHeight
            sys.path.append("..")

            # Importación del módulo de detección de objetos.
            from object_detection.utils import label_map_util
            from object_detection.utils import visualization_utils as vis_util

            PATH_TO_CKPT = 'modelo_congelado/frozen_inference_graph.pb'

            PATH_TO_LABELS = os.path.join('configuracion', 'label_map.pbtxt')

            NUM_CLASSES = 90

            self.detection_graph = tf.Graph()
            with self.detection_graph.as_default():
                od_graph_def = tf.GraphDef()
                with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
                    serialized_graph = fid.read()
                    od_graph_def.ParseFromString(serialized_graph)
                    tf.import_graph_def(od_graph_def, name='')

            label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
            categories = label_map_util.convert_label_map_to_categories(
                label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
            self.category_index = label_map_util.create_category_index(
                categories)

        except IOError as e:
            print(time.now(), "Error abriendo socket: ", ipcamUrl)
        except KeyboardInterrupt as e:
            print(time.now(), "Detenido por teclado.")
        except BaseException as e:
            print(time.now(), "Error desconocido: ", e)
        #    if e.number == -138:
        #        print("Compruebe la conexión con '" + ipcamUrl + "'")
        #    else:
        #        print("Error: " + e.message)
        finally:
            #self.capture.release()
            cv2.destroyAllWindows()

        with self.detection_graph.as_default():
            with tf.Session(graph=self.detection_graph) as sess:
                self.sess = tf.Session()
                self.image_tensor = self.detection_graph.get_tensor_by_name(
                    'image_tensor:0')
                # Each box represents a part of the image where a particular object was detected.
                self.detection_boxes = self.detection_graph.get_tensor_by_name(
                    'detection_boxes:0')
                # Each score represent how level of confidence for each of the objects.
                # Score is shown on the result image, together with the class label.
                self.detection_scores = self.detection_graph.get_tensor_by_name(
                    'detection_scores:0')
                self.detection_classes = self.detection_graph.get_tensor_by_name(
                    'detection_classes:0')
                self.num_detections = self.detection_graph.get_tensor_by_name(
                    'num_detections:0')

                #Creo un timer para:
                # 1) Actualizar la información en pantalla
                # 2) Activar la CNN y obtener datos del analisis
                self.timer = wx.Timer(self)
                self.Bind(wx.EVT_TIMER, self.OnTimer)

                #Inicialmente la CNN está inactiva
                self.analisis = False

                self.Bind(wx.EVT_CLOSE, self.onClose)
                self.Bind(wx.EVT_LEFT_UP, self.VentanaClick)

                #Estado del programa
                self.STATE_RUNNING = 1
                self.STATE_CLOSING = 2
                self.state = self.STATE_RUNNING

                #Estado del reproductor
                self.STATE_PORTADA = 1
                self.STATE_TUTORIAL = 2
                self.STATE_PELICULA = 3
                self.statePlayer = self.STATE_PORTADA

                #Cantidad de ciclos del timer que la CNN no trabaja
                #Esto es para evitar lag
                self.FREC = 20
                self.FRECUENCIA_CNN = 0

                #Seteo cada cuanto tiempo se activará el timer
                self.fps = 40
                self.timer.Start(1000. / self.fps)  # timer interval

                self.camara = "Camera"
                cv2.namedWindow(self.camara, cv2.WINDOW_NORMAL)

                cv2.setMouseCallback(self.camara, on_mouse, 0)
                cv2.setWindowProperty(self.camara, cv2.WND_PROP_FULLSCREEN,
                                      cv2.WINDOW_FULLSCREEN)
                sleep(0.1)
                cv2.resizeWindow(self.camara, 320, 180)
                cv2.moveWindow(self.camara, 16, 16)

                self.appPrincipal = "AppPrincipal"

                #Para traer al frente la toma de la camara
                top_windows = []
                win32gui.EnumWindows(windowEnumerationHandler, top_windows)
                for i in top_windows:

                    if self.camara in i[1]:
                        self.camaraPID = i[0]
                        win32gui.ShowWindow(i[0], 5)
                        win32gui.SetForegroundWindow(i[0])
                        break

                #Para traer al frente la AppPrincipal para capturar eventos
                top_windows = []
                win32gui.EnumWindows(windowEnumerationHandler, top_windows)
                for i in top_windows:
                    if self.appPrincipal in i[1]:
                        self.appPrincipalPID = i[0]
                        win32gui.ShowWindow(i[0], 5)
                        #win32gui.SetForegroundWindow(i[0])
                        break

                rect = win32gui.GetWindowRect(self.camaraPID)
                self.xCamara = rect[0]
                self.yCamara = rect[1]
                self.wCamara = rect[2] - self.xCamara
                self.hCamara = rect[3] - self.yCamara

                self.frequency = 1000  # Set Frequency
                self.duration = 200  # Set Duration To 1000 ms == 1 second

                self.widhtDesktop = GetSystemMetrics(0)
                self.heightDesktop = GetSystemMetrics(1)

                #Oculto la AppPrincipal del escritorio (X,Y,Width,Height)
                sleep(0.1)
                win32gui.ShowWindow(self.appPrincipalPID, win32con.SW_HIDE)
                self.logostr = 'imagenes/usher 5 borde4.png'
                self.xyLogo = 10

                if self.statePlayer == self.STATE_PELICULA:
                    #VLC para las peliculas
                    self.instance = vlc.Instance()
                    self.player = self.instance.media_player_new(
                        "Reproductor Peliculas y Portadas")
                    self.player.set_fullscreen(True)
                    pathVideo = os.path.join(self.PATH_VIDEOS,
                                             next(self.listaVideosAdultos))
                    self.media = self.instance.media_new(pathVideo)
                    self.player.set_media(self.media)

                    self.player.play()

                    sleep(0.1)
                    self.reproductorPID = win32gui.GetForegroundWindow()
                    self.player.pause()
                    self.pause = True
                    self.media = self.player.get_media()
                else:
                    #VLC para las portadas
                    self.instance = vlc.Instance("--sub-source logo:marq")

                    self.player = self.instance.media_player_new()

                    self.player.set_fullscreen(True)
                    self.media = self.instance.media_new(
                        'imagenes/portada.jpg')
                    self.player.set_media(self.media)

                    self.player.play()

                    sleep(0.1)
                    self.reproductorPID = win32gui.GetForegroundWindow()
                    self.player.pause()
                    self.pause = True
                    self.player.set_time(8000)

                    self.media = self.player.get_media()

                print("Reproductor inicial:", self.reproductorPID)

                self.vlcName = "VLC (Direct3D output)"
                self.vlcName2 = "VLC (VLC Video Output)"
                self.reproductorPID = 0
                #Obtengo el PID del vlc
                top_windows = []
                win32gui.EnumWindows(windowEnumerationHandler, top_windows)
                for i in top_windows:
                    if self.vlcName in i[1]:
                        self.reproductorPID = i[0]
                        win32gui.ShowWindow(i[0], 5)
                        break

                print("Reproductor inicial buscado:", self.reproductorPID)

                win32gui.ShowWindow(self.reproductorPID, win32con.SW_MAXIMIZE)
    def __init__(self, dbTree, sel):
        # Set the Cursor to the Hourglass while the report is assembled
        TransanaGlobal.menuWindow.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))

        try:

            # Build the title and subtitle
            title = _('Collection Summary Report')
            if dbTree.GetPyData(sel).nodetype == 'SearchCollectionNode':
                reportType = _('Search Result Collection')
            else:
                reportType = _('Collection')
            prompt = '%s: %s'
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                reportType = unicode(reportType, 'utf8')
                prompt = unicode(prompt, 'utf8')
            subtitle = prompt % (reportType, dbTree.GetItemText(sel))

            # Prepare the Transcript for printing
            (graphic, pageData) = TranscriptPrintoutClass.PrepareData(
                TransanaGlobal.printData,
                collectionTree=dbTree,
                collectionNode=sel,
                title=title,
                subtitle=subtitle)

            # If there's data inthe report...
            if pageData != []:
                # Send the results of the PrepareData() call to the MyPrintout object, once for the print preview
                # version and once for the printer version.
                printout = TranscriptPrintoutClass.MyPrintout(
                    title, graphic, pageData, subtitle=subtitle)
                printout2 = TranscriptPrintoutClass.MyPrintout(
                    title, graphic, pageData, subtitle=subtitle)

                # Create the Print Preview Object
                printPreview = wx.PrintPreview(printout, printout2,
                                               TransanaGlobal.printData)

                # Check for errors during Print preview construction
                if not printPreview.Ok():
                    dlg = Dialogs.ErrorDialog(None, _("Print Preview Problem"))
                    dlg.ShowModal()
                    dlg.Destroy()
                else:
                    # Create the Frame for the Print Preview
                    # The parent Frame is the global Menu Window
                    theWidth = max(wx.ClientDisplayRect()[2] - 180, 760)
                    theHeight = max(wx.ClientDisplayRect()[3] - 200, 560)
                    printFrame = wx.PreviewFrame(printPreview,
                                                 TransanaGlobal.menuWindow,
                                                 _("Print Preview"),
                                                 size=(theWidth, theHeight))
                    printFrame.Centre()
                    # Initialize the Frame for the Print Preview
                    printFrame.Initialize()
                    # Restore Cursor to Arrow
                    TransanaGlobal.menuWindow.SetCursor(
                        wx.StockCursor(wx.CURSOR_ARROW))
                    # Display the Print Preview Frame
                    printFrame.Show(True)
            else:
                # Restore Cursor to Arrow
                TransanaGlobal.menuWindow.SetCursor(
                    wx.StockCursor(wx.CURSOR_ARROW))
                # If there are no clips to report, display an error message.
                if 'unicode' in wx.PlatformInfo:
                    # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                    prompt = unicode(
                        _('Collection "%s" has no Clips for the Collection Summary Report.'
                          ), 'utf8')
                else:
                    prompt = _(
                        'Collection "%s" has no Clips for the Collection Summary Report.'
                    )
                dlg = wx.MessageDialog(None,
                                       prompt % dbTree.GetItemText(sel),
                                       style=wx.OK | wx.ICON_EXCLAMATION)
                dlg.ShowModal()
                dlg.Destroy()

        finally:
            # Restore Cursor to Arrow
            TransanaGlobal.menuWindow.SetCursor(wx.StockCursor(
                wx.CURSOR_ARROW))