example.py
author Radek Brich <radek.brich@devl.cz>
Wed, 16 Feb 2011 23:51:30 +0100
changeset 0 a35731b5e31a
child 1 69318aba22bf
permissions -rwxr-xr-x
tuikit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
import locale
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
locale.setlocale(locale.LC_ALL, '')
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
import os
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
from tuikit.application import Application
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
from tuikit.editfield import EditField
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
from tuikit.window import Window
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
from tuikit.button import Button
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
from tuikit.scrollbar import VScrollbar
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
from tuikit.textedit import TextEdit
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
from tuikit.menubar import MenuBar
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
from tuikit.menu import Menu
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
from tuikit.layout import VerticalLayout
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
class MyApplication(Application):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
    def __init__(self):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
        Application.__init__(self)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
        self.top.connect('keypress', self.globalkeypress)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
        menubar = MenuBar()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
        self.top.add(menubar)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
        filemenu = Menu(['New', '-', 'Open', 'Save', '-', 'Quit'])
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
        self.top.add(filemenu)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
        filemenu.allowlayout = False
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
        filemenu.hidden = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
        editmenu = Menu(['Copy', 'Paste'])
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
        self.top.add(editmenu)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
        editmenu.allowlayout = False
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
        editmenu.hidden = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
        helpmenu = Menu(['About'])
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
        self.top.add(helpmenu)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
        helpmenu.allowlayout = False
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
        helpmenu.hidden = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
        menubar.setitems([
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
            ('File', filemenu),
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
            ('Edit', editmenu),
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
            ('Help', helpmenu)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
            ])
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
        vert = VerticalLayout()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    50
        self.top.layout(vert)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    51
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    52
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    53
        #win = Window()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
        #self.top.add(win)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    55
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    56
        #button = Button('click!')
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    57
        #win.add(button)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    58
        #button.x = 10
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    59
        #button.y = 7
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    60
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    61
        #button.connect('click', self.buttonclick)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    62
        #self.button = button
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    63
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    64
        #subwin = Window(8,8)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    65
        #win.add(subwin)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    66
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    67
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    68
    def globalkeypress(self, keyname, char):
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    69
        if keyname == 'escape':
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    70
            self.terminate()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    71
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    72
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    73
if __name__ == '__main__':
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    74
    app = MyApplication()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    75
    app.start()
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    76