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