From 8d3ca0e4bb5c9ba25b6528325410108f1e5d2761 Mon Sep 17 00:00:00 2001 From: Abdur-RahmaanJ Date: Tue, 10 Oct 2023 11:36:34 +0400 Subject: [PATCH 1/3] docs: Add tutorials --- doc/tutorials/01-install.rst | 146 +++++++++++++++++ doc/tutorials/01-window.rst | 21 --- doc/tutorials/02-sizehints.rst | 21 --- doc/tutorials/02-window.rst | 59 +++++++ doc/tutorials/03-weighthints.rst | 62 +++++++ doc/tutorials/04-alignhints.rst | 122 ++++++++++++++ doc/tutorials/05-images.rst | 100 ++++++++++++ doc/tutorials/06-naviframe.rst | 84 ++++++++++ doc/tutorials/07-elmextensions.rst | 103 ++++++++++++ doc/tutorials/08-lists.rst | 169 ++++++++++++++++++++ doc/tutorials/09-genericlist.rst | 98 ++++++++++++ doc/tutorials/10-customelementarywidget.rst | 63 ++++++++ 12 files changed, 1006 insertions(+), 42 deletions(-) create mode 100644 doc/tutorials/01-install.rst delete mode 100644 doc/tutorials/01-window.rst delete mode 100644 doc/tutorials/02-sizehints.rst create mode 100644 doc/tutorials/02-window.rst create mode 100644 doc/tutorials/03-weighthints.rst create mode 100644 doc/tutorials/04-alignhints.rst create mode 100644 doc/tutorials/05-images.rst create mode 100644 doc/tutorials/06-naviframe.rst create mode 100644 doc/tutorials/07-elmextensions.rst create mode 100644 doc/tutorials/08-lists.rst create mode 100644 doc/tutorials/09-genericlist.rst create mode 100644 doc/tutorials/10-customelementarywidget.rst diff --git a/doc/tutorials/01-install.rst b/doc/tutorials/01-install.rst new file mode 100644 index 00000000..19294f1a --- /dev/null +++ b/doc/tutorials/01-install.rst @@ -0,0 +1,146 @@ + +Tutorial 1 - Install +==================== + +Python-efl is the binding for EFL, an awesome and performance-obcessed +set of libraries. EFL stands for Enlightment Foundation Libraries. It +was started for the `Enlightment `__ +desktop project and developed into a set of libraries. This tutorial +shows how to install python-efl. + +Install Instructions +==================== + +First create a new folder called efl_dev + +.. code:: python + + mkdir efl_dev + cd efl_dev + +Then see `EFL +downloads `__ and +`Python-EFL `__ +downloads. + +See the version you want is available on both. Let's choose 1.25.0 for +this tutorial + +Download and extract both + +.. code:: python + + wget https://download.enlightenment.org/rel/libs/efl/efl-1.25.0.tar.xz + tar xvf efl-1.25.0.tar.xz + wget https://download.enlightenment.org/rel/bindings/python/python-efl-1.25.0.tar.xz + tar xvf python-efl-1.25.0.tar.xz + +Install EFL +----------- + +Now let us install EFL first. Let's install essentials + +.. code:: python + + sudo apt install build-essential check meson ninja-build + +and dependencies + +.. code:: python + + sudo apt install libssl-dev libsystemd-dev libjpeg-dev libglib2.0-dev libgstreamer1.0-dev liblua5.2-dev libfreetype6-dev libfontconfig1-dev libfribidi-dev libavahi-client-dev libharfbuzz-dev libibus-1.0-dev libx11-dev libxext-dev libxrender-dev libgl1-mesa-dev libopenjp2-7-dev libwebp-dev libgif-dev libtiff5-dev libpoppler-dev libpoppler-cpp-dev libspectre-dev libraw-dev librsvg2-dev libudev-dev libmount-dev libdbus-1-dev libpulse-dev libsndfile1-dev libxcursor-dev libxcomposite-dev libxinerama-dev libxrandr-dev libxtst-dev libxss-dev libgstreamer-plugins-base1.0-dev doxygen libscim-dev libxdamage-dev libwebp-dev libunwind-dev + +and what i found missing + +.. code:: python + + sudo apt install libluajit-5.1-dev + +change dir + +.. code:: python + + cd efl-1.25.0 + +Now let us build the project + +.. code:: python + + meson build + ninja -C build + sudo ninja -C build install + +You also have to make some files visible to pkgconfig. One way of doing +this is to open /etc/profile in a text editor as root (using for example +sudo nano /etc/profile) and add the following line to the end: + +.. code:: python + + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig + +You may also need to refresh your library path to make sure your apps +can find the EFL libraries: + +.. code:: python + + sudo ldconfig + +Install Python-EFL +------------------ + +.. code:: python + + cd ../python-efl-1.25.0 + +Install python3-dev or corresponding. I was using Python3.9 so i did + +.. code:: python + + sudo apt install python3.9-dev + +also python dbus + +.. code:: python + + sudo apt install python-dbus-dev + +Then create and activate virtual environment + +.. code:: python + + python3.9 -m venv venv + . venv/bin/activate + +Install cython + +.. code:: python + + pip install cython + +Now build the package + +.. code:: python + + python setup.py build + +and install + +.. code:: python + + python setup.py install + +Conclusion +---------- + +Now if you run pip freeze you should get something similar + +.. code:: python + + Cython==0.29.24 + python-efl==1.25.0 + +refs: + +* https://www.enlightenment.org/docs/distros/ubuntu-start.md + +* https://git.enlightenment.org/bindings/python/python-efl.git/tree/INSTALL \ No newline at end of file diff --git a/doc/tutorials/01-window.rst b/doc/tutorials/01-window.rst deleted file mode 100644 index def5ae59..00000000 --- a/doc/tutorials/01-window.rst +++ /dev/null @@ -1,21 +0,0 @@ - -Tutorial 1 - Window -=================== - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mattis id dui -vitae lobortis. Fusce et tempus ipsum. Nulla non luctus urna. Pellentesque et -luctus diam. Etiam fermentum vestibulum nisi, eget vestibulum turpis aliquet vitae. -Integer interdum enim eu lacus pulvinar malesuada. Ut urna mi, congue non -pellentesque id, varius eget diam. Ut placerat neque sed orci tincidunt consequat. -Cras fermentum fringilla pulvinar. Ut tempor turpis odio. - -Vivamus sed magna tempor orci pharetra dapibus. Phasellus est elit, rhoncus -vitae consequat id, semper at ligula. Sed vitae odio tempor, maximus mi placerat, -faucibus metus. Quisque eget mauris quis ex gravida iaculis finibus vitae arcu. -Morbi non porttitor velit. Nullam pretium ex neque, ac malesuada felis dapibus -sodales. Pellentesque tristique est vel accumsan lobortis. Curabitur viverra -diam sit amet odio tincidunt pellentesque. Vestibulum non eros orci. Aliquam -accumsan convallis ullamcorper. Donec tristique massa nec massa venenatis tempus. -Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos -himenaeos. Aliquam augue nibh, viverra at urna in, lacinia maximus leo. -Nullam vestibulum lobortis elementum. \ No newline at end of file diff --git a/doc/tutorials/02-sizehints.rst b/doc/tutorials/02-sizehints.rst deleted file mode 100644 index dec5ba7e..00000000 --- a/doc/tutorials/02-sizehints.rst +++ /dev/null @@ -1,21 +0,0 @@ - -Tutorial 2 - Size Hints -======================= - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mattis id dui -vitae lobortis. Fusce et tempus ipsum. Nulla non luctus urna. Pellentesque et -luctus diam. Etiam fermentum vestibulum nisi, eget vestibulum turpis aliquet vitae. -Integer interdum enim eu lacus pulvinar malesuada. Ut urna mi, congue non -pellentesque id, varius eget diam. Ut placerat neque sed orci tincidunt consequat. -Cras fermentum fringilla pulvinar. Ut tempor turpis odio. - -Vivamus sed magna tempor orci pharetra dapibus. Phasellus est elit, rhoncus -vitae consequat id, semper at ligula. Sed vitae odio tempor, maximus mi placerat, -faucibus metus. Quisque eget mauris quis ex gravida iaculis finibus vitae arcu. -Morbi non porttitor velit. Nullam pretium ex neque, ac malesuada felis dapibus -sodales. Pellentesque tristique est vel accumsan lobortis. Curabitur viverra -diam sit amet odio tincidunt pellentesque. Vestibulum non eros orci. Aliquam -accumsan convallis ullamcorper. Donec tristique massa nec massa venenatis tempus. -Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos -himenaeos. Aliquam augue nibh, viverra at urna in, lacinia maximus leo. -Nullam vestibulum lobortis elementum. diff --git a/doc/tutorials/02-window.rst b/doc/tutorials/02-window.rst new file mode 100644 index 00000000..75c00261 --- /dev/null +++ b/doc/tutorials/02-window.rst @@ -0,0 +1,59 @@ + +Tutorial 2 - Window +=================== + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +Simple window + +Be sure to read first: + +`How to install Python-efl on Ubuntu or Linux +Mint `__ + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-1-hello-elementary-022415/ + ''' + import efl.elementary as elm + from efl.elementary.label import Label + from efl.elementary.window import StandardWindow + from efl.evas import EVAS_HINT_EXPAND + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex1", "Hello Elementary", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + label = Label(self) + label.size_hint_weight = EXPAND_BOTH + label.text = "Hello Elementary!" + label.show() + self.resize_object_add(label) + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() + +Note: elm.shutdown is no longer needed as per the docs which says + +.. code:: python + + .. versionchanged:: 1.14 + + The Python module calls this function when it is exiting so you + should no longer have any need to call this manually. Calling it does + not carry any penalty though. + +Updated from Jeff Hoogland's tutos diff --git a/doc/tutorials/03-weighthints.rst b/doc/tutorials/03-weighthints.rst new file mode 100644 index 00000000..944f54db --- /dev/null +++ b/doc/tutorials/03-weighthints.rst @@ -0,0 +1,62 @@ +Tutorial 3 - Weight Hints +========================= + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +Callback demo + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-2-weight-hints-031215/ + ''' + + import efl.elementary as elm + from efl.elementary.box import Box + from efl.elementary.button import Button + from efl.elementary.label import Label + from efl.elementary.window import StandardWindow + from efl.evas import EVAS_HINT_EXPAND + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex1", "Good Bye Elementary", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + our_label = Label(self) + our_label.size_hint_weight = EXPAND_BOTH + our_label.text = "Hello Elementary!" + our_label.show() + + our_button = Button(self) + our_button.size_hint_weight = EXPAND_BOTH + our_button.text = "Good Bye Elementary!" + our_button.callback_clicked_add(self.button_pressed) + our_button.show() + + our_box = Box(self) + our_box.size_hint_weight = EXPAND_BOTH + our_box.pack_end(our_label) + our_box.pack_end(our_button) + our_box.show() + + self.resize_object_add(our_box) + + def button_pressed(self, btn): + elm.exit() + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() + elm.shutdown() + diff --git a/doc/tutorials/04-alignhints.rst b/doc/tutorials/04-alignhints.rst new file mode 100644 index 00000000..35535afd --- /dev/null +++ b/doc/tutorials/04-alignhints.rst @@ -0,0 +1,122 @@ +Tutorial 4 - Align Hints +======================== + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-3-align-hints-041415/ + ''' + + import efl.elementary as elm + from efl.elementary.box import Box + from efl.elementary.button import Button + from efl.elementary.window import StandardWindow + from efl.evas import EVAS_HINT_EXPAND + from efl.evas import EVAS_HINT_FILL + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex3", "Weight Example", size=(300, 400)) + self.callback_delete_request_add(lambda o: elm.exit()) + + our_button = Button(self) + our_button.size_hint_weight = (0, 0) + our_button.size_hint_align = FILL_BOTH + our_button.text = "Button 1" + our_button.show() + + our_button2 = Button(self) + our_button2.size_hint_weight = EXPAND_BOTH + our_button2.size_hint_align = FILL_BOTH + our_button2.text = "Button 2" + our_button2.show() + + our_button3 = Button(self) + our_button3.size_hint_weight = (0, 0.5) + our_button3.size_hint_align = FILL_BOTH + our_button3.text = "Button 3" + our_button3.show() + + our_box = Box(self) + our_box.size_hint_weight = EXPAND_BOTH + our_box.pack_end(our_button) + our_box.pack_end(our_button2) + our_box.pack_end(our_button3) + our_box.show() + + self.resize_object_add(our_box) + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() + +2nd version + +.. code:: python + + import efl.elementary as elm + from efl.elementary.box import Box + from efl.elementary.button import Button + from efl.elementary.window import StandardWindow + from efl.evas import EVAS_HINT_EXPAND + from efl.evas import EVAS_HINT_FILL + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex4", "Align Example", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + + our_button = Button(self) + our_button.size_hint_weight = EXPAND_BOTH + our_button.size_hint_align = (0, 0) + # our_button.size_hint_align = (EVAS_HINT_FILL, 0) + our_button.text = "Button 1" + + our_button.show() + our_button2 = Button(self) + our_button2.size_hint_weight = EXPAND_BOTH + our_button2.size_hint_align = FILL_BOTH + our_button2.text = "Button 2" + our_button2.show() + + our_button3 = Button(self) + our_button3.size_hint_weight = EXPAND_BOTH + our_button3.size_hint_align = (1, 1) + our_button3.text = "Button 3" + our_button3.show() + + our_box = Box(self) + our_box.size_hint_weight = EXPAND_BOTH + our_box.pack_end(our_button) + our_box.pack_end(our_button2) + our_box.pack_end(our_button3) + our_box.show() + + self.resize_object_add(our_box) + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() + + diff --git a/doc/tutorials/05-images.rst b/doc/tutorials/05-images.rst new file mode 100644 index 00000000..66fbd307 --- /dev/null +++ b/doc/tutorials/05-images.rst @@ -0,0 +1,100 @@ +Tutorial 5 - Images +=================== + + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-4-displaying-images-042415/ + + Needs one image called image.png + ''' + + import efl.elementary as elm + from efl.elementary.image import Image + from efl.elementary.label import Label + from efl.elementary.window import StandardWindow + from efl.evas import EVAS_HINT_EXPAND + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex1", "Hello Elementary", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + our_image = Image(self) + our_image.size_hint_weight = EXPAND_BOTH + our_image.file_set("image.png") + our_image.tooltip_text_set("A picture!") + our_image.show() + self.resize_object_add(our_image) + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() + +Select image + +.. code:: python + + import os + import efl.elementary as elm + from efl.elementary.window import StandardWindow + from efl.elementary.image import Image + from efl.elementary.box import Box + from efl.elementary.fileselector_button import FileselectorButton + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex6", "Selected Image", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + self.our_image = our_image = Image(self) + our_image.size_hint_weight = EXPAND_BOTH + our_image.size_hint_align = FILL_BOTH + our_image.file_set("image.png") + our_image.tooltip_text_set("A picture!") + our_image.show() + + our_button = FileselectorButton(self) + our_button.size_hint_weight = EXPAND_HORIZ + our_button.text = "Select new Image" + our_button.callback_file_chosen_add(self.file_selected) + our_button.show() + + our_box = Box(self) + our_box.size_hint_weight = EXPAND_BOTH + our_box.pack_end(our_image) + our_box.pack_end(our_button) + our_box.show() + self.resize_object_add(our_box) + + def file_selected(self, fsb, selected_file): + if selected_file: + valid_extensions = [".png", ".jpg", ".gif"] + file_name, file_extension = os.path.splitext(selected_file) + if file_extension in valid_extensions: + self.our_image.file_set(selected_file) + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() diff --git a/doc/tutorials/06-naviframe.rst b/doc/tutorials/06-naviframe.rst new file mode 100644 index 00000000..75b6907b --- /dev/null +++ b/doc/tutorials/06-naviframe.rst @@ -0,0 +1,84 @@ +Tutorial 6 - Naviframe +====================== + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-5-naviframe-070115/ + ''' + + import efl.elementary as elm + from efl.elementary.window import StandardWindow + from efl.elementary.image import Image + from efl.elementary.label import Label + from efl.elementary.button import Button + from efl.elementary.box import Box + from efl.elementary.naviframe import Naviframe + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex7", "Naviframe", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + static_image = static_image = Image(self) + static_image.size_hint_weight = EXPAND_BOTH + static_image.file_set("image.png") + static_image.tooltip_text_set("A picture!") + static_image.show() + + our_label = our_label = Label(self) + our_label.size_hint_weight = EXPAND_BOTH + our_label.text = "Hey look some text!" + our_label.show() + + self.nf = Naviframe(self) + self.nf.size_hint_weight = EXPAND_BOTH + self.nf.size_hint_align = FILL_BOTH + self.nf.show() + + button_one = Button(self) + button_one.size_hint_weight = EXPAND_BOTH + button_one.text = "Show image" + button_one.callback_clicked_add(self.button_pressed, static_image) + button_one.show() + + button_two = Button(self) + button_two.size_hint_weight = EXPAND_BOTH + button_two.text = "Show label" + button_two.callback_clicked_add(self.button_pressed, our_label) + button_two.show() + + button_box = Box(self) + button_box.size_hint_weight = EXPAND_HORIZ + button_box.horizontal_set(True) + button_box.pack_end(button_one) + button_box.pack_end(button_two) + button_box.show() + + main_box = Box(self) + main_box.size_hint_weight = EXPAND_BOTH + main_box.pack_end(self.nf) + main_box.pack_end(button_box) + main_box.show() + + self.nf.item_simple_push(static_image) + self.resize_object_add(main_box) + def button_pressed(self, btn, our_object): + self.nf.item_simple_push(our_object) + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() diff --git a/doc/tutorials/07-elmextensions.rst b/doc/tutorials/07-elmextensions.rst new file mode 100644 index 00000000..f8a7b4f4 --- /dev/null +++ b/doc/tutorials/07-elmextensions.rst @@ -0,0 +1,103 @@ +Tutorial 7 - Elm Extensions +=========================== + + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +To follow this tutorial, download/clone `this +repo `__ and pip +install it + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-6-elmextensions-110115/ + ''' + + ''' + extentions + ''' + + AUTHORS = """ +
+ + Jeff Hoogland (Jef91)
+ Contact

