Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1def35

Browse files
Merge pull request #36 from JPLost/patch-1
Add tkinter+f3d example file
2 parents 67e1629 + 90df26a commit a1def35

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎examples/tkinter_f3d.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /