Debian Codegraph @

scripts/modules/character_screen.py

raw symbols SCIP
1 #
2 # $Id$
3 #
4 # (C) Copyright 2001 Kai Sterker <[email protected]>
5 # Part of the Adonthell Project http://adonthell.linuxgames.com
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY.
11 #
12 # See the COPYING file for more details
13 #
14
15 import adonthell
16
17 # -- pygettext support
18 def _(message): return adonthell.nls_translate (message)
19
20 # -- GUI for chosing the name of the main character
21 class character_screen (adonthell.win_container):
22
23 # -- Constructor
24 def __init__(self):
25 adonthell.win_container.__init__(self)
26
27 # -- get font and theme
28 self.font = adonthell.win_manager_get_font ("original")
29 self.theme = adonthell.win_manager_get_theme ("original")
30
31 self.move (60, 55)
32 self.resize (200, 110)
33 self.set_border (self.theme)
34 self.set_background (self.theme)
35 self.set_trans_background (True)
36
37 # -- The window title
38 self.title = adonthell.win_label ()
39 self.title.thisown = 0
40 self.title.resize (0, 20)
41 self.title.set_font (self.font)
42 self.title.set_form (adonthell.label_AUTO_SIZE)
43 self.title.set_text (_("Enter your character's name"))
44 self.title.pack ()
45 self.title.move ((self.length () - self.title.length ())//2, 10)
46
47 # -- The character image
48 self.image = adonthell.win_image ()
49 self.image.thisown = 0
50 self.image.move (10, 35)
51 self.image.resize (64, 64)
52 self.image.load_pnm ("gfx/portraits/player.pnm")
53 self.image.set_mask (True)
54 self.image.pack ()
55
56 # -- The text entry
57 self.entry = adonthell.win_write ()
58 self.entry.thisown = 0
59 self.entry.py_signal_connect (self.on_enter, adonthell.win_event_ACTIVATE_KEY)
60 self.entry.move (90, 62)
61 self.entry.resize (100, 20)
62 self.entry.set_font (self.font)
63 self.entry.set_cursor_visible (True)
64 self.entry.set_cursor_moveable (True)
65 self.entry.set_text ("Banec")
66 self.entry.pack ()
67
68 self.add (self.title)
69 self.add (self.image)
70 self.add (self.entry)
71 self.set_focus_object (self.entry)
72
73 self.set_visible_background (True)
74 self.set_visible_border (True)
75 self.set_visible_all (True)
76 self.set_activate (True)
77
78 self.entry.set_focus (True)
79 self.entry.set_activate (True)
80
81 # -- callback for accepting name
82 def on_enter (self):
83 self.name = self.entry.text_char ()
84 adonthell.gamedata_engine ().main_quit ()