Skip to content

Commit

Permalink
restructure components modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-morel committed Sep 25, 2024
1 parent 35f6c3d commit 75d61ba
Show file tree
Hide file tree
Showing 25 changed files with 76,307 additions and 1,126 deletions.
Binary file modified docs/_static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
from dataclasses import asdict
from pathlib import Path

# Register the lexer with Pygments
from pygments.lexers import get_all_lexers
from sphinxawesome_theme import LinkIcon, ThemeOptions
from sphinxawesome_theme.postprocess import Icons
from taktk.lexer import TaktlLexer

# For the full list of built-in configuration values, see the documentation:
# Forlthe full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

if __name__ == "__main__":
Expand Down Expand Up @@ -65,7 +68,7 @@
# docsearch_api_key = "<DOCSEARCH_SEARCH_API_KEY>"
# docsearch_index_name = "<DOCSEARCH_INDEX_NAME>"

prolog = """\
rst_prolog = """\
.. role:: python(code)
:language: python
:class: highlight"""
11 changes: 9 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ Easily create and manage notifications in your application using taktk's built-i

- Customizable notification duration
- Support for icons
- Flexible positioning options

Example::
..
from taktk import notify

Expand All @@ -142,6 +141,12 @@ Example::
duration="5000",
icon="path/to/update_icon.png")

.. code-block:: taktl
!enum ama:(d, j)
\frame yeah={colorama} padding=34
\dkfkl k
Getting Started
---------------
- :doc:`installation`
Expand All @@ -155,4 +160,6 @@ Getting Started
:caption: Contents:

installation
quickstart
tutorials/index
whatsnew
32 changes: 32 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Quickstart
==================================================

To setup you taktk project there are two modes of uses:

- :ref:`as-a-library`
- :ref:`as-a-framework`


As a library
--------------------------------------------------

Taktk supports using it's different components separately.

.. code-block:: python
from tkinter import Tk
from taktk.component import component
@component
def Widget(self):
r"""
\frame
\label text="Hello world" font={text_font} pos:pack
"""
text_font = "Arial 20"
return locals()
root = Tk()
Widget().render(root).pack()
root.mainloop()
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinxawesome_theme
sphinx-docsearch
git+https://github.com/ken-morel/taktk
83 changes: 83 additions & 0 deletions examples/load_obj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import tkinter
from tkinter_gl import GLCanvas
import pywavefront
try:
from OpenGL import GL
except ImportError:
raise ImportError(
"""
This example requires PyOpenGL.
You can install it with "pip install PyOpenGL".
""")

"""
Shows a square that can be moved with the cursor keys and whose size
can be controlled by a slider.
Shows how to do "animation", that is repeatedly calling draw using the
elapsed time to compute how far the square has moved. Also tests that
we correctly update the GLCanvas to slider events.
"""


class ObjView(GLCanvas):
profile = 'legacy'

def __init__(self, parent):
super().__init__(parent, width=500, height=500)

self.size = 0.5

# Position of square.
self.x = 0.0
self.y = 0.0
self.scene = pywavefront.Wavefront('noseman.obj', collect_faces=True)


def draw(self):
self.make_current()

GL.glViewport(0, 0, self.winfo_width(), self.winfo_height())
GL.glClearColor(0, 0, 0, 1)
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glRotatef(5, 1, 1, 1)

GL.glBegin(GL.GL_TRIANGLES)
for face in self.scene.meshes['Quad_Sphere'].faces:
for vertex in face:
vertex = self.scene.vertices[vertex]
x, y, z = vertex
GL.glVertex3f(z / 5, y / 5, z / 5)
print("showing your model...")
GL.glEnd()
# GL.glTranslate(0, 0, 0.1)

while True:
err = GL.glGetError()
if err == GL.GL_NO_ERROR:
break
print("Error: ", err)

self.swap_buffers()



if __name__ == '__main__':

root = tkinter.Tk()
view = ObjView(root)
view.pack()


root.columnconfigure(1, weight=1)

print("Using OpenGL", view.gl_version())

def update():
view.draw()
root.after(1, update)

root.after(1, update)
root.mainloop()

10 changes: 10 additions & 0 deletions examples/maps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Tkmap example."""
from tkmap import model, widget

canvas = widget.Tkmap()
canvas.pack(fill="both", expand=True)
canvas.open(
model.MapModel.load("openstreetmap"),
zoom=10,
location=(48.645272, 1.841411),
)
Binary file added examples/model.glb
Binary file not shown.
Binary file added examples/noseman.blend
Binary file not shown.
12 changes: 12 additions & 0 deletions examples/noseman.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Blender 3.3.19 MTL File: 'noseman.blend'
# www.blender.org

newmtl Material
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
Loading

0 comments on commit 75d61ba

Please sign in to comment.