demos/04_texteditor.py
author Radek Brich <radek.brich@devl.cz>
Wed, 03 Sep 2014 21:56:20 +0200
changeset 113 6796adfdc7eb
parent 106 abcadb7e2ef1
child 115 b4ff7392003a
permissions -rwxr-xr-x
Merge. Due to my schizophrenia, I've accidentally forked my own code. The other set of changes were found in another computer.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
     3
import demobase
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
     5
from tuikit.core.application import Application
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
     6
#from tuikit.scrollview import ScrollView
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
     7
from tuikit.widgets.textbox import TextBox
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
class MyApplication(Application):
106
abcadb7e2ef1 Use Point for mouse events, add them to Container and Widget.
Radek Brich <radek.brich@devl.cz>
parents: 96
diff changeset
    11
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
    def __init__(self):
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
        Application.__init__(self)
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    14
        #self.top.add_handler('keypress', self.on_top_keypress)
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    16
        t = open('../tuikit/core/widget.py').read()
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    17
        editbox = TextBox(t)
76
fa5301e58eca Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    18
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    19
        #scroll = ScrollView()
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    20
        #scroll.add(editbox)
76
fa5301e58eca Update demo_input, demo_editor. Update ScrollView: show/hide scrollbars as needed on child size requests.
Radek Brich <radek.brich@devl.cz>
parents: 62
diff changeset
    21
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    22
        self.root_window.add(editbox)
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 76
diff changeset
    23
        #self.root_window.add(scroll, halign='fill', valign='fill')
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
41
37b7dfc3eae6 Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    25
    def on_top_keypress(self, ev):
37b7dfc3eae6 Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    26
        if ev.keyname == 'escape':
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
            self.terminate()
45
43b2279b06e1 Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents: 41
diff changeset
    28
            return True
2
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
if __name__ == '__main__':
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
    app = MyApplication()
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
    app.start()
684cdc352562 Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34