Jump to content

Photo

Tutorials for Getting started with Python and Elementary


  • Please log in to reply
30 replies to this topic

#1 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 24 February 2015 - 05:45 AM

I've restarted my tutorial series on my blog about creating Elementary applications using Python.

 

Index Page -> http://jeffhoogland..../elm-tutorials/





A big thank you to everyone who contributes to Bodhi Linux


#2 kuuko

kuuko

    Powerful E Wizard

  • Developer
  • 229 posts
  • LocationHelsinki, Finland

Posted 24 February 2015 - 09:19 PM

Hey it's great that you wrote this, it will help people find Python-EFL and I'm happy about that. Simple and clear, expanding knowledge & skill base slowly. Well written.

Here's some issues I noticed, and corrections, please do tell if I didn't explain them well enough.

from efl.evas import EVAS_HINT_EXPAND

EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND

When you assign the “weight” property of a widget to our “EXPAND_BOTH” value that widget will fill the space that is available in your window.


The weight size hint will make the object use an area in a container with weighted value, for example when you have two objects in a horizontal box with size_hint_weight=(0.6, EVAS_HINT_EXPAND) and size_hint_weight=(0.4, EVAS_HINT_EXPAND) it will do a 60%:40% split horizontally. EVAS_HINT_EXPAND is shorthand for 1.0, which will weigh the objects equally.

Align size hint will align within the area assigned to the object, 0.0 is left/top, 0.5 is center, 1.0 is right/bottom. If the assigned area is the same size as the space that the object uses, it won't obviously align anywhere at all. EVAS_HINT_FILL is shorthand for the special value -1.0 which makes the object fill its assigned area entirely.
 

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 third line inherits all of the StandardWindow properties to our MainWindow class.

The class definition header on the first line tells Python to pick up the class attributes from the parent class, the third line initializes the parent object instance.
 

The first argument for StandardWindow is the window name and the second argument is the visible title for the window. We also pass an optional size argument when creating our window that defines the starting width and height dimensions.

Maybe explain here shortly that you can use any property as keyword arg name, and the value is assigned to that property?
 

The last line of our MainWindow class adds the Label we have created to the window:

self.resize_object_add(ourLabel)

This is not true. The object gets added to the window when you initialize it, then you need to set its size and position. What we do here is binding the objects size and position to the windows area, whenever you resize the window it will also resize the label object!
 

The fifth line starts our Elementary mainloop. This is what keeps your application running until the exit() function is called. Without calling this, the Elementary window you have created will never run.

Explain this better? Maybe in a later example? The main loop processes events, signals, etc. and allow the canvas to render, when it's not busy it will enter an idle state (ie. sleep, saving energy).


account_tiny.gif

#3 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 24 February 2015 - 09:30 PM

A lot of that is good additional detail. I kept a lot of my language intentionally basic to try and not overwhelm the people reading. Basic is best when getting started with something new.

I think weight/hints are complex enough that they can likely warrant their own piece with a few examples so I didn't want to really get into everything they could do here.



#4 kuuko

kuuko

    Powerful E Wizard

  • Developer
  • 229 posts
  • LocationHelsinki, Finland

Posted 24 February 2015 - 09:39 PM

The object that you pass with resize_object_add will also control the minimum and maximum size of your window.


account_tiny.gif

#5 kuuko

kuuko

    Powerful E Wizard

  • Developer
  • 229 posts
  • LocationHelsinki, Finland

Posted 24 February 2015 - 09:42 PM

Yes most of what I've written here you can explain in later examples. It's important though that your simple explanations convey the right general ideas about the concepts.


account_tiny.gif

#6 Kev

Kev

    An Aged Technophile

  • Members
  • 321 posts
  • LocationMichigan USA

Posted 02 March 2015 - 02:05 PM

... one of these days I really really need to start on learning this platform.


- Kevin

#7 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 12 March 2015 - 05:23 PM

Second tutorial talking about weight hints this time -> http://it.toolbox.co...ght-hints-65905



#8 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 24 April 2015 - 09:44 AM

Updated the first post with a link to the index page I've just thrown up -> http://jeffhoogland..../elm-tutorials/

 

It has four tutorials present now :D



#9 aka jazz

aka jazz

    Member

  • Banned
  • 611 posts

Posted 24 April 2015 - 08:23 PM

Damn I better get my bodhi box before Jeff posts the next tutorial :ph34r: elive has video tutorials but I prefer this way, I can get to them without hogging resources


Screenshots of e17 at the Gallerie des shedied and here for just one only. Incidentally,why don't you try our friendly IRC channel for some help? (link up top) or watch an e-ducational clip that's 2 and a half minutes long

#10 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 24 April 2015 - 08:40 PM

Elive has video tutorials about EFL software development? Link?



#11 SmartDuck

SmartDuck

    Member

  • Members
  • 35 posts
  • LocationWaalwijk, the Netherlands

