Logo
AVC, Application View Controller

OUTLINE

Current: 0.10.0

Released: 24-Apr-2015

License: GPL

Common Requirements:
python 2.2 - <3.0

GTK2+ requirements:
Pygtk 2.8 - 2.10
GTK3+ requirements:
PyGObject >=3.10
Qt requirements:
Pyqt v3 - v4
Tk requirements:
Tkinter 2.4
wxWidgets requirements:
wxPython 2.6 - 2.8
Swing requirements:
jython 2.5.1

Author: Fabrizio Pollastri

DOCUMENTATION

Quick start examples:
GTK2+, GTK3+, Qt, Tk,
wxWidgets, Swing.
User Manual

Release Notes

Changelog

All News

ARTICLES

AVC-Simplifying your GUI Code

SCREENSHOTS

GTK2+ examples

GTK3+ examples

Qt examples

Tk examples

wxWidgets examples

Swing examples

DOWNLOAD

Source:
- current avc-0.10.0.tar.gz
all sources

Packages:
Arch Linux
Debian
Ubuntu

Quick start examples:
GTK2+ spinbutton + glade file
GTK3+ spinbutton + glade file
ui file
Qt spinbox + ui file
Tk spinbox + tcl file
wxWidgets spincontrol + xrc file
Swing spinner

All examples


GTK3+ quick start

This is the GTK3+ spin button example included in AVC distribution. It comes into two versions. The first has the GUI generated from a Glade UI description. The second has the GUI generated directly by program instructions. For full details see the "GTK+ examples" chapter of the user manual.

Source code: Glade version (file gtk3_spinbutton.py, needs also gtk3_spinbutton.ui)
01: #!/usr/bin/python
02: # .+
03: #
04: # .identifier : $Id:$
05: # .context    : Application View Controller
06: # .title      : A spin button replicated into a label (GTK3)
07: # .kind       : python source
08: # .author     : Fabrizio Pollastri
09: # .site       : Revello - Italy
10: # .creation   : 15-Mar-2015
11: # .copyright  : (c) 2015 Fabrizio Pollastri.
12: # .license    : GNU General Public License (see below)
13: #
14: # This file is part of "AVC, Application View Controller".
15: #
16: # AVC is free software; you can redistribute it and/or modify
17: # it under the terms of the GNU General Public License as published by
18: # the Free Software Foundation; either version 3 of the License, or
19: # (at your option) any later version.
20: #
21: # AVC is distributed in the hope that it will be useful,
22: # but WITHOUT ANY WARRANTY; without even the implied warranty of
23: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24: # GNU General Public License for more details.
25: #
26: # You should have received a copy of the GNU General Public License
27: # along with this program.  If not, see <http://www.gnu.org/licenses/>.
28: #
29: # .-
30:
31:
32: import gi.repository.Gtk as Gtk         # gimp tool kit bindings
33:
34: from avc import *                       # AVC
35:
36: UI_XML = 'gtk3_spinbutton.ui'           # GUI descriptor
37:
38: ROOT_WINDOW = 'root_window'             # root window name
39:
40:
41: class Example(AVC):
42:   """
43:   A spin button whose value is replicated into a label
44:   """
45:
46:   def __init__(self):
47:
48:     # create GUI
49:     self.builder = Gtk.Builder()
50:     self.builder.add_from_file(UI_XML)
51:     self.builder.connect_signals(self)
52:     self.root_window = self.builder.get_object(ROOT_WINDOW)
53:     self.root_window.show_all()
54:
55:     # the variable holding the spin button value
56:     self.spin_value = 0
57:
58:
59:   def on_destroy(self,window):
60:     "Terminate program at window destroy"
61:     Gtk.main_quit()
62:
63:
64: #### MAIN
65:
66: example = Example()                     # instantiate the application
67: example.avc_init()                      # connect widgets with variables
68: Gtk.main()                              # run GTK event loop until quit
69:
70: #### END
71: 
Source code: programmatic version (file gtk3_spinbutton_progui.py)
01: #!/usr/bin/python
02: # .+
03: #
04: # .identifier : $Id:$
05: # .context    : Application View Controller
06: # .title      : A spin button replicated into a label (GTK3)
07: # .kind       : python source
08: # .author     : Fabrizio Pollastri
09: # .site       : Revello - Italy
10: # .creation   : 14-Mar-2015
11: # .copyright  : (c) 2008 Fabrizio Pollastri.
12: # .license    : GNU General Public License (see below)
13: #
14: # This file is part of "AVC, Application View Controller".
15: #
16: # AVC is free software; you can redistribute it and/or modify
17: # it under the terms of the GNU General Public License as published by
18: # the Free Software Foundation; either version 3 of the License, or
19: # (at your option) any later version.
20: #
21: # AVC is distributed in the hope that it will be useful,
22: # but WITHOUT ANY WARRANTY; without even the implied warranty of
23: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24: # GNU General Public License for more details.
25: #
26: # You should have received a copy of the GNU General Public License
27: # along with this program.  If not, see <http://www.gnu.org/licenses/>.
28: #
29: # .-
30:
31:
32: import gi.repository.Gtk as Gtk         # gimp tool kit bindings
33:
34: from avc import *                       # AVC
35:
36:
37: class Example(AVC):
38:   """
39:   A spin button whose value is replicated into a label
40:   """
41:
42:   def __init__(self):
43:
44:     ## create GUI
45:
46:     # main window
47:     window = Gtk.Window()
48:     window.set_title('AVC GTK3 spin button example')
49:     window.resize(310,50)
50:     window.connect('destroy',Gtk.main_quit)
51:
52:     # horizontal layout for widgets inside main window
53:     hbox = Gtk.HBox()
54:     window.add(hbox)
55:
56:     # label replicating the spin button value with formatting string
57:     label = Gtk.Label()
58:     label.set_name('spin_value__label')
59:     label.set_markup('<b>%d</b>')
60:     hbox.add(label)
61:
62:     # spin button
63:     #spinbutton = Gtk.SpinButton(Gtk.Adjustment(0,0,100,1,5,0),1,0)
64:     spinbutton = Gtk.SpinButton()
65:     spinbutton.set_adjustment(Gtk.Adjustment(0,0,100,1,5,0))
66:     spinbutton.set_name('spin_value__spinbutton')
67:     hbox.add(spinbutton)
68:
69:     # show all widgets
70:     window.show_all()
71:
72:
73:     # the variable holding the spin button value
74:     self.spin_value = 0
75:
76:
77: #### MAIN
78:
79: example = Example()                     # instantiate the application
80: example.avc_init()                      # connect widgets with variables
81: Gtk.main()                              # run GTK event loop until quit
82:
83: #### END
84: