Update demos and tests.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo_editor.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+
+import os
+
+from tuikit.application import Application
+from tuikit.editfield import EditField
+from tuikit.window import Window
+from tuikit.button import Button
+from tuikit.scrollbar import VScrollbar
+from tuikit.textedit import TextEdit
+
+
+class MyApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.top.connect('keypress', self.globalkeypress)
+
+ #edit = EditField(50, 'DlouhyTest12')
+ #self.top.add(edit)
+
+
+ t = open('tuikit/widget.py').read()
+ textedit = TextEdit(100, 40, t)
+ self.top.add(textedit)
+ textedit.x = 2
+ self.textedit = textedit
+
+ #win = Window()
+ #self.top.add(win)
+
+ #button = Button('click!')
+ #win.add(button)
+ #button.x = 10
+ #button.y = 7
+
+ #button.connect('click', self.buttonclick)
+ #self.button = button
+
+ #subwin = Window(8,8)
+ #win.add(subwin)
+
+
+ def buttonclick(self):
+ self.button.label = 'YES'
+
+
+ def globalkeypress(self, keyname, char):
+ if keyname == 'escape':
+ self.terminate()
+ if keyname == 'f1':
+ self.textedit.settext('%s' % self.top.focuschild)
+ self.textedit.redraw()
+
+
+
+if __name__ == '__main__':
+ os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
+ app = MyApplication()
+ app.start()
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo_menu.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+
+from tuikit import *
+
+
+class MyApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.top.connect('keypress', self.globalkeypress)
+
+ menubar = MenuBar()
+ self.top.add(menubar)
+
+ helpwin = Window()
+ self.top.add(helpwin)
+ helpwin.x = 10
+ helpwin.y = 5
+ helpwin.allowlayout = False
+ helpwin.hidden = True
+ helpwin.title = 'About'
+ #helpwin.closebutton = False
+ #helpwin.resizable = False
+
+
+ filemenu = Menu([
+ ('New', None),
+ None,
+ ('Open', None),
+ ('Save', None),
+ None,
+ ('Quit', self.terminate),
+ ])
+ self.top.add(filemenu)
+
+ editmenu = Menu([('Copy', None), ('Paste', None)])
+ helpmenu = Menu([('About', helpwin)])
+
+ self.top.add(editmenu)
+ self.top.add(helpmenu)
+
+ menubar.setitems([
+ ('File', filemenu),
+ ('Edit', editmenu),
+ ('Help', helpmenu),
+ ])
+
+ vert = VerticalLayout()
+ self.top.layout(vert)
+
+
+ #button = Button('click!')
+ #win.add(button)
+ #button.x = 10
+ #button.y = 7
+
+ #button.connect('click', self.buttonclick)
+ #self.button = button
+
+ #subwin = Window(8,8)
+ #win.add(subwin)
+
+
+ def globalkeypress(self, keyname, char):
+ if keyname == 'escape':
+ self.terminate()
+
+
+if __name__ == '__main__':
+ app = MyApplication()
+ app.start()
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo_treeview.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+
+from tuikit import *
+
+
+class MyApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.top.connect('keypress', self.globalkeypress)
+
+ model = TreeModel()
+ model.add('/', ['a', 'b'])
+ model.add('/a', ['c', 'd'])
+ model.add((0,1), ['e', 'f'])
+ model.add('/0/1/0', 'g')
+ model.add('/a/d/f', 'h')
+
+ view = TreeView(model)
+ view.collapse('/a/d')
+ self.top.add(view)
+
+ vert = VerticalLayout()
+ self.top.layout(vert)
+
+ def globalkeypress(self, keyname, char):
+ if keyname == 'escape':
+ self.terminate()
+
+
+if __name__ == '__main__':
+ app = MyApplication()
+ app.start()
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo_window.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+import os
+
+from tuikit.application import Application
+from tuikit.editfield import EditField
+from tuikit.window import Window
+from tuikit.button import Button
+
+
+class MyApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.top.connect('keypress', self.globalkeypress)
+
+ #edit = EditField(50, 'DlouhyTest12')
+ #self.top.add(edit)
+
+ win = Window()
+ self.top.add(win)
+
+ button = Button('click!')
+ win.add(button)
+ button.x = 10
+ button.y = 7
+
+ button.connect('click', self.buttonclick)
+ self.button = button
+
+ subwin = Window(8,8)
+ win.add(subwin)
+
+
+ def buttonclick(self):
+ self.button.label = 'YES'
+
+
+ def globalkeypress(self, keyname, char):
+ if keyname == 'escape':
+ self.terminate()
+
+
+if __name__ == '__main__':
+ locale.setlocale(locale.LC_ALL, '')
+ os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
+ app = MyApplication()
+ app.start()
+
--- a/docs/index.rst Fri Oct 07 11:07:59 2011 +0200
+++ b/docs/index.rst Fri Oct 07 12:02:33 2011 +0200
@@ -1,6 +1,11 @@
Tuikit documentation
====================
+| ``╒══════╤════╤════╕``
+| ``│ ├ ╷╷ ╷ │/ ╷ ├ │``
+| ``│ ╰╴╰┘ ╰ ╵╰ ╰ ╰╴ │``
+| ``╰────────────────╯``
+
Contents:
.. toctree::
@@ -28,4 +33,4 @@
tuikit.menu
tuikit.menubar
tuikit.treeview
-
\ No newline at end of file
+
--- a/editor.py Fri Oct 07 11:07:59 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-import locale
-locale.setlocale(locale.LC_ALL, '')
-
-import os
-
-from tuikit.application import Application
-from tuikit.editfield import EditField
-from tuikit.window import Window
-from tuikit.button import Button
-from tuikit.scrollbar import VScrollbar
-from tuikit.textedit import TextEdit
-
-
-class MyApplication(Application):
- def __init__(self):
- Application.__init__(self)
- self.top.connect('keypress', self.globalkeypress)
-
- #edit = EditField(50, 'DlouhyTest12')
- #self.top.add(edit)
-
-
- t = open('tuikit/widget.py').read()
- textedit = TextEdit(100, 40, t)
- self.top.add(textedit)
- textedit.x = 2
- self.textedit = textedit
-
- #win = Window()
- #self.top.add(win)
-
- #button = Button('click!')
- #win.add(button)
- #button.x = 10
- #button.y = 7
-
- #button.connect('click', self.buttonclick)
- #self.button = button
-
- #subwin = Window(8,8)
- #win.add(subwin)
-
-
- def buttonclick(self):
- self.button.label = 'YES'
-
-
- def globalkeypress(self, keyname, char):
- if keyname == 'escape':
- self.terminate()
- if keyname == 'f1':
- self.textedit.settext('%s' % self.top.focuschild)
- self.textedit.redraw()
-
-
-
-if __name__ == '__main__':
- os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
- app = MyApplication()
- app.start()
-
--- a/example.py Fri Oct 07 11:07:59 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-import locale
-locale.setlocale(locale.LC_ALL, '')
-
-from tuikit import *
-
-
-class MyApplication(Application):
- def __init__(self):
- Application.__init__(self)
- self.top.connect('keypress', self.globalkeypress)
-
- menubar = MenuBar()
- self.top.add(menubar)
-
- helpwin = Window()
- self.top.add(helpwin)
- helpwin.x = 10
- helpwin.y = 5
- helpwin.allowlayout = False
- helpwin.hidden = True
- helpwin.title = 'About'
- #helpwin.closebutton = False
- #helpwin.resizable = False
-
-
- filemenu = Menu([
- ('New', None),
- None,
- ('Open', None),
- ('Save', None),
- None,
- ('Quit', self.terminate),
- ])
- self.top.add(filemenu)
-
- editmenu = Menu([('Copy', None), ('Paste', None)])
- helpmenu = Menu([('About', helpwin)])
-
- self.top.add(editmenu)
- self.top.add(helpmenu)
-
- menubar.setitems([
- ('File', filemenu),
- ('Edit', editmenu),
- ('Help', helpmenu),
- ])
-
- vert = VerticalLayout()
- self.top.layout(vert)
-
-
- #button = Button('click!')
- #win.add(button)
- #button.x = 10
- #button.y = 7
-
- #button.connect('click', self.buttonclick)
- #self.button = button
-
- #subwin = Window(8,8)
- #win.add(subwin)
-
-
- def globalkeypress(self, keyname, char):
- if keyname == 'escape':
- self.terminate()
-
-
-if __name__ == '__main__':
- app = MyApplication()
- app.start()
-
--- a/example_treeview.py Fri Oct 07 11:07:59 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-import locale
-locale.setlocale(locale.LC_ALL, '')
-
-from tuikit import *
-
-
-class MyApplication(Application):
- def __init__(self):
- Application.__init__(self)
- self.top.connect('keypress', self.globalkeypress)
-
- model = TreeModel()
- model.add('/', ['a', 'b'])
- model.add('/a', ['c', 'd'])
- model.add((0,1), ['e', 'f'])
- model.add('/0/1/0', 'g')
- model.add('/a/d/f', 'h')
-
- view = TreeView(model)
- view.collapse('/a/d')
- self.top.add(view)
-
- vert = VerticalLayout()
- self.top.layout(vert)
-
- def globalkeypress(self, keyname, char):
- if keyname == 'escape':
- self.terminate()
-
-
-if __name__ == '__main__':
- app = MyApplication()
- app.start()
-
--- a/test_input.py Fri Oct 07 11:07:59 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-import locale
-locale.setlocale(locale.LC_ALL, '')
-
-from tuikit import *
-
-
-class MyApplication(Application):
- def __init__(self):
- Application.__init__(self)
- self.top.connect('keypress', self.globalkeypress)
-
- self.text = ''
- textedit = TextEdit(100, 40, self.text)
- self.top.add(textedit)
- textedit.x = 2
- self.textedit = textedit
-
-
- def globalkeypress(self, keyname, char):
- if char == 'q':
- self.terminate()
- self.text += 'keyname: %s char: %s\n' % (keyname, char)
- self.textedit.settext(self.text)
- self.textedit.scrolltoend()
-
-
-if __name__ == '__main__':
- app = MyApplication()
- app.start()
-
--- a/tests/gridlayout.py Fri Oct 07 11:07:59 2011 +0200
+++ b/tests/gridlayout.py Fri Oct 07 12:02:33 2011 +0200
@@ -1,7 +1,10 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-from tuikit import *
+import sys
+sys.path.append('..')
+
+from tuikit import Container, Size, Widget, GridLayout
# -------------
# | 0 | 1 | 2 |
@@ -22,10 +25,10 @@
w[i] = Widget()
cont.add(w[i])
- w[3].layouthints['colspan'] = 2
+ w[3].hints['colspan'] = 2
- w[1].sizemin = (2,2)
- w[3].sizemin = (6,1)
+ w[1].sizemin = Size(2,2)
+ w[3].sizemin = Size(6,1)
grid = GridLayout(3)
grid.container = cont
@@ -52,7 +55,7 @@
if w is None:
print('[0,0]', end=' ')
else:
- print('[%d,%d]' % w.sizemin, end=' ')
+ print('[{0.w},{0.h}]'.format(w.sizemin), end=' ')
print()
print('colminw:')
@@ -60,3 +63,4 @@
print('rowminh:')
print(grid._rowminh)
+
--- a/tests/gridlayout_rowspan.py Fri Oct 07 11:07:59 2011 +0200
+++ b/tests/gridlayout_rowspan.py Fri Oct 07 12:02:33 2011 +0200
@@ -1,7 +1,10 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-from tuikit import *
+import sys
+sys.path.append('..')
+
+from tuikit import Container, Widget, Size, GridLayout
# +---+---+---+
# | 0 | 1 |
@@ -23,10 +26,10 @@
w[i] = Widget()
cont.add(w[i])
- w[0].layouthints['colspan'] = 2
+ w[0].hints['colspan'] = 2
- w[1].sizemin = (2,2)
- w[3].sizemin = (6,1)
+ w[1].sizemin = Size(2,2)
+ w[3].sizemin = Size(6,1)
grid = GridLayout(3)
grid.container = cont
@@ -53,7 +56,7 @@
if w is None:
print('[0,0]', end=' ')
else:
- print('[%d,%d]' % w.sizemin, end=' ')
+ print('[{0.w},{0.h}]'.format(w.sizemin), end=' ')
print()
print('colminw:')
@@ -61,3 +64,4 @@
print('rowminh:')
print(grid._rowminh)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/input.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+
+from tuikit import *
+
+
+class MyApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.top.connect('keypress', self.globalkeypress)
+
+ self.text = ''
+ textedit = TextEdit(100, 40, self.text)
+ self.top.add(textedit)
+ textedit.x = 2
+ self.textedit = textedit
+
+
+ def globalkeypress(self, keyname, char):
+ if char == 'q':
+ self.terminate()
+ self.text += 'keyname: %s char: %s\n' % (keyname, char)
+ self.textedit.settext(self.text)
+ self.textedit.scrolltoend()
+
+
+if __name__ == '__main__':
+ app = MyApplication()
+ app.start()
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/keycodes.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import curses
+import locale
+
+locale.setlocale(locale.LC_ALL,"")
+
+def doStuff(screen):
+ screen.addstr('termname: %s\n' % curses.termname())
+ screen.keypad(0)
+ screen.scrollok(1)
+ curses.nl()
+ curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
+ while True:
+ c = screen.getch()
+
+ screen.nodelay(1)
+ while c != -1:
+ screen.addstr('0x%02x,' % c)
+ c = screen.getch()
+ screen.nodelay(0)
+
+ screen.addstr('\n')
+
+ screen.refresh()
+
+curses.wrapper(doStuff)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mouse.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import curses
+import locale
+
+locale.setlocale(locale.LC_ALL,"")
+
+def doStuff(screen):
+ screen.addstr('%s\n' % curses.termname())
+ screen.keypad(1)
+ screen.scrollok(1)
+ curses.nl()
+ curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
+ curses.mouseinterval(0) # do not wait to detect clicks, we use only press/release
+ while True:
+ c = screen.getch()
+ char = ' '
+ if c < 256:
+ char = curses.unctrl(c)
+ screen.addstr('key: %x %s\n' % (c, char))
+
+ if c == curses.KEY_MOUSE:
+ m = curses.getmouse()
+ screen.addstr('(%d %d %d %d %x)\n' % m)
+
+ screen.refresh()
+
+curses.wrapper(doStuff)
--- a/tests/test_treeview.py Fri Oct 07 11:07:59 2011 +0200
+++ b/tests/test_treeview.py Fri Oct 07 12:02:33 2011 +0200
@@ -1,8 +1,12 @@
#!/usr/bin/env python3
+import sys
+sys.path.append('..')
+
from tuikit.treeview import *
import unittest
+
class TestTreeView(unittest.TestCase):
def test_treemodel(self):
'''Build tree model, iterate through the tree, test result.'''
@@ -32,3 +36,4 @@
if __name__ == '__main__':
unittest.main()
+
--- a/tests/tuikit Fri Oct 07 11:07:59 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-../tuikit
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/unicode.py Fri Oct 07 12:02:33 2011 +0200
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+# coding=UTF-8
+
+import curses
+import locale
+
+locale.setlocale(locale.LC_ALL, "")
+
+def doStuff(stdscr):
+ message = "Žlutý kůň.\nPress 'q' to quit.\n"
+ stdscr.addstr(0, 0, message, 0)
+ while True:
+ c = stdscr.getch() # pauses until a key's hit
+ if c == ord('q'):
+ break
+ stdscr.addch(c)
+
+curses.wrapper(doStuff)
--- a/tuikit/__init__.py Fri Oct 07 11:07:59 2011 +0200
+++ b/tuikit/__init__.py Fri Oct 07 12:02:33 2011 +0200
@@ -3,7 +3,7 @@
from tuikit.application import Application
from tuikit.button import Button
from tuikit.combobox import ComboBox
-from tuikit.common import Rect
+from tuikit.common import Rect, Size, Coords
from tuikit.container import Container
from tuikit.editbox import EditBox
from tuikit.editfield import EditField
--- a/tuikit/layout.py Fri Oct 07 11:07:59 2011 +0200
+++ b/tuikit/layout.py Fri Oct 07 12:02:33 2011 +0200
@@ -7,7 +7,6 @@
'''
-import logging
import math
from tuikit.common import Rect