From d8ff18387f317c6f040b5fb21891ed3faa7297f7 Mon Sep 17 00:00:00 2001 From: Roz K Date: Sun, 12 Oct 2025 03:01:18 +0200 Subject: [PATCH] gl canvas and context --- pyui/preview.py | 7 ++++- pyui/preview_generated.py | 16 ++++++++-- pyui/resources/mainframe.fbp | 4 +-- pyui/resources/preview.fbp | 8 +++-- pyui/resources/video.fbp | 60 ------------------------------------ pyui/video.py | 18 +++++++++-- pyui/video_generated.py | 31 ------------------- 7 files changed, 42 insertions(+), 102 deletions(-) delete mode 100644 pyui/resources/video.fbp delete mode 100644 pyui/video_generated.py diff --git a/pyui/preview.py b/pyui/preview.py index 27cbb7f..83e462a 100644 --- a/pyui/preview.py +++ b/pyui/preview.py @@ -17,4 +17,9 @@ from . import preview_generated class PreviewPanel(preview_generated.PreviewPanel): - pass + + def initdialog_event_handler(self, event): + self.video_panel.initialize() + + def size_event_handler(self, event): + pass diff --git a/pyui/preview_generated.py b/pyui/preview_generated.py index bd5bf9c..9b3c07f 100644 --- a/pyui/preview_generated.py +++ b/pyui/preview_generated.py @@ -7,7 +7,7 @@ ## PLEASE DO *NOT* EDIT THIS FILE! ########################################################################### -from .video import VideoPanel +from .video import VideoCanvas import wx import wx.xrc @@ -45,7 +45,7 @@ class PreviewPanel ( wx.Panel ): centering_sizer.Add( ( 0, 0), 1, wx.EXPAND, 5 ) - self.video_panel = VideoPanel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 400,300 ), wx.BORDER_NONE|wx.FULL_REPAINT_ON_RESIZE|wx.TAB_TRAVERSAL ) + self.video_panel = VideoCanvas( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 400,300 ), wx.BORDER_NONE|wx.FULL_REPAINT_ON_RESIZE|wx.TAB_TRAVERSAL ) centering_sizer.Add( self.video_panel, 0, wx.EXPAND, 5 ) @@ -64,7 +64,19 @@ class PreviewPanel ( wx.Panel ): self.SetSizer( centering_sizer ) self.Layout() + # Connect Events + self.Bind( wx.EVT_INIT_DIALOG, self.initdialog_event_handler ) + self.Bind( wx.EVT_SIZE, self.size_event_handler ) + def __del__( self ): pass + # Virtual event handlers, override them in your derived class + def initdialog_event_handler( self, event ): + pass + + def size_event_handler( self, event ): + pass + + diff --git a/pyui/resources/mainframe.fbp b/pyui/resources/mainframe.fbp index c5d0d38..7ad4ec0 100644 --- a/pyui/resources/mainframe.fbp +++ b/pyui/resources/mainframe.fbp @@ -23,11 +23,11 @@ 0 source_name 1 - 1 + 0 source_name 1 - 1 + 0 1 0 0 diff --git a/pyui/resources/preview.fbp b/pyui/resources/preview.fbp index 8427e60..96f6390 100644 --- a/pyui/resources/preview.fbp +++ b/pyui/resources/preview.fbp @@ -23,11 +23,11 @@ 0 source_name 1 - 1 + 0 source_name 1 - 1 + 0 1 0 0 @@ -55,6 +55,8 @@ wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL + initdialog_event_handler + size_event_handler 3 wxBOTH @@ -157,7 +159,7 @@ Resizable 1 400,300 - VideoPanel; .video; + VideoCanvas; .video; 0 diff --git a/pyui/resources/video.fbp b/pyui/resources/video.fbp deleted file mode 100644 index cf1a7fb..0000000 --- a/pyui/resources/video.fbp +++ /dev/null @@ -1,60 +0,0 @@ - - - - - Python - ; - 0 - connect - none - - - 0 - 1 - res - UTF-8 - video_generated - 6000 - 1 - 1 - UI - video - /home/roz/Dev/rk/rk_pve/pyui - 0 - source_name - 1 - 1 - source_name - - 1 - 1 - 1 - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - 1 - 1 - 1 - impl_virtual - - - 0 - wxID_ANY - - - VideoPanel - - 400,300 - ; ; forward_declare - - 0 - - - wxBORDER_NONE|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL - - - diff --git a/pyui/video.py b/pyui/video.py index f49c7b7..ac9e89f 100644 --- a/pyui/video.py +++ b/pyui/video.py @@ -14,7 +14,19 @@ # You should have received a copy of the GNU General Public License along with People's Video Editor. # If not, see . -from . import video_generated +import wx +import wx.glcanvas -class VideoPanel(video_generated.VideoPanel): - pass +class VideoCanvas(wx.glcanvas.GLCanvas): + __slots__ = 'context' + + def __init__(self, parent, + id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.TAB_TRAVERSAL): + wx.glcanvas.GLCanvas.__init__(self, parent, id = id, pos = pos, size = size, style = style, attribList = + wx.glcanvas.GLAttributes().PlatformDefaults().RGBA().FrameBuffersRGB().DoubleBuffer().EndList()) + self.context = wx.glcanvas.GLContext(self, ctxAttrs = + wx.glcanvas.GLContextAttrs().CoreProfile().OGLVersion(4,6).EndList()) + + def initialize(self): + self.SetCurrent(self.context) + self.SwapBuffers() diff --git a/pyui/video_generated.py b/pyui/video_generated.py deleted file mode 100644 index 4de1730..0000000 --- a/pyui/video_generated.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- - -########################################################################### -## Python code generated with wxFormBuilder (version 4.2.1-5faebfea) -## http://www.wxformbuilder.org/ -## -## PLEASE DO *NOT* EDIT THIS FILE! -########################################################################### - -import wx -import wx.xrc - -import gettext -_ = gettext.gettext - -########################################################################### -## Class VideoPanel -########################################################################### - -class VideoPanel ( wx.Panel ): - - def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 400,300 ), style = wx.BORDER_NONE|wx.FULL_REPAINT_ON_RESIZE|wx.TAB_TRAVERSAL, name = wx.EmptyString ): - wx.Panel.__init__ ( self, parent, id = id, pos = pos, size = size, style = style, name = name ) - - self.DragAcceptFiles( True ) - - - def __del__( self ): - pass - -