Skip to content

Commit b60e545

Browse files
committed
Use Python 3 and GTK+ 3
1 parent 58bb612 commit b60e545

File tree

3 files changed

+148
-143
lines changed

3 files changed

+148
-143
lines changed

SierraLauncher.py

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

3-
# Sierra Launcher replacement by C C Magnus Gustavsson
3+
'''Sierra Launcher replacement by C C Magnus Gustavsson'''
44

5-
import os, pygtk
6-
pygtk.require('2.0')
7-
8-
from gtk import *
5+
import gi, os
6+
gi.require_version('Gtk', '3.0')
7+
from gi.repository import Gtk
8+
from gi.repository.Gtk import AttachOptions as options
99

1010
# Actions for Linux/Unix (instead of SierraLauncher.ini)
11-
actions = ["acroread Manuals/KQManual.pdf &",
12-
"dosbox kq1sci/SIERRA.COM -fullscreen -exit &",
13-
"dosbox kq2/SIERRA.COM -fullscreen -exit &",
14-
"dosbox kq3/SIERRA.COM -fullscreen -exit &",
15-
"dosbox kq4/SIERRA.COM -fullscreen -exit &",
16-
"dosbox kq5/SIERRA.EXE -fullscreen -exit &",
17-
"dosbox kq6/SIERRA.EXE -fullscreen -exit &",
18-
"wine kq7/SIERRAW.EXE kq7/RESOURCE.WIN &"]
19-
20-
class SierraLauncher:
11+
ACTIONS = [
12+
"acroread Manuals/KQManual.pdf &",
13+
"dosbox kq1sci/SIERRA.COM -fullscreen -exit &",
14+
"dosbox kq2/SIERRA.COM -fullscreen -exit &",
15+
"dosbox kq3/SIERRA.COM -fullscreen -exit &",
16+
"dosbox kq4/SIERRA.COM -fullscreen -exit &",
17+
"dosbox kq5/SIERRA.EXE -fullscreen -exit &",
18+
"dosbox kq6/SIERRA.EXE -fullscreen -exit &",
19+
"wine kq7/SIERRAW.EXE kq7/RESOURCE.WIN &"
20+
]
21+
22+
class SierraLauncher(object):
2123
def destroy(self, widget, data=None):
22-
main_quit()
24+
Gtk.main_quit()
2325

2426
def delete_event(self, widget, event, data=None):
2527
self.destroy(self, widget)
2628

2729
def launch(self, widget, data=None):
28-
os.system(actions[widget.num])
30+
os.system(ACTIONS[widget.num])
2931
if self.close_window_on_launch:
3032
self.destroy(self, widget)
3133

@@ -35,61 +37,61 @@ def toggle(self, widget, data=None):
3537
def __init__(self):
3638
self.close_window_on_launch = False
3739

38-
self.window = Window(WINDOW_TOPLEVEL)
40+
self.window = Gtk.Window()
3941
self.window.set_title("King's Quest Collection(TM)")
4042
self.window.set_icon_from_file("Sierra.ico")
4143
self.window.set_resizable(False)
4244
self.window.connect("destroy", self.destroy)
4345
self.window.connect("delete_event", self.delete_event)
4446

45-
self.table = Table(columns=3, rows=9, homogeneous=False)
47+
self.table = Gtk.Table(columns=3, rows=9, homogeneous=False)
4648
self.table.set_border_width(8)
4749
self.window.add(self.table)
4850

4951
for i in range(1, 8):
50-
self.button = Button(' Launch ')
52+
self.button = Gtk.Button('{:^36}'.format('Launch'))
5153
self.button.num = i
5254
self.button.connect("clicked", self.launch, None)
5355
self.button.set_border_width(4)
5456
self.button.show()
5557

56-
self.frame = Frame("King's Quest " + str(i))
58+
self.frame = Gtk.Frame(label="King's Quest {:d}".format(i))
5759
self.frame.add(self.button)
58-
self.table.attach(self.frame, 0, 2, i-1, i, xoptions=FILL,
59-
yoptions=FILL, xpadding=8, ypadding=2)
60+
self.table.attach(self.frame, 0, 2, i-1, i, xoptions=options.FILL,
61+
yoptions=options.FILL, xpadding=8, ypadding=2)
6062
self.frame.show()
6163

