|  | 
|  | 1 | +"""This code is free to use example on using pyopengltk """ | 
|  | 2 | +"""Made by Juha-Pekka Ahto """ | 
|  | 3 | +"""Machine and production engineer """ | 
|  | 4 | +import f3d | 
|  | 5 | +import tkinter as tk # Works also on CustomTKinter | 
|  | 6 | +from pyopengltk import OpenGLFrame | 
|  | 7 | + | 
|  | 8 | + | 
|  | 9 | +class Frame(OpenGLFrame): | 
|  | 10 | + # !!!OpenGlFrame requires adding own code to initgl and redraw!!! | 
|  | 11 | + # !!!This solution only renders the F3D viewer, as it uses EXTERNAL, so controls need to be defined!!! | 
|  | 12 | + def __init__(self): | 
|  | 13 | + super().__init__() | 
|  | 14 | + self.mEngine = None | 
|  | 15 | + | 
|  | 16 | + # Initialize F3D | 
|  | 17 | + def initgl(self): | 
|  | 18 | + self.mEngine = f3d.Engine(f3d.Window.Type.EXTERNAL) | 
|  | 19 | + self.mEngine.loader.load_geometry(f3d.Mesh( | 
|  | 20 | + points=[0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0], | 
|  | 21 | + face_sides=[3], | 
|  | 22 | + face_indices=[0, 1, 2], | 
|  | 23 | + ) | 
|  | 24 | + ) | 
|  | 25 | + | 
|  | 26 | + def redraw(self): | 
|  | 27 | + self.mEngine.window.render() | 
|  | 28 | + | 
|  | 29 | + | 
|  | 30 | +# Create main window and define size, position and title | 
|  | 31 | +root = tk.Tk() | 
|  | 32 | +root.geometry('640x480+100+100') | 
|  | 33 | +root.title('LanPtr3D') | 
|  | 34 | +F3D = Frame() | 
|  | 35 | +F3D.pack(fill=tk.BOTH, expand=tk.YES) | 
|  | 36 | + | 
|  | 37 | +# Run TKinter mainloop | 
|  | 38 | +root.mainloop() | 
0 commit comments