Forum Archive

I am trying to write Tkinter-like `GUI` library for iOS

JadedTuna

Hey everyone, ShadowSlayer here. I've decided to post this thread, to give myself a little motivation. I am trying to write Tkinter-like GUI library (on top of Scene of course!) for Pythonista. Wish me luck! I will post all my updates here.

P. S. Maybe I won't success in this project, but at least I am going to try :)

MartinPacker

Go for it. I certainly can find a use for it.

omz

Sounds like a fun (and challenging) project, though you might want to wait for the 1.5 update. There will be a ui module that might be more suitable for this than scene.

JadedTuna

@omz, maybe, but I'd better start with what I have right now. If I understand the logic (which I probably already did), I will be able to later rewrite the library, using the ui module :)

MartinPacker

If 1.5 is Real Soon Now I'd wait. I assume the ui module has some resemblance to other modules in the same area?

JadedTuna

Is there a way to force end the Scene? Like Scene().stop()?

filippocld223

yes. i think scene.end()

ccc

I was unable to find a Scene.end() method...

import inspect, scene
print('\n'.join([member[0] for member in inspect.getmembers(scene.Scene())]))

The other methods are documented in http://omz-software.com/pythonista/docs/ios/scene.html and Ole said he would add docs for Scene.stop() here: http://omz-forums.appspot.com/pythonista/post/5822369738260480 If you add a Scene.stop() method to your Scene, it will be called when the user clicks the X.

The only ways that I have found to really end a Scene are to tap the X in the upper right corner of the window or to launch another Scene. http://omz-forums.appspot.com/pythonista/post/5876387541942272

dgelessus

Not sure how close this is to what you're planning to do, but BashedCrab made a simple GUI toolkit named Hydrogen a while ago. You should probably take a look at it, it may be possible to build upon that instead of having to write everything up from scratch.

JadedTuna

Guys, thanks for your tips :).
I am done writing simple Button&StaticText and StaticLink widgets. I will upload the code tomorrow and post the link to it here.

JadedTuna

Ouch! I've got idea, how to implement Event system a little bit better. But I am getting very weird problems! Can someone help me? A bit hard to explain, you have to run file draggable_frame.py.

iGUI.py

draggable_frame.py

ccc

ImportError: No module named events

JadedTuna

@ccc, sorry. events file contains:

EVT_TOUCH_BEGAN = 1
EVT_TOUCH_MOVED = 2
EVT_TOUCH_ENDED = 3
ccc

I could not quite figure out how to help you but:

  1. You might want to look at some advise that Ole provided on draggable images: http://omz-forums.appspot.com/pythonista/post/5144563366756352
  2. You can safely remove the .keys() part of lines like:
        if not id in self.children.keys():
 # and
        return event_type in self.handlers.keys()

# can be rewritten as:
        if not id in self.children:
 # and
        return event_type in self.handlers

See key in dict at https://docs.python.org/2/library/stdtypes.html#dict

JadedTuna

Hey all, I am back. Sorry for not writing anything for so long, I had damn lot of exams. I've finally fixed the problem, and now I have this draggable frame. Gonna add some more stuff and post the first version here soon.