Coverage for tatlin/lib/ui/view.py: 85%
41 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 05:56 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 05:56 +0000
1# -*- coding: utf-8 -*-
2# Copyright (C) 2011 Denis Kobozev
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software Foundation,
16# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18import wx
21class ViewButtons(wx.FlexGridSizer):
22 def __init__(self, parent, scene):
23 super(ViewButtons, self).__init__(rows=3, cols=3, vgap=0, hgap=0)
25 self.scene = scene
27 self.btn_front = wx.Button(parent, label="Front")
28 self.btn_back = wx.Button(parent, label="Back")
29 self.btn_left = wx.Button(parent, label="Left")
30 self.btn_right = wx.Button(parent, label="Right")
32 self.btn_top = wx.Button(parent, label="Top")
33 self.btn_bottom = wx.Button(parent, label="Bottom")
35 vbox = wx.BoxSizer(wx.VERTICAL)
36 vbox.Add(self.btn_top, 0, wx.EXPAND)
37 vbox.Add(self.btn_bottom, 0, wx.EXPAND)
39 self.Add((0, 0), 0, wx.EXPAND)
40 self.Add(self.btn_back, 0, wx.EXPAND)
41 self.Add((0, 0), 0, wx.EXPAND)
42 self.Add(self.btn_left, 0, wx.EXPAND)
43 self.Add(vbox, 0, wx.EXPAND)
44 self.Add(self.btn_right, 0, wx.EXPAND)
45 self.Add((0, 0), 0, wx.EXPAND)
46 self.Add(self.btn_front, 0, wx.EXPAND)
47 self.Add((0, 0), 0, wx.EXPAND)
49 # connect handlers
50 self.btn_front.Bind(wx.EVT_BUTTON, self.on_view_front)
51 self.btn_back.Bind(wx.EVT_BUTTON, self.on_view_back)
52 self.btn_left.Bind(wx.EVT_BUTTON, self.on_view_left)
53 self.btn_right.Bind(wx.EVT_BUTTON, self.on_view_right)
54 self.btn_top.Bind(wx.EVT_BUTTON, self.on_view_top)
55 self.btn_bottom.Bind(wx.EVT_BUTTON, self.on_view_bottom)
57 def on_view_front(self, event):
58 self.scene.rotate_view(0, 0)
60 def on_view_back(self, event):
61 self.scene.rotate_view(180, 0)
63 def on_view_left(self, event):
64 self.scene.rotate_view(90, 0)
66 def on_view_right(self, event):
67 self.scene.rotate_view(-90, 0)
69 def on_view_top(self, event):
70 self.scene.rotate_view(0, -90)
72 def on_view_bottom(self, event):
73 self.scene.rotate_view(0, 90)