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

#!/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
from tuikit.menubar import MenuBar
from tuikit.menu import Menu
from tuikit.layout import VerticalLayout


class MyApplication(Application):
    def __init__(self):
        Application.__init__(self)
        self.top.connect('keypress', self.globalkeypress)

        menubar = MenuBar()
        self.top.add(menubar)

        filemenu = Menu(['New', '-', 'Open', 'Save', '-', 'Quit'])
        self.top.add(filemenu)
        filemenu.allowlayout = False
        filemenu.hidden = True

        editmenu = Menu(['Copy', 'Paste'])
        self.top.add(editmenu)
        editmenu.allowlayout = False
        editmenu.hidden = True

        helpmenu = Menu(['About'])
        self.top.add(helpmenu)
        helpmenu.allowlayout = False
        helpmenu.hidden = True

        menubar.setitems([
            ('File', filemenu),
            ('Edit', editmenu),
            ('Help', helpmenu)
            ])

        vert = VerticalLayout()
        self.top.layout(vert)


        #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 globalkeypress(self, keyname, char):
        if keyname == 'escape':
            self.terminate()


if __name__ == '__main__':
    app = MyApplication()
    app.start()