From 053cf3e48c7a5dbed51863c21c434a71b1c97ab9 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Wed, 19 Aug 2015 20:25:40 +0200 Subject: [PATCH] Use GTK rename script --- ghextris.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ghextris.py b/ghextris.py index f60c4c8..aae1798 100755 --- a/ghextris.py +++ b/ghextris.py @@ -25,15 +25,15 @@ VERSION="0.9.0" import os import sys -import pygtk -pygtk.require("2.0") +import gi +gi.require_version("Gtk", "3.0") -import gtk +from gi.repository import Gtk import gnomecanvas import gnome import gnome.ui -import gobject -import gtk.glade +from gi.repository import GObject +import Gtk.glade import gettext @@ -221,7 +221,7 @@ class Hextris: self.next_piece() if self.running == False: - gobject.timeout_add(self.speed, self.timer_handler) + GObject.timeout_add(self.speed, self.timer_handler) self.running = True else: self.speed_reset = True @@ -229,7 +229,7 @@ class Hextris: return True def on_about_activate(self, event): - aTree = gtk.glade.XML(self.glade, "about") + aTree = Gtk.glade.XML(self.glade, "about") about = aTree.get_widget("about") about.set_property("name", "Ghextris") about.set_property("version", VERSION) @@ -245,14 +245,14 @@ class Hextris: return True def on_quit_activate(self, event): - gtk.main_quit() + Gtk.main_quit() def main(self): gnome.init("Ghextris", VERSION) gettext.install("ghextris") self.glade = os.path.join(SHAREDIR, "ghextris.glade") - wTree = gtk.glade.XML(self.glade, "GhextrisApp") + wTree = Gtk.glade.XML(self.glade, "GhextrisApp") dic = {"on_new_activate": self.on_new_activate, "on_pause_game_activate": self.on_pause_game_activate, "on_quit_activate": self.on_quit_activate, @@ -328,7 +328,7 @@ class Hextris: if self.speed_reset == True: self.speed_reset = False - gobject.timeout_add(int(self.speed), self.timer_handler) + GObject.timeout_add(int(self.speed), self.timer_handler) return False return True @@ -342,7 +342,7 @@ class Hextris: if self.lost == True: return False - if event.keyval == gtk.keysyms.p and self.lost == False: + if event.keyval == Gdk.KEY_p and self.lost == False: if self.paused == True: self.paused = False else: @@ -352,8 +352,8 @@ class Hextris: if self.paused == True: return False - if event.keyval == gtk.keysyms.Up or event.keyval == gtk.keysyms.Down: - if event.keyval == gtk.keysyms.Up: + if event.keyval == Gdk.KEY_Up or event.keyval == Gdk.KEY_Down: + if event.keyval == Gdk.KEY_Up: attitude_change = 1 else: attitude_change = -1 @@ -372,8 +372,8 @@ class Hextris: self.piece_x, self.piece_y); return True - if event.keyval == gtk.keysyms.Left or event.keyval == gtk.keysyms.Right: - if event.keyval == gtk.keysyms.Left: + if event.keyval == Gdk.KEY_Left or event.keyval == Gdk.KEY_Right: + if event.keyval == Gdk.KEY_Left: deltax = -1 else: deltax = 1 @@ -399,7 +399,7 @@ class Hextris: self.piece.move(deltax*(self.piecewidth+self.piecenarrow)/2, deltay) return True - if event.keyval == gtk.keysyms.space: + if event.keyval == Gdk.KEY_space: orig_piece_y = self.piece_y while self.check_collisions() == False: self.piece_y += 1 @@ -492,4 +492,4 @@ class Hextris: if __name__ == '__main__': h = Hextris() h.main() - gtk.main() + Gtk.main() -- 2.39.5