Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common/Util/KeyboardWindow.py
diff options
context:
space:
mode:
Diffstat (limited to 'common/Util/KeyboardWindow.py')
-rw-r--r--common/Util/KeyboardWindow.py42
1 files changed, 22 insertions, 20 deletions
diff --git a/common/Util/KeyboardWindow.py b/common/Util/KeyboardWindow.py
index a244bdb..e828967 100644
--- a/common/Util/KeyboardWindow.py
+++ b/common/Util/KeyboardWindow.py
@@ -1,20 +1,22 @@
-from gi.repository import Gtk
+import pygtk
+pygtk.require( '2.0' )
+import gtk
import random
from common.Util.ThemeWidgets import keyButton
import common.Config as Config
KEY_MAP_PIANO = Config.KEY_MAP_PIANO
-class KeyboardWindow(Gtk.Window):
+class KeyboardWindow(gtk.Window):
def __init__(self, size = None, pos = 0, popup = False):
if popup is False:
- Gtk.Window.__init__(self , Gtk.WINDOW_TOPLEVEL)
+ gtk.Window.__init__(self , gtk.WINDOW_TOPLEVEL)
else:
- Gtk.Window.__init__(self , Gtk.WINDOW_POPUP)
- color = Gdk.color_parse("#000000")
- self.modify_bg(Gtk.STATE_NORMAL, color)
+ gtk.Window.__init__(self , gtk.WINDOW_POPUP)
+ color = gtk.gdk.color_parse("#000000")
+ self.modify_bg(gtk.STATE_NORMAL, color)
self.set_decorated(False)
- self.add_events(Gdk.BUTTON_PRESS_MASK | Gdk.BUTTON_RELEASE_MASK | Gdk.ENTER_NOTIFY_MASK | Gdk.KEY_PRESS_MASK)
+ self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.KEY_PRESS_MASK)
self.connect("key-press-event",self.handle_keypress)
self.connect("key-release-event",self.handle_keyrelease)
self.connect("button-press-event",self.handle_mousePress)
@@ -47,23 +49,23 @@ class KeyboardWindow(Gtk.Window):
self.btn_dic = {}
- mainvbox = Gtk.VBox()
- mainhbox = Gtk.HBox()
+ mainvbox = gtk.VBox()
+ mainhbox = gtk.HBox()
#Main keyboard section
- vbox = Gtk.VBox()
+ vbox = gtk.VBox()
for row in [1,2,3,4,5]:
- hbox = Gtk.HBox()
+ hbox = gtk.HBox()
for key in self.rows[row]:
self.btn_dic[key[0]] = keyButton(self.pixel_space * key[1], self.height, [0,0,0], [0.5,0.5,0.5])
hbox.pack_start(self.btn_dic[key[0]], padding = self.pixel_space//2)
vbox.pack_start(hbox, padding = self.pixel_space//2)
- mainhbox.pack_start(vbox, True, True, 0)
+ mainhbox.pack_start(vbox)
#Right part of the keyboard
- right_vbox = Gtk.VBox()
- right_tophbox = Gtk.HBox()
- right_lowhbox = Gtk.HBox()
+ right_vbox = gtk.VBox()
+ right_tophbox = gtk.HBox()
+ right_lowhbox = gtk.HBox()
self.btn_dic[self.right_section[0][0]] = keyButton(self.pixel_space * self.right_section[0][1], self.height, [0,0,0], [0.5,0.5,0.5])
self.btn_dic[self.right_section[1][0]] = keyButton(self.pixel_space * self.right_section[1][1][0], self.pixel_space * self.right_section[1][1][1], [0,0,0], [0.5,0.5,0.5])
@@ -82,7 +84,7 @@ class KeyboardWindow(Gtk.Window):
right_vbox.pack_start(right_lowhbox, padding = self.pixel_space//2)
#Mouse buttons
- mouse_hbox = Gtk.HBox()
+ mouse_hbox = gtk.HBox()
self.btn_dic["left_mouse"] = keyButton(self.pixel_space * 6, self.pixel_space * 2, [0,0,0], [0.5,0.5,0.5])
self.btn_dic["right_mouse"] = keyButton(self.pixel_space * 6, self.pixel_space * 2, [0,0,0], [0.5,0.5,0.5])
mouse_hbox.pack_start(self.btn_dic["left_mouse"], True, True, self.pixel_space//2)
@@ -94,8 +96,8 @@ class KeyboardWindow(Gtk.Window):
self.btn_dic[key].connect("enter",self.handle_mouseEnter)
self.btn_dic[key].connect("leave",self.handle_mouseLeave)
- mainhbox.pack_start(right_vbox, True, True, 0)
- mainvbox.pack_start(mainhbox, True, True, 0)
+ mainhbox.pack_start(right_vbox)
+ mainvbox.pack_start(mainhbox)
mainvbox.pack_start(mouse_hbox, padding = self.pixel_space//2)
self.add(mainvbox)
@@ -173,6 +175,6 @@ class KeyboardWindow(Gtk.Window):
if __name__ == "__main__":
win = KeyboardWindow()
- win.connect("destroy",Gtk.main_quit)
+ win.connect("destroy",gtk.main_quit)
win.show_all()
- Gtk.main()
+ gtk.main()