Пример #1
0
 def new_backing(self, bw, bh):
     widget = super().new_backing(bw, bh)
     if self.drawing_area:
         self.remove(self.drawing_area)
     set_visual(widget, self._has_alpha)
     widget.show()
     self.init_widget_events(widget)
     if self.drawing_area and self.size_constraints:
         #apply min size to the drawing_area:
         thints = typedict(self.size_constraints)
         minsize = thints.intpair("minimum-size", (0, 0))
         self.drawing_area.set_size_request(*minsize)
     self.add(widget)
     self.drawing_area = widget
     #maybe redundant?:
     self.apply_geometry_hints(self.geometry_hints)
Пример #2
0
 def check_support(self, force_enable=False):
     i = self.props
     if not self.xdisplay:
         return {
             "success": False,
             "safe": False,
             "enabled": False,
             "message": "cannot access X11 display",
         }
     from gi.repository import Gtk
     tmp = Gtk.Window(Gtk.WindowType.TOPLEVEL)
     tmp.resize(1, 1)
     tmp.set_decorated(False)
     tmp.realize()
     da = Gtk.DrawingArea()
     tmp.add(da)
     set_visual(da, True)
     win = tmp.get_window()
     log("check_support(%s) using temporary window=%s", force_enable, tmp)
     with self.get_paint_context(win):
         i.update(check_PyOpenGL_support(force_enable))
     tmp.destroy()
     return i