62-
self.button = Button('View Manual')
64+
self.button = Gtk.Button('View Manual')
6365
self.button.num = 0
6466
self.button.connect("clicked", self.launch, None)
65-
self.table.attach(self.button, 0, 1, 7, 8, xoptions=EXPAND,
66-
yoptions=EXPAND, xpadding=4, ypadding=4)
67+
self.table.attach(self.button, 0, 1, 7, 8, xoptions=options.EXPAND,
68+
yoptions=options.EXPAND, xpadding=4, ypadding=4)
6769
self.button.show()
6870

69-
self.button = Button(' Close ')
70-
self.button.connect_object("clicked", Widget.destroy, self.window)
71-
self.table.attach(self.button, 1, 2, 7, 8, xoptions=EXPAND,
72-
yoptions=EXPAND, xpadding=4, ypadding=4)
71+
self.button = Gtk.Button('{:^15}'.format('Close'))
72+
self.button.connect_object("clicked", Gtk.Widget.destroy, self.window)
73+
self.table.attach(self.button, 1, 2, 7, 8, xoptions=options.EXPAND,
74+
yoptions=options.EXPAND, xpadding=4, ypadding=4)
7375
self.button.show()
7476

75-
self.button = CheckButton("Close window on launch")
77+
self.button = Gtk.CheckButton("Close window on launch")
7678
self.button.set_active(self.close_window_on_launch)
7779
self.button.connect("toggled", self.toggle, None)
78-
self.table.attach(self.button, 0, 2, 8, 9, xoptions=EXPAND,
79-
yoptions=EXPAND, xpadding=4, ypadding=4)
80+
self.table.attach(self.button, 0, 2, 8, 9, xoptions=options.EXPAND,
81+
yoptions=options.EXPAND, xpadding=4, ypadding=4)
8082
self.button.show()
8183

82-
self.image = Image()
84+
self.image = Gtk.Image()
8385
self.image.set_from_file("gameart.bmp")
84-
self.table.attach(self.image, 2, 3, 0, 9, xoptions=EXPAND,
85-
yoptions=EXPAND, xpadding=8, ypadding=8)
86+
self.table.attach(self.image, 2, 3, 0, 9, xoptions=options.EXPAND,
87+
yoptions=options.EXPAND, xpadding=8, ypadding=8)
8688
self.image.show()
8789

8890
self.table.show()
8991
self.window.show()
9092

9193
def main(self):
92-
main()
94+
Gtk.main()
9395

9496
if __name__ == "__main__":
9597
SierraLauncher().main()

SierraLauncherLSL.py

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

3-
# Sierra Launcher replacement by C C Magnus Gustavsson
3+
'''Sierra Launcher replacement by C C Magnus Gustavsson'''
44

5-
import os, pygtk
6-
pygtk.require('2.0')
7-
8-
from gtk import *
5+
import gi, os
6+
gi.require_version('Gtk', '3.0')
7+
from gi.repository import Gtk
8+
from gi.repository.Gtk import AttachOptions as options
99

1010
# Actions for Linux/Unix (instead of SierraLauncher.ini)
11-
actions = ["acroread Manuals/LarryManual.pdf &",
12-
"dosbox lsl1vga/SCIDHUV.EXE -fullscreen -exit &",
13-
"dosbox lsl2/SIERRA.COM -fullscreen -exit &",
14-
"dosbox lsl3/SIERRA.COM -fullscreen -exit &",
15-
"gedit lsl4/README.TXT &",
16-
"dosbox lsl5/SCIDHUV.EXE -fullscreen -exit &",
17-
"dosbox lsl6/SIERRA.EXE -fullscreen -exit &"]
18-
19-
class SierraLauncher:
11+
ACTIONS = [
12+
"acroread Manuals/LarryManual.pdf &",
13+
"dosbox lsl1vga/SCIDHUV.EXE -fullscreen -exit &",
14+
"dosbox lsl2/SIERRA.COM -fullscreen -exit &",
15+
"dosbox lsl3/SIERRA.COM -fullscreen -exit &",
16+
"gedit lsl4/README.TXT &",
17+
"dosbox lsl5/SCIDHUV.EXE -fullscreen -exit &",
18+
"dosbox lsl6/SIERRA.EXE -fullscreen -exit &"
19+
]
20+
21+
class SierraLauncher(object):
2022
def destroy(self, widget, data=None):
21-
main_quit()
23+
Gtk.main_quit()
2224

2325
def delete_event(self, widget, event, data=None):
2426
self.destroy(self, widget)
2527

2628
def launch(self, widget, data=None):
27-
os.system(actions[widget.num])
29+
os.system(ACTIONS[widget.num])
2830
if self.close_window_on_launch:
2931
self.destroy(self, widget)
3032

