Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/snake/rev/3619305694ad
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:09:37 2012
Кодировка:
snake: 3619305694ad

snake

changeset 96:3619305694ad

Actually fixed buttons resizing. Fixed code separation for buttons drawing.
author Danya Alexeyevsky <me.dendik@gmail.com>
date Mon, 20 Dec 2010 02:26:35 +0300
parents dcd9d23e77d7
children 4436cf8ba30c
files main.py
diffstat 1 files changed, 16 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/main.py	Mon Dec 20 02:23:01 2010 +0300
     1.2 +++ b/main.py	Mon Dec 20 02:26:35 2010 +0300
     1.3 @@ -11,27 +11,26 @@
     1.4          self.root.title("Python Battle")
     1.5          self.canvas = tk.Canvas(self.root, background = "black")
     1.6          self.canvas.pack(side ="top", fill="both", expand="yes")
     1.7 -        buttons = tk.Frame(self.root)
     1.8 -        buttons.pack(side ="bottom", fill="both", expand="yes")
     1.9 -        self.buttons_pack(buttons)
    1.10 +        self.buttons_pack(self.root).pack(side ="bottom", fill="both", expand="no")
    1.11          self.step_id = 0
    1.12          self.engine = engine.Engine(self.canvas)
    1.13          self.after_id = None
    1.14          return
    1.15 -    def buttons_pack(self, frame):
    1.16 -        load_1 = tk.Button(frame, text="Load 1", command=lambda: self.load(1))
    1.17 -        load_1.pack(side="left", fill="both", expand = "no")
    1.18 -        load_2 = tk.Button(frame, text="Load 2", command=lambda: self.load(2))
    1.19 -        load_2.pack(side="left", fill="both", expand = "no")
    1.20 -        run_b = tk.Button(frame, text="Run", command=lambda: self.run())
    1.21 -        run_b.pack(side="left", fill="both", expand = "no")
    1.22 -        load_3 = tk.Button(frame, text="Load 3", command=lambda: self.load(3))
    1.23 -        load_3.pack(side="right", fill="both", expand = "no")
    1.24 -        load_4 = tk.Button(frame, text="Load 4", command=lambda: self.load(4))
    1.25 -        load_4.pack(side="right", fill="both", expand = "no")
    1.26 -        step_b = tk.Button(frame, text="Step", command=lambda: self.step())
    1.27 -        step_b.pack(side="right", fill="both", expand = "no")
    1.28 -        return
    1.29 +    def buttons_pack(self, root):
    1.30 +        buttons = tk.Frame(root)
    1.31 +        load_1 = tk.Button(buttons, text="Load 1", command=lambda: self.load(1))
    1.32 +        load_1.pack(side="left", fill="both", expand = "yes")
    1.33 +        load_2 = tk.Button(buttons, text="Load 2", command=lambda: self.load(2))
    1.34 +        load_2.pack(side="left", fill="both", expand = "yes")
    1.35 +        run_b = tk.Button(buttons, text="Run", command=lambda: self.run())
    1.36 +        run_b.pack(side="left", fill="both", expand = "yes")
    1.37 +        load_3 = tk.Button(buttons, text="Load 3", command=lambda: self.load(3))
    1.38 +        load_3.pack(side="right", fill="both", expand = "yes")
    1.39 +        load_4 = tk.Button(buttons, text="Load 4", command=lambda: self.load(4))
    1.40 +        load_4.pack(side="right", fill="both", expand = "yes")
    1.41 +        step_b = tk.Button(buttons, text="Step", command=lambda: self.step())
    1.42 +        step_b.pack(side="right", fill="both", expand = "yes")
    1.43 +        return buttons
    1.44      
    1.45      def load (self, snake_number):
    1.46          if self.step_id >= 200: