64 lines
1.6 KiB
Plaintext
64 lines
1.6 KiB
Plaintext
|
#!/usr/bin/env python
|
||
|
|
||
|
import pygtk
|
||
|
pygtk.require('2.0')
|
||
|
import gtk, gobject
|
||
|
|
||
|
class Slider:
|
||
|
def __init__(self):
|
||
|
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||
|
self.window.set_resizable(True)
|
||
|
|
||
|
self.window.connect("destroy", self.quit)
|
||
|
self.window.set_title("Slider")
|
||
|
self.window.set_border_width(0)
|
||
|
|
||
|
vbox = gtk.VBox(False, 5)
|
||
|
vbox.set_border_width(10)
|
||
|
self.window.add(vbox)
|
||
|
vbox.show()
|
||
|
|
||
|
# Create a label
|
||
|
self.label = gtk.Label("")
|
||
|
vbox.pack_start(self.label, False, False, 0)
|
||
|
self.label.show()
|
||
|
|
||
|
# Create a centering alignment object
|
||
|
align = gtk.Alignment(0.5, 0.5, 0, 0)
|
||
|
vbox.pack_start(align, False, False, 5)
|
||
|
align.show()
|
||
|
|
||
|
# Create the Slider
|
||
|
self.slider = gtk.HScale(adjustment=gtk.Adjustment(
|
||
|
value=0,
|
||
|
lower=0, upper=10,
|
||
|
step_incr=1, page_incr=2, page_size=2))
|
||
|
|
||
|
align.add(self.slider)
|
||
|
self.slider.show()
|
||
|
self.label.set_mnemonic_widget(self.slider)
|
||
|
self.label.set_text_with_mnemonic("_Some slider:")
|
||
|
|
||
|
separator = gtk.HSeparator()
|
||
|
vbox.pack_start(separator, False, False, 0)
|
||
|
separator.show()
|
||
|
|
||
|
# Add a button to exit the program
|
||
|
button = gtk.Button("close")
|
||
|
button.connect("clicked", self.quit)
|
||
|
vbox.pack_start(button, False, False, 0)
|
||
|
button.show()
|
||
|
|
||
|
self.window.show()
|
||
|
|
||
|
def quit(self, widget, data=None):
|
||
|
gtk.main_quit()
|
||
|
|
||
|
def main():
|
||
|
gtk.main()
|
||
|
return 0
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
Slider()
|
||
|
main()
|