[gnome-devel-docs] Run autopep8 over Python platform demos
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Run autopep8 over Python platform demos
- Date: Mon, 27 Jan 2014 11:13:58 +0000 (UTC)
commit 487db1d79a54c2c3e3046090c446328e3e9707b3
Author: David King <amigadave amigadave com>
Date: Mon Jan 27 10:35:12 2014 +0000
Run autopep8 over Python platform demos
platform-demos/C/samples/GtkApplicationWindow.py | 5 ++
platform-demos/C/samples/aboutdialog.py | 15 +++--
platform-demos/C/samples/button.py | 8 ++-
platform-demos/C/samples/buttonbox.py | 34 ++++++----
platform-demos/C/samples/checkbutton.py | 4 +
platform-demos/C/samples/colorbutton.py | 8 ++-
platform-demos/C/samples/combobox.py | 11 ++-
platform-demos/C/samples/combobox_multicolumn.py | 8 ++-
platform-demos/C/samples/dialog.py | 15 +++-
platform-demos/C/samples/entry.py | 4 +
platform-demos/C/samples/filechooserdialog.py | 68 +++++++++++---------
platform-demos/C/samples/fontchooserwidget.py | 7 ++-
platform-demos/C/samples/gmenu.py | 6 ++-
platform-demos/C/samples/grid.py | 7 ++-
.../C/samples/hello-in-python/hello-world.py | 4 +
platform-demos/C/samples/image.py | 4 +
platform-demos/C/samples/label.py | 4 +
platform-demos/C/samples/linkbutton.py | 8 ++-
platform-demos/C/samples/menubar.py | 22 ++++--
platform-demos/C/samples/menubar_basis.py | 4 +
platform-demos/C/samples/menubutton.py | 16 +++--
platform-demos/C/samples/messagedialog.py | 7 ++-
platform-demos/C/samples/paned.py | 4 +
platform-demos/C/samples/progressbar.py | 4 +
platform-demos/C/samples/radiobutton.py | 13 +++-
platform-demos/C/samples/scale.py | 22 +++++--
platform-demos/C/samples/scrolledwindow.py | 13 +++-
platform-demos/C/samples/separator.py | 4 +
platform-demos/C/samples/spinbutton.py | 10 ++-
platform-demos/C/samples/spinner.py | 4 +
platform-demos/C/samples/statusbar.py | 9 ++-
platform-demos/C/samples/switch.py | 10 ++-
platform-demos/C/samples/textview.py | 7 ++-
platform-demos/C/samples/togglebutton.py | 15 +++--
platform-demos/C/samples/toolbar.py | 15 +++-
platform-demos/C/samples/toolbar_builder.py | 13 +++-
platform-demos/C/samples/tooltip.py | 21 ++++--
.../C/samples/treeview_advanced_liststore.py | 21 ++++--
.../C/samples/treeview_cellrenderertoggle.py | 16 ++++-
.../C/samples/treeview_simple_liststore.py | 13 +++-
platform-demos/C/samples/treeview_treestore.py | 6 ++-
platform-demos/C/samples/widget_drawing.py | 31 +++++----
platform-demos/C/samples/window.py | 2 +
43 files changed, 370 insertions(+), 152 deletions(-)
---
diff --git a/platform-demos/C/samples/GtkApplicationWindow.py
b/platform-demos/C/samples/GtkApplicationWindow.py
index f24d394..453d823 100644
--- a/platform-demos/C/samples/GtkApplicationWindow.py
+++ b/platform-demos/C/samples/GtkApplicationWindow.py
@@ -2,14 +2,19 @@ from gi.repository import Gtk
import sys
# a Gtk ApplicationWindow
+
+
class MyWindow(Gtk.ApplicationWindow):
# constructor: the title is "Welcome to GNOME" and the window belongs
# to the application app
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+
class MyApplication(Gtk.Application):
# constructor of the Gtk Application
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/aboutdialog.py b/platform-demos/C/samples/aboutdialog.py
index 4ef29e6..82f983f 100644
--- a/platform-demos/C/samples/aboutdialog.py
+++ b/platform-demos/C/samples/aboutdialog.py
@@ -2,6 +2,7 @@ from gi.repository import Gtk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# constructor for a window (the parent window)
@@ -27,14 +28,16 @@ class MyWindow(Gtk.ApplicationWindow):
# we fill in the aboutdialog
aboutdialog.set_program_name("AboutDialog Example")
- aboutdialog.set_copyright("Copyright \xc2\xa9 2012 GNOME Documentation Team")
+ aboutdialog.set_copyright(
+ "Copyright \xc2\xa9 2012 GNOME Documentation Team")
aboutdialog.set_authors(authors)
aboutdialog.set_documenters(documenters)
aboutdialog.set_website("http://developer.gnome.org")
aboutdialog.set_website_label("GNOME Developer Website")
# we do not want to show the title, which by default would be "About AboutDialog Example"
- # we have to reset the title of the messagedialog window after setting the program name
+ # we have to reset the title of the messagedialog window after setting
+ # the program name
aboutdialog.set_title("")
# to close the aboutdialog when "close" is clicked we connect the
@@ -47,7 +50,9 @@ class MyWindow(Gtk.ApplicationWindow):
def on_close(self, action, parameter):
action.destroy()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -58,17 +63,17 @@ class MyApplication(Gtk.Application):
def quit_cb(self, action, parameter):
self.quit()
- def do_startup (self):
+ def do_startup(self):
Gtk.Application.do_startup(self)
# create a menu (a Gio.Menu)
menu = Gio.Menu()
# append a menu item with label "About" and action "app.about"
- menu.append ("About", "app.about")
+ menu.append("About", "app.about")
# append a menu item with label "Quit" and action "app.quit"
menu.append("Quit", "app.quit")
# set menu as the menu for the application
- self.set_app_menu (menu)
+ self.set_app_menu(menu)
# a new simpleaction - for the application
quit_action = Gio.SimpleAction.new("quit", None)
diff --git a/platform-demos/C/samples/button.py b/platform-demos/C/samples/button.py
index 16aa2b5..e32a93d 100644
--- a/platform-demos/C/samples/button.py
+++ b/platform-demos/C/samples/button.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="GNOME Button", application=app)
self.set_default_size(250, 50)
@@ -21,7 +23,9 @@ class MyWindow(Gtk.ApplicationWindow):
def do_clicked(self, button):
print "You clicked me!"
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -29,8 +33,8 @@ class MyApplication(Gtk.Application):
win = MyWindow(self)
win.show_all()
- def do_startup (self):
- Gtk.Application.do_startup (self)
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
app = MyApplication()
exit_status = app.run(sys.argv)
diff --git a/platform-demos/C/samples/buttonbox.py b/platform-demos/C/samples/buttonbox.py
index ead1f96..50324f3 100644
--- a/platform-demos/C/samples/buttonbox.py
+++ b/platform-demos/C/samples/buttonbox.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Calculator", application=app)
self.set_default_size(350, 200)
@@ -19,17 +21,17 @@ class MyWindow(Gtk.ApplicationWindow):
# a grid
grid = Gtk.Grid()
grid.set_row_spacing(5)
-
+
# to attach the entry
grid.attach(self.entry, 0, 0, 1, 1)
-
+
# the labels for the buttons
- buttons = [ 7, 8, 9, '/',
- 4, 5, 6, '*',
- 1, 2, 3, '-',
- 'C', 0, '=', '+' ]
-
- # each row is a ButtonBox, attached to the grid
+ buttons = [7, 8, 9, '/',
+ 4, 5, 6, '*',
+ 1, 2, 3, '-',
+ 'C', 0, '=', '+']
+
+ # each row is a ButtonBox, attached to the grid
for i in range(4):
hbox = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL)
hbox.set_spacing(5)
@@ -40,7 +42,7 @@ class MyWindow(Gtk.ApplicationWindow):
button.set_can_focus(False)
button.connect("clicked", self.button_clicked)
hbox.add(button)
-
+
# some variables for the calculations
self.first_number = 0
self.second_number = 0
@@ -54,25 +56,25 @@ class MyWindow(Gtk.ApplicationWindow):
def button_clicked(self, button):
# for the operations
if button.get_label() == '+':
- self.counter += 1
+ self.counter += 1
if self.counter > 1:
self.do_operation()
self.entry.set_text('0')
self.operation = "plus"
elif button.get_label() == '-':
- self.counter += 1
+ self.counter += 1
if self.counter > 1:
self.do_operation()
self.entry.set_text('0')
self.operation = "minus"
elif button.get_label() == '*':
- self.counter += 1
+ self.counter += 1
if self.counter > 1:
self.do_operation()
self.entry.set_text('0')
self.operation = "multiplication"
elif button.get_label() == '/':
- self.counter += 1
+ self.counter += 1
if self.counter > 1:
self.do_operation()
self.entry.set_text('0')
@@ -96,7 +98,7 @@ class MyWindow(Gtk.ApplicationWindow):
number = 0
else:
number = int(self.entry.get_text())
- number = number * 10 + new_digit
+ number = number * 10 + new_digit
if self.counter == 0:
self.first_number = number
else:
@@ -125,8 +127,10 @@ class MyWindow(Gtk.ApplicationWindow):
self.second_number = 0
self.counter = 0
self.entry.set_text('error')
-
+
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/checkbutton.py b/platform-demos/C/samples/checkbutton.py
index 8f1dd9d..67131b9 100644
--- a/platform-demos/C/samples/checkbutton.py
+++ b/platform-demos/C/samples/checkbutton.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="CheckButton Example", application=app)
self.set_default_size(300, 100)
@@ -31,7 +33,9 @@ class MyWindow(Gtk.ApplicationWindow):
else:
self.set_title("")
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/colorbutton.py b/platform-demos/C/samples/colorbutton.py
index ff5121e..c311126 100644
--- a/platform-demos/C/samples/colorbutton.py
+++ b/platform-demos/C/samples/colorbutton.py
@@ -2,7 +2,9 @@ from gi.repository import Gtk
from gi.repository import Gdk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="ColorButton", application=app)
self.set_default_size(150, 50)
@@ -36,7 +38,9 @@ class MyWindow(Gtk.ApplicationWindow):
def on_color_chosen(self, user_data):
print "You chose the color: " + self.button.get_rgba().to_string()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -44,8 +48,8 @@ class MyApplication(Gtk.Application):
win = MyWindow(self)
win.show_all()
- def do_startup (self):
- Gtk.Application.do_startup (self)
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
app = MyApplication()
exit_status = app.run(sys.argv)
diff --git a/platform-demos/C/samples/combobox.py b/platform-demos/C/samples/combobox.py
index b08a89e..418a16d 100644
--- a/platform-demos/C/samples/combobox.py
+++ b/platform-demos/C/samples/combobox.py
@@ -3,7 +3,9 @@ import sys
distros = [["Select distribution"], ["Fedora"], ["Mint"], ["Suse"]]
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
self.set_default_size(200, -1)
@@ -31,20 +33,23 @@ class MyWindow(Gtk.ApplicationWindow):
# the first row is the active one by default at the beginning
combobox.set_active(0)
- # connect the signal emitted when a row is selected to the callback function
+ # connect the signal emitted when a row is selected to the callback
+ # function
combobox.connect("changed", self.on_changed)
# add the combobox to the window
self.add(combobox)
def on_changed(self, combo):
- # if the row selected is not the first one, write its value on the terminal
+ # if the row selected is not the first one, write its value on the
+ # terminal
if combo.get_active() != 0:
- print "You chose " + str(distros[combo.get_active()][0]) +"."
+ print "You chose " + str(distros[combo.get_active()][0]) + "."
return True
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/combobox_multicolumn.py
b/platform-demos/C/samples/combobox_multicolumn.py
index 63f2765..8e5b94e 100644
--- a/platform-demos/C/samples/combobox_multicolumn.py
+++ b/platform-demos/C/samples/combobox_multicolumn.py
@@ -6,7 +6,9 @@ actions = [["Select", None],
["Open", Gtk.STOCK_OPEN],
["Save", Gtk.STOCK_SAVE]]
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
self.set_default_size(200, -1)
@@ -41,7 +43,8 @@ class MyWindow(Gtk.ApplicationWindow):
# the first row is the active one at the beginning
combobox.set_active(0)
- # connect the signal emitted when a row is selected to the callback function
+ # connect the signal emitted when a row is selected to the callback
+ # function
combobox.connect("changed", self.on_changed)
# add the combobox to the window
@@ -51,11 +54,12 @@ class MyWindow(Gtk.ApplicationWindow):
# if the row selected is not the first one, write on the terminal
# the value of the first column in the model
if combo.get_active() != 0:
- print "You chose " + str(actions[combo.get_active()][0]) +"\n"
+ print "You chose " + str(actions[combo.get_active()][0]) + "\n"
return True
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/dialog.py b/platform-demos/C/samples/dialog.py
index b8315d1..720a41f 100644
--- a/platform-demos/C/samples/dialog.py
+++ b/platform-demos/C/samples/dialog.py
@@ -1,20 +1,24 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# construct a window (the parent window)
+
def __init__(self, app):
Gtk.Window.__init__(self, title="GNOME Button", application=app)
self.set_default_size(250, 50)
# a button on the parent window
button = Gtk.Button("Click me")
- # connect the signal "clicked" of the button with the function on_button_click()
+ # connect the signal "clicked" of the button with the function
+ # on_button_click()
button.connect("clicked", self.on_button_click)
# add the button to the window
self.add(button)
- # callback function for the signal "clicked" of the button in the parent window
+ # callback function for the signal "clicked" of the button in the parent
+ # window
def on_button_click(self, widget):
# create a Gtk.Dialog
dialog = Gtk.Dialog()
@@ -26,7 +30,8 @@ class MyWindow(Gtk.ApplicationWindow):
dialog.set_modal(True)
# add a button to the dialog window
dialog.add_button(button_text="OK", response_id=Gtk.ResponseType.OK)
- # connect the "response" signal (the button has been clicked) to the function on_response()
+ # connect the "response" signal (the button has been clicked) to the
+ # function on_response()
dialog.connect("response", self.on_response)
# get the content area of the dialog, add a label to it
@@ -42,7 +47,9 @@ class MyWindow(Gtk.ApplicationWindow):
# (that is, when the button of the dialog has been clicked)
widget.destroy()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -50,7 +57,7 @@ class MyApplication(Gtk.Application):
win = MyWindow(self)
win.show_all()
- def do_startup (self):
+ def do_startup(self):
Gtk.Application.do_startup(self)
app = MyApplication()
diff --git a/platform-demos/C/samples/entry.py b/platform-demos/C/samples/entry.py
index 51d15ef..276add3 100644
--- a/platform-demos/C/samples/entry.py
+++ b/platform-demos/C/samples/entry.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="What is your name?", application=app)
self.set_default_size(300, 100)
@@ -23,7 +25,9 @@ class MyWindow(Gtk.ApplicationWindow):
# print it in a nice form in the terminal
print "Hello " + name + "!"
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/filechooserdialog.py b/platform-demos/C/samples/filechooserdialog.py
index ceb5bce..5acc545 100644
--- a/platform-demos/C/samples/filechooserdialog.py
+++ b/platform-demos/C/samples/filechooserdialog.py
@@ -4,42 +4,46 @@ from gi.repository import Gio
from gi.repository import GObject
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
- Gtk.Window.__init__(self, title="FileChooserDialog Example", application=app)
+ Gtk.Window.__init__(
+ self, title="FileChooserDialog Example", application=app)
self.set_default_size(400, 400)
# the actions for the window menu, connected to the callback functions
new_action = Gio.SimpleAction.new("new", None)
new_action.connect("activate", self.new_callback)
self.add_action(new_action)
-
+
open_action = Gio.SimpleAction.new("open", None)
open_action.connect("activate", self.open_callback)
self.add_action(open_action)
-
+
save_action = Gio.SimpleAction.new("save", None)
save_action.connect("activate", self.save_callback)
self.add_action(save_action)
-
+
save_as_action = Gio.SimpleAction.new("save-as", None)
save_as_action.connect("activate", self.save_as_callback)
self.add_action(save_as_action)
-
+
# the file
self.file = None
-
+
# the textview with the buffer
self.buffer = Gtk.TextBuffer()
textview = Gtk.TextView(buffer=self.buffer)
textview.set_wrap_mode(Gtk.WrapMode.WORD)
-
+
# a scrolled window for the textview
self.scrolled_window = Gtk.ScrolledWindow()
- self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ self.scrolled_window.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.scrolled_window.add(textview)
self.scrolled_window.set_border_width(5)
-
+
# add the scrolled window to the window
self.add(self.scrolled_window)
@@ -47,16 +51,17 @@ class MyWindow(Gtk.ApplicationWindow):
def new_callback(self, action, parameter):
self.buffer.set_text("")
print "New file created"
-
+
# callback for open
def open_callback(self, action, parameter):
- # create a filechooserdialog to open:
- # the arguments are: title of the window, parent_window, action, (buttons, response)
- open_dialog = Gtk.FileChooserDialog ("Pick a file", self,
- Gtk.FileChooserAction.OPEN,
- (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT))
-
+ # create a filechooserdialog to open:
+ # the arguments are: title of the window, parent_window, action,
+ # (buttons, response)
+ open_dialog = Gtk.FileChooserDialog("Pick a file", self,
+ Gtk.FileChooserAction.OPEN,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT))
+
# not only local files can be selected in the file selector
open_dialog.set_local_only(False)
# dialog always on top of the textview window
@@ -95,12 +100,13 @@ class MyWindow(Gtk.ApplicationWindow):
# callback function for save_as
def save_as_callback(self, action, parameter):
- # create a filechooserdialog to save:
- # the arguments are: title of the window, parent_window, action, (buttons, response)
- save_dialog = Gtk.FileChooserDialog ("Pick a file", self,
- Gtk.FileChooserAction.SAVE,
- (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
- Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT))
+ # create a filechooserdialog to save:
+ # the arguments are: title of the window, parent_window, action,
+ # (buttons, response)
+ save_dialog = Gtk.FileChooserDialog("Pick a file", self,
+ Gtk.FileChooserAction.SAVE,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT))
# the dialog will present a confirmation dialog if the user types a file name that
# already exists
save_dialog.set_do_overwrite_confirmation(True)
@@ -117,7 +123,7 @@ class MyWindow(Gtk.ApplicationWindow):
save_dialog.connect("response", self.save_response_cb)
# show the dialog
save_dialog.show()
-
+
# callback function for the dialog save_dialog
def save_response_cb(self, dialog, response_id):
save_dialog = dialog
@@ -132,8 +138,8 @@ class MyWindow(Gtk.ApplicationWindow):
print "cancelled: FileChooserAction.SAVE"
# destroy the FileChooserDialog
dialog.destroy()
-
- # callback function for save
+
+ # callback function for save
def save_callback(self, action, parameter):
# if self.file is not already there
if self.file is not None:
@@ -164,17 +170,19 @@ class MyWindow(Gtk.ApplicationWindow):
# if the contents are empty
else:
# create (if the file does not exist) or overwrite the file in readwrite mode.
- # arguments: etags, make_backup, flags, GError
+ # arguments: etags, make_backup, flags, GError
try:
self.file.replace_readwrite(None,
False,
- Gio.FileCreateFlags.NONE,
+ Gio.FileCreateFlags.NONE,
None)
print "saved: " + self.file.get_path()
except GObject.GError as e:
print "Error: " + e.message
-
+
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -199,7 +207,7 @@ class MyApplication(Gtk.Application):
sys.exit()
menu = builder.get_object("appmenu")
self.set_app_menu(menu)
-
+
# callback function for quit
def quit_callback(self, action, parameter):
self.quit()
diff --git a/platform-demos/C/samples/fontchooserwidget.py b/platform-demos/C/samples/fontchooserwidget.py
index db8a81e..df4a68c 100644
--- a/platform-demos/C/samples/fontchooserwidget.py
+++ b/platform-demos/C/samples/fontchooserwidget.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="FontChooserWidget", application=app)
@@ -10,7 +12,8 @@ class MyWindow(Gtk.ApplicationWindow):
# a default font
self.font_chooser.set_font("Sans")
# a text to preview the font
- self.font_chooser.set_preview_text("This is an example of preview text!")
+ self.font_chooser.set_preview_text(
+ "This is an example of preview text!")
# connect signal from the font chooser to the callback function
self.font_chooser.connect("notify::font", self.font_cb)
@@ -23,7 +26,9 @@ class MyWindow(Gtk.ApplicationWindow):
# print in the terminal
print "You chose the font " + self.font_chooser.get_font()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/gmenu.py b/platform-demos/C/samples/gmenu.py
index c0dc578..a1f2583 100644
--- a/platform-demos/C/samples/gmenu.py
+++ b/platform-demos/C/samples/gmenu.py
@@ -2,11 +2,15 @@ from gi.repository import Gtk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="GMenu Example", application=app)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -14,7 +18,7 @@ class MyApplication(Gtk.Application):
win = MyWindow(self)
win.show_all()
- def do_startup (self):
+ def do_startup(self):
# start the application
Gtk.Application.do_startup(self)
diff --git a/platform-demos/C/samples/grid.py b/platform-demos/C/samples/grid.py
index 70a7217..86ccf43 100644
--- a/platform-demos/C/samples/grid.py
+++ b/platform-demos/C/samples/grid.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Grid Example", application=app)
@@ -22,12 +24,15 @@ class MyWindow(Gtk.ApplicationWindow):
# attach the second label
grid.attach(label_top_right, 1, 0, 1, 1)
# attach the third label below the first label
- grid.attach_next_to(label_bottom, label_top_left, Gtk.PositionType.BOTTOM, 2, 1)
+ grid.attach_next_to(
+ label_bottom, label_top_left, Gtk.PositionType.BOTTOM, 2, 1)
# add the grid to the window
self.add(grid)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/hello-in-python/hello-world.py
b/platform-demos/C/samples/hello-in-python/hello-world.py
index ebca626..5d6d014 100644
--- a/platform-demos/C/samples/hello-in-python/hello-world.py
+++ b/platform-demos/C/samples/hello-in-python/hello-world.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# constructor for a Gtk.ApplicationWindow
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
self.set_default_size(200, 100)
@@ -14,7 +16,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the label to the window
self.add(label)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/image.py b/platform-demos/C/samples/image.py
index be5707e..02a02a2 100644
--- a/platform-demos/C/samples/image.py
+++ b/platform-demos/C/samples/image.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# create a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
self.set_default_size(300, 300)
@@ -14,7 +16,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the image to the window
self.add(image)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/label.py b/platform-demos/C/samples/label.py
index ebca626..5d6d014 100644
--- a/platform-demos/C/samples/label.py
+++ b/platform-demos/C/samples/label.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# constructor for a Gtk.ApplicationWindow
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
self.set_default_size(200, 100)
@@ -14,7 +16,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the label to the window
self.add(label)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/linkbutton.py b/platform-demos/C/samples/linkbutton.py
index a098361..78851cd 100644
--- a/platform-demos/C/samples/linkbutton.py
+++ b/platform-demos/C/samples/linkbutton.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="GNOME LinkButton", application=app)
self.set_default_size(250, 50)
@@ -15,7 +17,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the button to the window
self.add(button)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -23,8 +27,8 @@ class MyApplication(Gtk.Application):
win = MyWindow(self)
win.show_all()
- def do_startup (self):
- Gtk.Application.do_startup (self)
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
app = MyApplication()
exit_status = app.run(sys.argv)
diff --git a/platform-demos/C/samples/menubar.py b/platform-demos/C/samples/menubar.py
index ae63cc4..d044f79 100644
--- a/platform-demos/C/samples/menubar.py
+++ b/platform-demos/C/samples/menubar.py
@@ -3,7 +3,9 @@ from gi.repository import GLib
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="MenuBar Example", application=app)
self.set_default_size(200, 200)
@@ -23,7 +25,8 @@ class MyWindow(Gtk.ApplicationWindow):
self.add_action(paste_action)
# action with a state created (name, parameter type, initial state)
- shape_action = Gio.SimpleAction.new_stateful("shape", GLib.VariantType.new('s'),
GLib.Variant.new_string('line'))
+ shape_action = Gio.SimpleAction.new_stateful(
+ "shape", GLib.VariantType.new('s'), GLib.Variant.new_string('line'))
# connected to the callback function
shape_action.connect("activate", self.shape_callback)
# added to the window
@@ -46,9 +49,9 @@ class MyWindow(Gtk.ApplicationWindow):
# callback function for shape_action
def shape_callback(self, action, parameter):
- print "Shape is set to", parameter.get_string()
- # Note that we set the state of the action!
- action.set_state(parameter)
+ print "Shape is set to", parameter.get_string()
+ # Note that we set the state of the action!
+ action.set_state(parameter)
# callback function for about (see the AboutDialog example)
def about_callback(self, action, parameter):
@@ -61,7 +64,8 @@ class MyWindow(Gtk.ApplicationWindow):
# we fill in the aboutdialog
aboutdialog.set_program_name("MenuBar Example")
- aboutdialog.set_copyright("Copyright \xc2\xa9 2012 GNOME Documentation Team")
+ aboutdialog.set_copyright(
+ "Copyright \xc2\xa9 2012 GNOME Documentation Team")
aboutdialog.set_authors(authors)
aboutdialog.set_documenters(documenters)
aboutdialog.set_website("http://developer.gnome.org")
@@ -77,7 +81,9 @@ class MyWindow(Gtk.ApplicationWindow):
def on_close(self, action, parameter):
action.destroy()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -104,14 +110,16 @@ class MyApplication(Gtk.Application):
self.add_action(quit_action)
# action with a state created
- state_action = Gio.SimpleAction.new_stateful("state", GLib.VariantType.new('s'),
GLib.Variant.new_string('off'))
+ state_action = Gio.SimpleAction.new_stateful(
+ "state", GLib.VariantType.new('s'), GLib.Variant.new_string('off'))
# action connected to the callback function
state_action.connect("activate", self.state_callback)
# action added to the application
self.add_action(state_action)
# action with a state created
- awesome_action = Gio.SimpleAction.new_stateful("awesome", None, GLib.Variant.new_boolean(False))
+ awesome_action = Gio.SimpleAction.new_stateful(
+ "awesome", None, GLib.Variant.new_boolean(False))
# action connected to the callback function
awesome_action.connect("activate", self.awesome_callback)
# action added to the application
diff --git a/platform-demos/C/samples/menubar_basis.py b/platform-demos/C/samples/menubar_basis.py
index 1394854..a1c8675 100644
--- a/platform-demos/C/samples/menubar_basis.py
+++ b/platform-demos/C/samples/menubar_basis.py
@@ -1,12 +1,16 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="MenuBar Example", application=app)
self.set_default_size(200, 200)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/menubutton.py b/platform-demos/C/samples/menubutton.py
index 63fbbfe..6c3af1c 100644
--- a/platform-demos/C/samples/menubutton.py
+++ b/platform-demos/C/samples/menubutton.py
@@ -2,19 +2,21 @@ from gi.repository import Gtk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Menubutton Example", application=app)
self.set_default_size(600, 400)
grid = Gtk.Grid()
-
+
# a menubutton
menubutton = Gtk.MenuButton()
menubutton.set_size_request(80, 35)
-
+
grid.attach(menubutton, 0, 0, 1, 1)
-
+
# a menu with two actions
menumodel = Gio.Menu()
menumodel.append("New", "app.new")
@@ -32,14 +34,16 @@ class MyWindow(Gtk.ApplicationWindow):
about_action = Gio.SimpleAction.new("about", None)
about_action.connect("activate", self.about_callback)
self.add_action(about_action)
-
+
self.add(grid)
# callback for "about"
def about_callback(self, action, parameter):
print "You clicked \"About\""
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -54,11 +58,11 @@ class MyApplication(Gtk.Application):
new_action = Gio.SimpleAction.new("new", None)
new_action.connect("activate", self.new_callback)
self.add_action(new_action)
-
+
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.quit_callback)
self.add_action(quit_action)
-
+
# callback functions for the actions related to the application
def new_callback(self, action, parameter):
print "You clicked \"New\""
diff --git a/platform-demos/C/samples/messagedialog.py b/platform-demos/C/samples/messagedialog.py
index fff5960..002736e 100644
--- a/platform-demos/C/samples/messagedialog.py
+++ b/platform-demos/C/samples/messagedialog.py
@@ -2,6 +2,7 @@ from gi.repository import Gtk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# constructor for a window (the parent window) with a label
@@ -47,7 +48,9 @@ class MyWindow(Gtk.ApplicationWindow):
# finally, destroy the messagedialog
widget.destroy()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
@@ -58,7 +61,7 @@ class MyApplication(Gtk.Application):
def quit_cb(self, action, parameter):
self.quit()
- def do_startup (self):
+ def do_startup(self):
Gtk.Application.do_startup(self)
# create a menu (a Gio.Menu)
@@ -73,7 +76,7 @@ class MyApplication(Gtk.Application):
# a new simpleaction - for the application
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.quit_cb)
- self.add_action (quit_action)
+ self.add_action(quit_action)
app = MyApplication()
exit_status = app.run(sys.argv)
diff --git a/platform-demos/C/samples/paned.py b/platform-demos/C/samples/paned.py
index 0d6ab34..76c8622 100644
--- a/platform-demos/C/samples/paned.py
+++ b/platform-demos/C/samples/paned.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Paned Example", application=app)
self.set_default_size(450, 350)
@@ -24,7 +26,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the panes to the window
self.add(paned)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/progressbar.py b/platform-demos/C/samples/progressbar.py
index 4641da9..1894520 100644
--- a/platform-demos/C/samples/progressbar.py
+++ b/platform-demos/C/samples/progressbar.py
@@ -2,8 +2,10 @@ from gi.repository import GLib
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="ProgressBar Example", application=app)
self.set_default_size(220, 20)
@@ -40,7 +42,9 @@ class MyWindow(Gtk.ApplicationWindow):
# call the function again
return True
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/radiobutton.py b/platform-demos/C/samples/radiobutton.py
index f177ac1..b1079c1 100644
--- a/platform-demos/C/samples/radiobutton.py
+++ b/platform-demos/C/samples/radiobutton.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="RadioButton Example", application=app)
self.set_default_size(250, 100)
@@ -25,7 +27,8 @@ class MyWindow(Gtk.ApplicationWindow):
# another radiobutton, in the same group as button1,
# with label "Button 3"
- button3 = Gtk.RadioButton.new_with_label_from_widget(button1, "Button 3")
+ button3 = Gtk.RadioButton.new_with_label_from_widget(
+ button1, "Button 3")
# connect the signal "toggled" emitted by the radiobutton
# with the callback function toggled_cb
button3.connect("toggled", self.toggled_cb)
@@ -34,9 +37,9 @@ class MyWindow(Gtk.ApplicationWindow):
# a grid to place the buttons
grid = Gtk.Grid.new()
- grid.attach(button1, 0, 0, 1, 1);
- grid.attach(button2, 0, 1, 1, 1);
- grid.attach(button3, 0, 2, 1, 1);
+ grid.attach(button1, 0, 0, 1, 1)
+ grid.attach(button2, 0, 1, 1, 1)
+ grid.attach(button3, 0, 2, 1, 1)
# add the grid to the window
self.add(grid)
@@ -54,7 +57,9 @@ class MyWindow(Gtk.ApplicationWindow):
# print on the terminal which button was turned on/off
print button.get_label() + " was turned " + state
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/scale.py b/platform-demos/C/samples/scale.py
index dd4a2ea..76187ce 100644
--- a/platform-demos/C/samples/scale.py
+++ b/platform-demos/C/samples/scale.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Scale Example", application=app)
self.set_default_size(400, 300)
@@ -15,12 +17,15 @@ class MyWindow(Gtk.ApplicationWindow):
ad2 = Gtk.Adjustment(50, 0, 100, 5, 10, 0)
# an horizontal scale
- self.h_scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=ad1)
+ self.h_scale = Gtk.Scale(
+ orientation=Gtk.Orientation.HORIZONTAL, adjustment=ad1)
# of integers (no digits)
self.h_scale.set_digits(0)
- # that can expand horizontally if there is space in the grid (see below)
+ # that can expand horizontally if there is space in the grid (see
+ # below)
self.h_scale.set_hexpand(True)
- # that is aligned at the top of the space allowed in the grid (see below)
+ # that is aligned at the top of the space allowed in the grid (see
+ # below)
self.h_scale.set_valign(Gtk.Align.START)
# we connect the signal "value-changed" emitted by the scale with the callback
@@ -28,7 +33,8 @@ class MyWindow(Gtk.ApplicationWindow):
self.h_scale.connect("value-changed", self.scale_moved)
# a vertical scale
- self.v_scale = Gtk.Scale(orientation=Gtk.Orientation.VERTICAL, adjustment=ad2)
+ self.v_scale = Gtk.Scale(
+ orientation=Gtk.Orientation.VERTICAL, adjustment=ad2)
# that can expand vertically if there is space in the grid (see below)
self.v_scale.set_vexpand(True)
@@ -45,17 +51,21 @@ class MyWindow(Gtk.ApplicationWindow):
grid.set_column_spacing(10)
grid.set_column_homogeneous(True)
grid.attach(self.h_scale, 0, 0, 1, 1)
- grid.attach_next_to(self.v_scale, self.h_scale, Gtk.PositionType.RIGHT, 1, 1)
+ grid.attach_next_to(
+ self.v_scale, self.h_scale, Gtk.PositionType.RIGHT, 1, 1)
grid.attach(self.label, 0, 1, 2, 1)
self.add(grid)
- # any signal from the scales is signaled to the label the text of which is changed
+ # any signal from the scales is signaled to the label the text of which is
+ # changed
def scale_moved(self, event):
self.label.set_text("Horizontal scale is " + str(int(self.h_scale.get_value())) +
"; vertical scale is " + str(self.v_scale.get_value()) + ".")
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/scrolledwindow.py b/platform-demos/C/samples/scrolledwindow.py
index 05137b7..52430db 100644
--- a/platform-demos/C/samples/scrolledwindow.py
+++ b/platform-demos/C/samples/scrolledwindow.py
@@ -1,16 +1,21 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
- Gtk.Window.__init__(self, title="ScrolledWindow Example", application=app)
+ Gtk.Window.__init__(
+ self, title="ScrolledWindow Example", application=app)
self.set_default_size(200, 200)
# the scrolledwindow
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.set_border_width(10)
- # there is always the scrollbar (otherwise: AUTOMATIC - only if needed - or NEVER)
- scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
+ # there is always the scrollbar (otherwise: AUTOMATIC - only if needed
+ # - or NEVER)
+ scrolled_window.set_policy(
+ Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
# an image - slightly larger than the window...
image = Gtk.Image()
@@ -22,7 +27,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the scrolledwindow to the window
self.add(scrolled_window)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/separator.py b/platform-demos/C/samples/separator.py
index 0aab0ee..f755401 100644
--- a/platform-demos/C/samples/separator.py
+++ b/platform-demos/C/samples/separator.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Separator Example", application=app)
@@ -31,7 +33,9 @@ class MyWindow(Gtk.ApplicationWindow):
# add the grid to the window
self.add(grid)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/spinbutton.py b/platform-demos/C/samples/spinbutton.py
index 1aa77a1..67ebbb9 100644
--- a/platform-demos/C/samples/spinbutton.py
+++ b/platform-demos/C/samples/spinbutton.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="SpinButton Example", application=app)
self.set_default_size(210, 70)
@@ -33,11 +35,15 @@ class MyWindow(Gtk.ApplicationWindow):
self.add(grid)
- # callback function: the signal of the spinbutton is used to change the text of the label
+ # callback function: the signal of the spinbutton is used to change the
+ # text of the label
def spin_selected(self, event):
- self.label.set_text("The number you selected is " + str(self.spin.get_value_as_int()) + ".")
+ self.label.set_text(
+ "The number you selected is " + str(self.spin.get_value_as_int()) + ".")
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/spinner.py b/platform-demos/C/samples/spinner.py
index 517b657..185a686 100644
--- a/platform-demos/C/samples/spinner.py
+++ b/platform-demos/C/samples/spinner.py
@@ -2,8 +2,10 @@ from gi.repository import Gtk
from gi.repository import Gdk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Spinner Example", application=app)
self.set_default_size(200, 200)
@@ -34,7 +36,9 @@ class MyWindow(Gtk.ApplicationWindow):
# stop the signal emission
return True
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/statusbar.py b/platform-demos/C/samples/statusbar.py
index bb1b622..fcfb33c 100644
--- a/platform-demos/C/samples/statusbar.py
+++ b/platform-demos/C/samples/statusbar.py
@@ -2,8 +2,10 @@ from gi.repository import Gtk
from gi.repository import Gdk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="StatusBar Example", application=app)
self.set_default_size(200, 100)
@@ -22,7 +24,8 @@ class MyWindow(Gtk.ApplicationWindow):
# the source of a message
self.context_id = self.statusbar.get_context_id("example")
# we push a message onto the statusbar's stack
- self.statusbar.push(self.context_id, "Waiting for you to do something...")
+ self.statusbar.push(
+ self.context_id, "Waiting for you to do something...")
# a grid to attach the widgets
grid = Gtk.Grid()
@@ -48,11 +51,13 @@ class MyWindow(Gtk.ApplicationWindow):
# onto which we push a new status with the symbolic name
# of the key pressed
self.statusbar.push(self.context_id, Gdk.keyval_name(event.keyval) +
- " key was pressed.")
+ " key was pressed.")
# stop the signal emission
return True
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/switch.py b/platform-demos/C/samples/switch.py
index c830ee6..25508b4 100644
--- a/platform-demos/C/samples/switch.py
+++ b/platform-demos/C/samples/switch.py
@@ -1,8 +1,10 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Switch Example", application=app)
self.set_default_size(300, 100)
@@ -22,9 +24,9 @@ class MyWindow(Gtk.ApplicationWindow):
# a grid to allocate the widgets
grid = Gtk.Grid()
- grid.set_column_spacing (10);
- grid.attach (label, 0, 0, 1, 1);
- grid.attach (switch, 1, 0, 1, 1);
+ grid.set_column_spacing(10)
+ grid.attach(label, 0, 0, 1, 1)
+ grid.attach(switch, 1, 0, 1, 1)
# add the grid to the window
self.add(grid)
@@ -40,7 +42,9 @@ class MyWindow(Gtk.ApplicationWindow):
else:
self.set_title("")
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/textview.py b/platform-demos/C/samples/textview.py
index d13dcc4..3294afc 100644
--- a/platform-demos/C/samples/textview.py
+++ b/platform-demos/C/samples/textview.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="TextView Example", application=app)
self.set_default_size(300, 450)
@@ -10,7 +12,8 @@ class MyWindow(Gtk.ApplicationWindow):
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.set_border_width(5)
# we scroll only if needed
- scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ scrolled_window.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
# a text buffer (stores text)
buffer1 = Gtk.TextBuffer()
@@ -25,7 +28,9 @@ class MyWindow(Gtk.ApplicationWindow):
self.add(scrolled_window)
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/togglebutton.py b/platform-demos/C/samples/togglebutton.py
index f741985..c4e428a 100644
--- a/platform-demos/C/samples/togglebutton.py
+++ b/platform-demos/C/samples/togglebutton.py
@@ -1,10 +1,13 @@
from gi.repository import Gtk
import sys
+
class MyWindow(Gtk.ApplicationWindow):
# a window
+
def __init__(self, app):
- Gtk.Window.__init__(self, title="ToggleButton Example", application=app)
+ Gtk.Window.__init__(
+ self, title="ToggleButton Example", application=app)
self.set_default_size(300, 300)
self.set_border_width(30)
@@ -23,10 +26,10 @@ class MyWindow(Gtk.ApplicationWindow):
# a grid to allocate the widgets
grid = Gtk.Grid()
- grid.set_row_homogeneous(False);
- grid.set_row_spacing(15);
- grid.attach(self.spinner, 0, 0, 1, 1);
- grid.attach(button, 0, 1, 1, 1);
+ grid.set_row_homogeneous(False)
+ grid.set_row_spacing(15)
+ grid.attach(self.spinner, 0, 0, 1, 1)
+ grid.attach(button, 0, 1, 1, 1)
# add the grid to the window
self.add(grid)
@@ -40,7 +43,9 @@ class MyWindow(Gtk.ApplicationWindow):
else:
self.spinner.stop()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/toolbar.py b/platform-demos/C/samples/toolbar.py
index c673d7e..efde399 100644
--- a/platform-demos/C/samples/toolbar.py
+++ b/platform-demos/C/samples/toolbar.py
@@ -3,7 +3,9 @@ from gi.repository import Gdk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Toolbar Example", application=app)
self.set_default_size(400, 200)
@@ -43,7 +45,7 @@ class MyWindow(Gtk.ApplicationWindow):
toolbar = Gtk.Toolbar()
# which is the primary toolbar of the application
- toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
+ toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
# create a button for the "new" action, with a stock image
new_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_NEW)
@@ -72,7 +74,8 @@ class MyWindow(Gtk.ApplicationWindow):
undo_button.set_action_name("win.undo")
# button for the "fullscreen/leave fullscreen" action
- self.fullscreen_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_FULLSCREEN)
+ self.fullscreen_button = Gtk.ToolButton.new_from_stock(
+ Gtk.STOCK_FULLSCREEN)
self.fullscreen_button.set_is_important(True)
toolbar.insert(self.fullscreen_button, 3)
self.fullscreen_button.set_action_name("win.fullscreen")
@@ -86,8 +89,10 @@ class MyWindow(Gtk.ApplicationWindow):
# callback method for fullscreen / leave fullscreen
def fullscreen_callback(self, action, parameter):
- # check if the state is the same as Gdk.WindowState.FULLSCREEN, which is a bit flag
- is_fullscreen = self.get_window().get_state() & Gdk.WindowState.FULLSCREEN != 0
+ # check if the state is the same as Gdk.WindowState.FULLSCREEN, which
+ # is a bit flag
+ is_fullscreen = self.get_window().get_state(
+ ) & Gdk.WindowState.FULLSCREEN != 0
if not is_fullscreen:
self.fullscreen_button.set_stock_id(Gtk.STOCK_LEAVE_FULLSCREEN)
self.fullscreen()
@@ -95,7 +100,9 @@ class MyWindow(Gtk.ApplicationWindow):
self.fullscreen_button.set_stock_id(Gtk.STOCK_FULLSCREEN)
self.unfullscreen()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/toolbar_builder.py b/platform-demos/C/samples/toolbar_builder.py
index 1984315..d210556 100644
--- a/platform-demos/C/samples/toolbar_builder.py
+++ b/platform-demos/C/samples/toolbar_builder.py
@@ -3,7 +3,9 @@ from gi.repository import Gdk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Toolbar Example", application=app)
self.set_default_size(400, 200)
@@ -29,7 +31,8 @@ class MyWindow(Gtk.ApplicationWindow):
# two buttons that will be used later in a method
self.fullscreen_button = builder.get_object("fullscreen_button")
- self.leave_fullscreen_button = builder.get_object("leave_fullscreen_button")
+ self.leave_fullscreen_button = builder.get_object(
+ "leave_fullscreen_button")
# create the actions that control the window, connect their signal to a
# callback method (see below), add the action to the window:
@@ -50,8 +53,10 @@ class MyWindow(Gtk.ApplicationWindow):
# callback for fullscreen
def fullscreen_callback(self, action, parameter):
- # check if the state is the same as Gdk.WindowState.FULLSCREEN, which is a bit flag
- is_fullscreen = self.get_window().get_state() & Gdk.WindowState.FULLSCREEN != 0
+ # check if the state is the same as Gdk.WindowState.FULLSCREEN, which
+ # is a bit flag
+ is_fullscreen = self.get_window().get_state(
+ ) & Gdk.WindowState.FULLSCREEN != 0
if is_fullscreen:
self.unfullscreen()
self.leave_fullscreen_button.hide()
@@ -61,7 +66,9 @@ class MyWindow(Gtk.ApplicationWindow):
self.fullscreen_button.hide()
self.leave_fullscreen_button.show()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/tooltip.py b/platform-demos/C/samples/tooltip.py
index 8e03249..2ed0975 100644
--- a/platform-demos/C/samples/tooltip.py
+++ b/platform-demos/C/samples/tooltip.py
@@ -3,9 +3,12 @@ from gi.repository import Gdk
from gi.repository import Gio
import sys
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
- Gtk.Window.__init__(self, title="Toolbar with Tooltips Example", application=app)
+ Gtk.Window.__init__(
+ self, title="Toolbar with Tooltips Example", application=app)
self.set_default_size(400, 200)
grid = Gtk.Grid()
@@ -28,11 +31,11 @@ class MyWindow(Gtk.ApplicationWindow):
def create_toolbar(self):
toolbar = Gtk.Toolbar()
- toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
+ toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
# button for the "new" action
new_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_NEW)
- # with a tooltip with a given text
+ # with a tooltip with a given text
new_button.set_tooltip_text("Create a new file")
new_button.set_is_important(True)
toolbar.insert(new_button, 0)
@@ -41,7 +44,7 @@ class MyWindow(Gtk.ApplicationWindow):
# button for the "open" action
open_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_OPEN)
- # with a tooltip with a given text in the Pango markup language
+ # with a tooltip with a given text in the Pango markup language
open_button.set_tooltip_markup("Open an <i>existing</i> file")
open_button.set_is_important(True)
toolbar.insert(open_button, 1)
@@ -51,7 +54,7 @@ class MyWindow(Gtk.ApplicationWindow):
# button for the "undo" action
undo_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_UNDO)
# with a tooltip with an image
- # set True the property "has-tooltip"
+ # set True the property "has-tooltip"
undo_button.set_property("has-tooltip", True)
# connect to the callback function that for the tooltip
# with the signal "query-tooltip"
@@ -62,7 +65,8 @@ class MyWindow(Gtk.ApplicationWindow):
undo_button.set_action_name("win.undo")
# button for the "fullscreen/leave fullscreen" action
- self.fullscreen_button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_FULLSCREEN)
+ self.fullscreen_button = Gtk.ToolButton.new_from_stock(
+ Gtk.STOCK_FULLSCREEN)
self.fullscreen_button.set_is_important(True)
toolbar.insert(self.fullscreen_button, 3)
self.fullscreen_button.set_action_name("win.fullscreen")
@@ -82,7 +86,8 @@ class MyWindow(Gtk.ApplicationWindow):
print "You clicked \"Undo\"."
def fullscreen_callback(self, action, parameter):
- is_fullscreen = self.get_window().get_state() & Gdk.WindowState.FULLSCREEN != 0
+ is_fullscreen = self.get_window().get_state(
+ ) & Gdk.WindowState.FULLSCREEN != 0
if not is_fullscreen:
self.fullscreen_button.set_stock_id(Gtk.STOCK_LEAVE_FULLSCREEN)
self.fullscreen()
@@ -90,7 +95,9 @@ class MyWindow(Gtk.ApplicationWindow):
self.fullscreen_button.set_stock_id(Gtk.STOCK_FULLSCREEN)
self.unfullscreen()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/treeview_advanced_liststore.py
b/platform-demos/C/samples/treeview_advanced_liststore.py
index 30f0f8b..8e71821 100644
--- a/platform-demos/C/samples/treeview_advanced_liststore.py
+++ b/platform-demos/C/samples/treeview_advanced_liststore.py
@@ -9,7 +9,9 @@ list_of_dvd = [["The Usual Suspects"],
["Once Upon a Time in the West"],
["Rear Window"]]
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="My DVDs", application=app)
self.set_default_size(250, 100)
@@ -59,9 +61,12 @@ class MyWindow(Gtk.ApplicationWindow):
grid.attach(view, 0, 0, 4, 1)
grid.attach(self.label, 0, 1, 4, 1)
grid.attach(self.button_add, 0, 2, 1, 1)
- grid.attach_next_to(self.entry, self.button_add, Gtk.PositionType.RIGHT, 1, 1)
- grid.attach_next_to(self.button_remove, self.entry, Gtk.PositionType.RIGHT, 1, 1)
- grid.attach_next_to(self.button_remove_all, self.button_remove, Gtk.PositionType.RIGHT, 1, 1)
+ grid.attach_next_to(
+ self.entry, self.button_add, Gtk.PositionType.RIGHT, 1, 1)
+ grid.attach_next_to(
+ self.button_remove, self.entry, Gtk.PositionType.RIGHT, 1, 1)
+ grid.attach_next_to(
+ self.button_remove_all, self.button_remove, Gtk.PositionType.RIGHT, 1, 1)
# add the grid to the window
self.add(grid)
@@ -69,9 +74,10 @@ class MyWindow(Gtk.ApplicationWindow):
def on_changed(self, selection):
# get the model and the iterator that points at the data in the model
(model, iter) = selection.get_selected()
- # set the label to a new value depending on the selection, if there is one
+ # set the label to a new value depending on the selection, if there is
+ # one
if iter is not None:
- self.label.set_text("\n %s" %(model[iter][0]))
+ self.label.set_text("\n %s" % (model[iter][0]))
else:
self.label.set_text("")
return True
@@ -82,7 +88,7 @@ class MyWindow(Gtk.ApplicationWindow):
title = self.entry.get_text()
self.listmodel.append([title])
# and print a message in the terminal
- print "%s has been added" %(title)
+ print "%s has been added" % (title)
def remove_cb(self, button):
# if there is still an entry in the model
@@ -92,7 +98,7 @@ class MyWindow(Gtk.ApplicationWindow):
# if there is a selection, print a message in the terminal
# and remove it from the model
if iter is not None:
- print "%s has been removed" %(model[iter][0])
+ print "%s has been removed" % (model[iter][0])
self.listmodel.remove(iter)
# otherwise, ask the user to select something to remove
else:
@@ -114,6 +120,7 @@ class MyWindow(Gtk.ApplicationWindow):
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/treeview_cellrenderertoggle.py
b/platform-demos/C/samples/treeview_cellrenderertoggle.py
index d8e3868..4dfc1b7 100644
--- a/platform-demos/C/samples/treeview_cellrenderertoggle.py
+++ b/platform-demos/C/samples/treeview_cellrenderertoggle.py
@@ -3,10 +3,13 @@ from gi.repository import Pango
import sys
books = [["Tolstoy, Leo", ["War and Peace", True], ["Anna Karenina", False]],
- ["Shakespeare, William", ["Hamlet", False], ["Macbeth", True], ["Othello", False]],
+ ["Shakespeare, William", ["Hamlet", False],
+ ["Macbeth", True], ["Othello", False]],
["Tolkien, J.R.R.", ["The Lord of the Rings", False]]]
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Library", application=app)
self.set_default_size(250, 100)
@@ -20,7 +23,8 @@ class MyWindow(Gtk.ApplicationWindow):
# the iter piter is returned when appending the author in the first column
# and False in the second
piter = self.store.append(None, [books[i][0], False])
- # append the books and the associated boolean value as children of the author
+ # append the books and the associated boolean value as children of
+ # the author
j = 1
while j < len(books[i]):
self.store.append(piter, books[i][j])
@@ -69,9 +73,11 @@ class MyWindow(Gtk.ApplicationWindow):
while citer is not None:
self.store[citer][1] = current_value
citer = self.store.iter_next(citer)
- # if the length of the path is not 1 (that is, if we are selecting a book)
+ # if the length of the path is not 1 (that is, if we are selecting a
+ # book)
elif len(path) != 1:
- # get the first child of the parent of the book (the first book of the author)
+ # get the first child of the parent of the book (the first book of
+ # the author)
citer = self.store.get_iter(path)
piter = self.store.iter_parent(citer)
citer = self.store.iter_children(piter)
@@ -85,7 +91,9 @@ class MyWindow(Gtk.ApplicationWindow):
# if they do, the author as well is selected; otherwise it is not
self.store[piter][1] = all_selected
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/treeview_simple_liststore.py
b/platform-demos/C/samples/treeview_simple_liststore.py
index 4af92b6..bfd3298 100644
--- a/platform-demos/C/samples/treeview_simple_liststore.py
+++ b/platform-demos/C/samples/treeview_simple_liststore.py
@@ -13,13 +13,16 @@ phonebook = [["Jurg", "Billeter", "555-0123"],
["Jason", "Clinton", "555-4567"],
["Random J.", "Hacker", "555-5678"]]
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="My Phone Book", application=app)
self.set_default_size(250, 100)
self.set_border_width(10)
- # the data in the model (three strings for each row, one for each column)
+ # the data in the model (three strings for each row, one for each
+ # column)
listmodel = Gtk.ListStore(str, str, str)
# append the values in the model
for i in range(len(phonebook)):
@@ -33,8 +36,8 @@ class MyWindow(Gtk.ApplicationWindow):
cell = Gtk.CellRendererText()
# the text in the first column should be in boldface
if i == 0:
- cell.props.weight_set=True
- cell.props.weight=Pango.Weight.BOLD
+ cell.props.weight_set = True
+ cell.props.weight = Pango.Weight.BOLD
# the column is created
col = Gtk.TreeViewColumn(columns[i], cell, text=i)
# and it is appended to the treeview
@@ -59,11 +62,13 @@ class MyWindow(Gtk.ApplicationWindow):
# get the model and the iterator that points at the data in the model
(model, iter) = selection.get_selected()
# set the label to a new value depending on the selection
- self.label.set_text("\n %s %s %s" %(model[iter][0], model[iter][1], model[iter][2]))
+ self.label.set_text("\n %s %s %s" %
+ (model[iter][0], model[iter][1], model[iter][2]))
return True
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/treeview_treestore.py b/platform-demos/C/samples/treeview_treestore.py
index 4b7277c..0950e76 100644
--- a/platform-demos/C/samples/treeview_treestore.py
+++ b/platform-demos/C/samples/treeview_treestore.py
@@ -6,7 +6,9 @@ books = [["Tolstoy, Leo", "War and Peace", "Anna Karenina"],
["Shakespeare, William", "Hamlet", "Macbeth", "Othello"],
["Tolkien, J.R.R.", "The Lord of the Rings"]]
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Library", application=app)
self.set_default_size(250, 100)
@@ -32,7 +34,8 @@ class MyWindow(Gtk.ApplicationWindow):
# the cellrenderer for the column - text
renderer_books = Gtk.CellRendererText()
# the column is created
- column_books = Gtk.TreeViewColumn("Books by Author", renderer_books, text=0)
+ column_books = Gtk.TreeViewColumn(
+ "Books by Author", renderer_books, text=0)
# and it is appended to the treeview
view.append_column(column_books)
@@ -44,6 +47,7 @@ class MyWindow(Gtk.ApplicationWindow):
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/widget_drawing.py b/platform-demos/C/samples/widget_drawing.py
index 6e8588f..f336cc7 100644
--- a/platform-demos/C/samples/widget_drawing.py
+++ b/platform-demos/C/samples/widget_drawing.py
@@ -3,7 +3,9 @@ from gi.repository import cairo
import sys
import math
+
class MyWindow(Gtk.ApplicationWindow):
+
def __init__(self, app):
Gtk.Window.__init__(self, title="Choose an angle", application=app)
self.set_default_size(400, 400)
@@ -13,7 +15,7 @@ class MyWindow(Gtk.ApplicationWindow):
self.angle = 360
grid = Gtk.Grid()
-
+
# a spinbutton that takes the value of an angle
ad = Gtk.Adjustment(360, 0, 360, 1, 0, 0)
self.spin = Gtk.SpinButton(adjustment=ad, climb_rate=1, digits=0)
@@ -23,51 +25,54 @@ class MyWindow(Gtk.ApplicationWindow):
self.darea = Gtk.DrawingArea()
# that we describe in the method draw(), connected to the signal "draw"
self.darea.connect("draw", self.draw)
- # we have to request a minimum size of the drawing area, or it will disappear
+ # we have to request a minimum size of the drawing area, or it will
+ # disappear
self.darea.set_size_request(300, 300)
grid.attach(self.spin, 0, 0, 1, 1)
grid.attach(self.darea, 0, 1, 1, 1)
-
+
self.add(grid)
-
- # whenever we get a new angle in the spinbutton
+
+ # whenever we get a new angle in the spinbutton
def get_angle(self, event):
self.angle = self.spin.get_value_as_int()
# redraw what is in the drawing area
self.darea.queue_draw()
-
+
def draw(self, darea, cr):
# a 10-pixels-wide line
cr.set_line_width(10)
# red
cr.set_source_rgba(0.5, 0.0, 0.0, 1.0)
-
- # get the width and height of the drawing area
+
+ # get the width and height of the drawing area
w = self.darea.get_allocated_width()
h = self.darea.get_allocated_height()
- # move to the center of the drawing area
+ # move to the center of the drawing area
# (translate from the top left corner to w/2, h/2)
- cr.translate(w/2, h/2)
+ cr.translate(w / 2, h / 2)
# draw a line to (55, 0)
cr.line_to(55, 0)
# and get back to (0, 0)
cr.line_to(0, 0)
- # draw an arc centered in the origin, 50 pixels wide, from the angle 0
+ # draw an arc centered in the origin, 50 pixels wide, from the angle 0
# (in radians) to the angle given by the spinbutton (in degrees)
- cr.arc(0, 0, 50, 0, self.angle*(math.pi/180))
+ cr.arc(0, 0, 50, 0, self.angle * (math.pi / 180))
# draw a line back to the origin
cr.line_to(0, 0)
# drawing the path, and keeping the path for future use
cr.stroke_preserve()
-
+
# set a colour
cr.set_source_rgba(0.0, 0.5, 0.5, 1.0)
# and use it to fill the path (that we had kept)
cr.fill()
+
class MyApplication(Gtk.Application):
+
def __init__(self):
Gtk.Application.__init__(self)
diff --git a/platform-demos/C/samples/window.py b/platform-demos/C/samples/window.py
index 7532cc2..9f58e76 100644
--- a/platform-demos/C/samples/window.py
+++ b/platform-demos/C/samples/window.py
@@ -1,7 +1,9 @@
from gi.repository import Gtk
import sys
+
class MyApplication(Gtk.Application):
+
def do_activate(self):
# create a Gtk Window belonging to the application itself
window = Gtk.Window(application=self)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]