+ + """ + + LICENSE = """ + + + GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007

+
+ This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version.

+ This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details.

+ You should have received a copy of the GNU General Public License + along with this program. If not, see
+ http://www.gnu.org/licenses/ + + """ + + INFO = """ + + Elementary Python Extensions are awesome!
+
+
+ + """ + import efl.elementary as elm + from efl.elementary.window import StandardWindow + from efl.elementary.box import Box + + from elmextensions import StandardButton + from elmextensions import StandardPopup + from elmextensions import AboutWindow + + + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex8", "ElmEx - Button and Popup", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + + our_button = StandardButton(self, "Show Popup", cb_onclick=self.button_pressed) + our_button.size_hint_weight = EXPAND_HORIZ + our_button.size_hint_align = FILL_BOTH + our_button.show() + + + main_box = Box(self) + main_box.size_hint_weight = EXPAND_BOTH + main_box.size_hint_align = FILL_BOTH + main_box.pack_end(our_button) + main_box.show() + + self.resize_object_add(main_box) + + def button_pressed(self, btn): + ourPopup = StandardPopup(self, "Press OK to close this message.", "ok") + ourPopup.show() + + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() diff --git a/doc/tutorials/08-lists.rst b/doc/tutorials/08-lists.rst new file mode 100644 index 00000000..50628806 --- /dev/null +++ b/doc/tutorials/08-lists.rst @@ -0,0 +1,169 @@ +Tutorial 8 - Lists +================== + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/pyefl-tutorial-7-lists-111115/ + ''' + + import efl.elementary as elm + from efl.elementary.window import StandardWindow + from efl.elementary.list import List + + from elmextensions import StandardPopup + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + list_items = ["Apples", + "Bananas", + "Cookies", + "Fruit Loops", + "Milk", + "Apple Juice", + "BBQ Sauce", + "Nesquik", + "Trail Mix", + "Chips", + "Crackers", + "Cheese", + "Peanutbutter", + "Jelly", + "Ham", + "Turkey", + "Potatos", + "Stuffing", + "Tomato Sauce", + "Pineapple", + "Hot Dog Chili Sauce", + "Stewed Tomatoes", + "Creamed Corn", + "Cream of Mushroom Soup", + "Peaches", + "Chilies and Tomatoes", + "Cream of Chicken Soup", + "Cherry Pie Filling", + "Canned Beans (various)", + "Cream of Tomato Soup", + "Apple Pie Filling", + "Canned Peas", + "Green Beans" + ] + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex9", "List", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + + our_list = List(self) + our_list.size_hint_weight = EXPAND_BOTH + our_list.callback_activated_add(self.list_item_selected) + + list_items.sort() + + for it in list_items: + our_list.item_append(it) + + our_list.go() + our_list.show() + + self.resize_object_add(our_list) + + def list_item_selected(self, our_list, our_item): + our_popup = StandardPopup(self, "You selected %s"%our_item.text, "ok") + our_popup.show() + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() + +Searcheable list + +.. code:: python + + import efl.elementary as elm + from efl.elementary.window import StandardWindow + + from elmextensions import SearchableList + from elmextensions import StandardPopup + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + + + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + list_items = ["Apples", + "Bananas", + "Cookies", + "Fruit Loops", + "Milk", + "Apple Juice", + "BBQ Sauce", + "Nesquik", + "Trail Mix", + "Chips", + "Crackers", + "Cheese", + "Peanutbutter", + "Jelly", + "Ham", + "Turkey", + "Potatos", + "Stuffing", + "Tomato Sauce", + "Pineapple", + "Hot Dog Chili Sauce", + "Stewed Tomatoes", + "Creamed Corn", + "Cream of Mushroom Soup", + "Peaches", + "Chilies and Tomatoes", + "Cream of Chicken Soup", + "Cherry Pie Filling", + "Canned Beans (various)", + "Cream of Tomato Soup", + "Apple Pie Filling", + "Canned Peas", + "Green Beans" + ] + + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex10", "Searchable List", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + + search_list = SearchableList(self) + search_list.size_hint_weight = EXPAND_BOTH + search_list.lst.callback_activated_add(self.list_item_selected) + + list_items.sort() + + for it in list_items: + search_list.item_append(it) + + search_list.show() + + self.resize_object_add(search_list) + + def list_item_selected(self, ourList, our_item): + our_popup = StandardPopup(self, "You selected %s"%our_item.text, "ok") + our_popup.show() + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() diff --git a/doc/tutorials/09-genericlist.rst b/doc/tutorials/09-genericlist.rst new file mode 100644 index 00000000..b0e28ca7 --- /dev/null +++ b/doc/tutorials/09-genericlist.rst @@ -0,0 +1,98 @@ +Tutorial 9 - Generic List +========================= + + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/programming/blogs/pyefl-tutorial-8-genlist-120215/ + ''' + + import efl.elementary as elm + from efl.elementary.window import StandardWindow + from efl.elementary.genlist import Genlist, GenlistItem, GenlistItemClass + + from elmextensions import StandardPopup + + ListItems = ["Apples", + "Bananas", + "Cookies", + "Fruit Loops", + "Milk", + "Apple Juice", + "BBQ Sauce", + "Nesquik", + "Trail Mix", + "Chips", + "Crackers", + "Cheese", + "Peanutbutter", + "Jelly", + "Ham", + "Turkey", + "Potatos", + "Stuffing", + "Tomato Sauce", + "Pineapple", + "Hot Dog Chili Sauce", + "Stewed Tomatoes", + "Creamed Corn", + "Cream of Mushroom Soup", + "Peaches", + "Chilies and Tomatoes", + "Cream of Chicken Soup", + "Cherry Pie Filling", + "Canned Beans (various)", + "Cream of Tomato Soup", + "Apple Pie Filling", + "Canned Peas", + "Green Beans" + ] + + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + class GLIC(GenlistItemClass): + def __init__(self): + GenlistItemClass.__init__(self, item_style="default") + + def text_get(self, gl, part, data): + return data["itemName"] + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex11", "Genlist List", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + + our_list = Genlist(self) + our_list.size_hint_weight = EXPAND_BOTH + our_list.callback_activated_add(self.list_item_selected) + + ListItems.sort() + + for it in ListItems: + li = GenlistItem(item_data={"itemName":it}, item_class=GLIC()) + li.append_to(our_list) + + our_list.show() + + self.resize_object_add(our_list) + + def list_item_selected(self, our_list, our_item): + our_popup = StandardPopup(self, "You selected %s"%our_item.data["itemName"], "ok") + our_popup.show() + + if __name__ == "__main__": + elm.init() + gui = MainWindow() + gui.show() + elm.run() diff --git a/doc/tutorials/10-customelementarywidget.rst b/doc/tutorials/10-customelementarywidget.rst new file mode 100644 index 00000000..cbc89f9b --- /dev/null +++ b/doc/tutorials/10-customelementarywidget.rst @@ -0,0 +1,63 @@ +Tutorial 10 - Custom Elementary Widget +====================================== + +Python-EFL is a wrapper around the Enlightenment GUI kit. This series of +tutorials is an update from the original author. + +.. code:: python + + ''' + Abdur-Ramaan Janhangeer + Updated from Jeff Hoogland's tutos + for Python3.9 and Python-elf 1.25.0 + + https://www.toolbox.com/tech/operating-systems/blogs/py-efl-tutorial-9-custom-elementary-widgets-020116/ + ''' + + import efl.elementary as elm + from efl.elementary.window import StandardWindow + from efl.elementary.frame import Frame + from efl.elementary.image import Image + + + from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL + EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0 + FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL + + class PictureFrame(Frame): + def __init__(self, parent_widget, ourText=None, image=None, *args, **kwargs): + Frame.__init__(self, parent_widget, *args, **kwargs) + + self.text = ourText + + self.our_image = Image(self) + self.our_image.size_hint_weight = EXPAND_BOTH + + if image: + self.our_image.file_set(image) + + self.content_set(self.our_image) + + def file_set(self, image): + self.our_image.file_set(image) + + class MainWindow(StandardWindow): + def __init__(self): + StandardWindow.__init__(self, "ex12", "Custom Widget", size=(300, 200)) + self.callback_delete_request_add(lambda o: elm.exit()) + + our_picture_frame = PictureFrame(self) + our_picture_frame.size_hint_weight = EXPAND_BOTH + our_picture_frame.text = "A Custom Picture Frame" + our_picture_frame.file_set("image.png") + our_picture_frame.show() + + self.resize_object_add(our_picture_frame) + + if __name__ == "__main__": + elm.init() + GUI = MainWindow() + GUI.show() + elm.run() + elm.shutdown() From faf9f383cc6a0b668bc51590acc2627e32c64e4c Mon Sep 17 00:00:00 2001 From: Abdur-RahmaanJ Date: Tue, 10 Oct 2023 11:38:24 +0400 Subject: [PATCH 2/3] docs(README): Refer to tutorials in install section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 74a0936d..e86b0f81 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ EFL, or the *Enlightenment Foundation Libraries*, is a collection of libraries f Python-EFL are the python bindings for the whole EFL stack (evas, ecore, edje, emotion, ethumb and elementary). You can use Python-EFL to build a portable GUI application in minutes. -The documentation for Python-EFL is available [here](https://docs.enlightenment.org/python-efl/current/). +The documentation for Python-EFL is available [here](https://docs.enlightenment.org/python-efl/current/). The tutorials section includes a ubuntu / mint install tutorial. ## Install from pypi From a61f4d8a3d6270aaa9ce9ce68b9721531cf797d6 Mon Sep 17 00:00:00 2001 From: Abdur-RahmaanJ Date: Thu, 12 Oct 2023 11:32:47 +0400 Subject: [PATCH 3/3] docs: remove Jeff blog's links --- doc/tutorials/02-window.rst | 2 -- doc/tutorials/03-weighthints.rst | 2 -- doc/tutorials/04-alignhints.rst | 2 -- doc/tutorials/05-images.rst | 2 -- doc/tutorials/06-naviframe.rst | 2 -- doc/tutorials/07-elmextensions.rst | 6 ------ doc/tutorials/08-lists.rst | 2 -- doc/tutorials/09-genericlist.rst | 2 -- doc/tutorials/10-customelementarywidget.rst | 2 -- 9 files changed, 22 deletions(-) diff --git a/doc/tutorials/02-window.rst b/doc/tutorials/02-window.rst index 75c00261..76a54fbb 100644 --- a/doc/tutorials/02-window.rst +++ b/doc/tutorials/02-window.rst @@ -18,8 +18,6 @@ Mint