Posted 25 April 2015 - 06:41 PM

I'm learning Ruby now, did some Python programming years back. I saw there is a Ruby bindings project for EFL.


Dell Lattitude E4300 - Bodhi 4.1.0 - Main system

Dell Lattitude D505 - Arch - Minetest / Minecraft server

Compaq Armada 1590DT - DSL

Raspberry Pi B+ - Raspbian - Test

Raspberry Pi A+ / Arduino Nano - Raspbian - Greenhouse server


#12 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 27 April 2015 - 02:14 PM

I've never touched the ruby bindings so I'm not sure how well they are maintained or if anything even uses them.



#13 SmartDuck

SmartDuck

    Member

  • Members
  • 35 posts
  • LocationWaalwijk, the Netherlands

Posted 30 April 2015 - 09:28 PM

My Python skills are a bit rusty. :) 

The week after next I have three weeks time off. I will check the tutorials.


Dell Lattitude E4300 - Bodhi 4.1.0 - Main system

Dell Lattitude D505 - Arch - Minetest / Minecraft server

Compaq Armada 1590DT - DSL

Raspberry Pi B+ - Raspbian - Test

Raspberry Pi A+ / Arduino Nano - Raspbian - Greenhouse server


#14 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 01 May 2015 - 12:38 AM

Great. I should have a few more done by then.

#15 SmartDuck

SmartDuck

    Member

  • Members
  • 35 posts
  • LocationWaalwijk, the Netherlands

Posted 17 May 2015 - 07:04 PM

Completed the first tutorial Hello Elementary ...

 

In the second example the ident of the 

 def buttonPressed(self, btn):

        elm.exit()

is one space off.

 

The tutorial is crystal clear, easy to follow, great! :)

 

Tip for Eclipse users:

http://pydev.org/man...01_install.html

Works fine with the Eclipse 3.8 version from the repository.


Dell Lattitude E4300 - Bodhi 4.1.0 - Main system

Dell Lattitude D505 - Arch - Minetest / Minecraft server

Compaq Armada 1590DT - DSL

Raspberry Pi B+ - Raspbian - Test

Raspberry Pi A+ / Arduino Nano - Raspbian - Greenhouse server


#16 SmartDuck

SmartDuck

    Member

  • Members
  • 35 posts
  • LocationWaalwijk, the Netherlands

Posted 23 May 2015 - 09:03 AM

Finished the second tutorial. 

Expirimented with weights, something to get used to.

It works in a similar way as with Java for Android to divide the controls on the application window. 


Dell Lattitude E4300 - Bodhi 4.1.0 - Main system

Dell Lattitude D505 - Arch - Minetest / Minecraft server

Compaq Armada 1590DT - DSL

Raspberry Pi B+ - Raspbian - Test

Raspberry Pi A+ / Arduino Nano - Raspbian - Greenhouse server


#17 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 24 May 2015 - 02:05 AM

Thanks for the feedback. I'm hoping to hammer a few more of these this week.

#18 SmartDuck

SmartDuck

    Member

  • Members
  • 35 posts
  • LocationWaalwijk, the Netherlands

Posted 24 May 2015 - 08:48 AM

A tutorial on how to use multiple py files or how to create a package to distribute would be nice :).


Dell Lattitude E4300 - Bodhi 4.1.0 - Main system

Dell Lattitude D505 - Arch - Minetest / Minecraft server

Compaq Armada 1590DT - DSL

Raspberry Pi B+ - Raspbian - Test

Raspberry Pi A+ / Arduino Nano - Raspbian - Greenhouse server


#19 Jeff

Jeff

    Lead Developer

  • Developer
  • 12328 posts
  • LocationBloomington, IL

Posted 24 May 2015 - 01:10 PM

Creating a simple Debian package is on my list of tutorials to write, that is unrelated to pyefl tutorials though.

 

I'm unsure what you mean about multiple py files. There is nothing special about pyefl that needs extra tutorials about splitting things into multiple files.



#20 SmartDuck

SmartDuck

    Member

  • Members
  • 35 posts
  • LocationWaalwijk, the Netherlands

Posted 24 May 2015 - 03:35 PM

Ok, just the same as plain python. 

 

I finished all tutorials. 

In the last example it is not clear what fileName does, it is set by  fileName, fileExtension = os.path.splitext(selectedFile)

but I can't see how it is assigned to ourImage.

 

In Eclipse with PyDev you can simply press CTRL-SHIFT-F to format the code.

The idents of the example code messes up copy and pasting the code from the webpage.


Dell Lattitude E4300 - Bodhi 4.1.0 - Main system

Dell Lattitude D505 - Arch - Minetest / Minecraft server

Compaq Armada 1590DT - DSL

Raspberry Pi B+ - Raspbian - Test

Raspberry Pi A+ / Arduino Nano - Raspbian - Greenhouse server





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users