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