author | Radek Brich <radek.brich@devl.cz> |
Tue, 15 Mar 2011 17:27:09 +0100 | |
changeset 2 | 684cdc352562 |
parent 1 | 69318aba22bf |
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 |
||
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
18 |
helpwin = Window() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
19 |
self.top.add(helpwin) |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
20 |
helpwin.x = 10 |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
21 |
helpwin.y = 5 |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
22 |
helpwin.allowlayout = False |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
23 |
helpwin.hidden = True |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
24 |
helpwin.title = 'About' |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
25 |
#helpwin.closebutton = False |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
26 |
#helpwin.resizable = False |
1
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
27 |
|
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
28 |
|
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
29 |
filemenu = Menu([ |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
30 |
('New', None), |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
31 |
None, |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
32 |
('Open', None), |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
33 |
('Save', None), |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
34 |
None, |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
35 |
('Quit', self.terminate), |
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
36 |
]) |
0 | 37 |
self.top.add(filemenu) |
38 |
||
1
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
39 |
editmenu = Menu([('Copy', None), ('Paste', None)]) |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
40 |
helpmenu = Menu([('About', helpwin)]) |
1
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
41 |
|
0 | 42 |
self.top.add(editmenu) |
43 |
self.top.add(helpmenu) |
|
44 |
||
45 |
menubar.setitems([ |
|
46 |
('File', filemenu), |
|
47 |
('Edit', editmenu), |
|
1
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
48 |
('Help', helpmenu), |
0 | 49 |
]) |
50 |
||
51 |
vert = VerticalLayout() |
|
52 |
self.top.layout(vert) |
|
53 |
||
54 |
||
55 |
#button = Button('click!') |
|
56 |
#win.add(button) |
|
57 |
#button.x = 10 |
|
58 |
#button.y = 7 |
|
59 |
||
60 |
#button.connect('click', self.buttonclick) |
|
61 |
#self.button = button |
|
62 |
||
63 |
#subwin = Window(8,8) |
|
64 |
#win.add(subwin) |
|
65 |
||
66 |
||
67 |
def globalkeypress(self, keyname, char): |
|
68 |
if keyname == 'escape': |
|
69 |
self.terminate() |
|
70 |
||
71 |
||
72 |
if __name__ == '__main__': |
|
73 |
app = MyApplication() |
|
74 |
app.start() |
|
75 |