@@ -34,65 +36,65 @@ def toggle(self, widget, data=None):
3436
def __init__(self):
3537
self.close_window_on_launch = False
3638

37-
self.window = Window(WINDOW_TOPLEVEL)
39+
self.window = Gtk.Window()
3840
self.window.set_title("Leisure Suit Larry Collection(TM)")
3941
self.window.set_icon_from_file("Sierra.ico")
4042
self.window.set_resizable(False)
4143
self.window.connect("destroy", self.destroy)
4244
self.window.connect("delete_event", self.delete_event)
4345

44-
self.table = Table(columns=3, rows=9, homogeneous=False)
46+
self.table = Gtk.Table(columns=3, rows=9, homogeneous=False)
4547
self.table.set_border_width(8)
4648
self.window.add(self.table)
4749

4850
for i in range(1, 7):
49-
self.button = Button(' Launch ')
51+
self.button = Gtk.Button('{:^36}'.format('Launch'))
5052
self.button.num = i
5153
self.button.connect("clicked", self.launch, None)
5254
self.button.set_border_width(4)
5355
self.button.show()
5456

55-
self.frame = Frame("Leisure Suit Larry " + str(i))
57+
self.frame = Gtk.Frame(label="Leisure Suit Larry {:d}".format(i))
5658
self.frame.add(self.button)
57-
self.table.attach(self.frame, 0, 2, i-1, i, xoptions=FILL,
58-
yoptions=FILL, xpadding=8, ypadding=2)
59+
self.table.attach(self.frame, 0, 2, i-1, i, xoptions=options.FILL,
60+
yoptions=options.FILL, xpadding=8, ypadding=2)
5961
self.frame.show()
6062

61-
self.dummy = Frame()
62-
self.table.attach(self.dummy, 0, 2, 6, 7, xoptions=EXPAND,
63-
yoptions=EXPAND, xpadding=8, ypadding=2)
63+
self.dummy = Gtk.Frame()
64+
self.table.attach(self.dummy, 0, 2, 6, 7, xoptions=options.EXPAND,
65+
yoptions=options.EXPAND, xpadding=8, ypadding=2)
6466

65-
self.button = Button('View Manual')
67+
self.button = Gtk.Button('View Manual')
6668
self.button.num = 0
6769
self.button.connect("clicked", self.launch, None)
68-
self.table.attach(self.button, 0, 1, 7, 8, xoptions=EXPAND,
69-
yoptions=EXPAND, xpadding=4, ypadding=4)
70+
self.table.attach(self.button, 0, 1, 7, 8, xoptions=options.EXPAND,
71+
yoptions=options.EXPAND, xpadding=4, ypadding=4)
7072
self.button.show()
7173

72-
self.button = Button(' Close ')
73-
self.button.connect_object("clicked", Widget.destroy, self.window)
74-
self.table.attach(self.button, 1, 2, 7, 8, xoptions=EXPAND,
75-
yoptions=EXPAND, xpadding=4, ypadding=4)
74+
self.button = Gtk.Button('{:^15}'.format('Close'))
75+
self.button.connect_object("clicked", Gtk.Widget.destroy, self.window)
76+
self.table.attach(self.button, 1, 2, 7, 8, xoptions=options.EXPAND,
77+
yoptions=options.EXPAND, xpadding=4, ypadding=4)
7678
self.button.show()
7779

78-
self.button = CheckButton("Close window on launch")
80+
self.button = Gtk.CheckButton("Close window on launch")
7981
self.button.set_active(self.close_window_on_launch)
8082
self.button.connect("toggled", self.toggle, None)
81-
self.table.attach(self.button, 0, 2, 8, 9, xoptions=EXPAND,
83+
self.table.attach(self.button, 0, 2, 8, 9, xoptions=options.EXPAND,
8284
yoptions=0, xpadding=4, ypadding=4)
8385
self.button.show()
8486

85-
self.image = Image()
87+
self.image = Gtk.Image()
8688
self.image.set_from_file("gameart.bmp")
87-
self.table.attach(self.image, 2, 3, 0, 9, xoptions=EXPAND,
88-
yoptions=EXPAND, xpadding=8, ypadding=8)
89+
self.table.attach(self.image, 2, 3, 0, 9, xoptions=options.EXPAND,
90+
yoptions=options.EXPAND, xpadding=8, ypadding=8)
8991
self.image.show()
9092

9193
self.table.show()
9294
self.window.show()
9395

9496
def main(self):
95-
main()
97+
Gtk.main()
9698

9799
if __name__ == "__main__":
98100
SierraLauncher().main()

0 commit comments

Comments
 (0)