主文件:
import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo, gtk.glade
from Handlers import Handlers
from FramesetParameters import FramesetParameters
from GeometricRules import GeometricRules
from BikeDrawing import BikeDrawing
p=FramesetParameters("fitting", "handling", "construction")
builder = gtk.Builder()
builder.add_from_file("FramesetDesignerUI.glade")
Handlers(p)
builder.connect_signals(Handlers.__dict__)
mainWindow = builder.get_object("mainWindow")
mainWindow.show_all()
gtk.main()
这个处理程序.py文件:
class Handlers:
def adjustbottomBracketHeight(widget):
obj.bottomBracketHeight = widget.get_value()
def adjustseatTubeAngle(widget):
obj.seatTubeAngle = widget.get_value()
def adjustseatTubeLength(widget):
obj.seatTubeLength = widget.get_value()
def adjusttopTubeLength(widget):
obj.topTubeLength = widget.get_value()
def adjustheadTubeAngle(widget):
obj.headTubeAngle = widget.get_value()
def adjustheadTubeTopHeight(widget):
obj.headTubeTopHeight = widget.get_value()
def adjustrearAxlePosition(widget):
obj.rearAxlePosition = widget.get_value()
def adjusttrail(widget):
obj.trail = widget.get_value()
def adjustseatTubeExtension(widget):
obj.seatTubeExtension = widget.get_value()
def adjustheadTubeUpperExtension(widget):
obj.headTubeUpperExtension = widget.get_value()
def adjustheadTubeLowerExtension(widget):
obj.headTubeLowerExtension = widget.get_value()
def adjustforkCrownBulk(widget):
obj.forkCrownBulk = widget.get_value()
当我运行程序时,GUI会正确显示,但当我移动滑块时会出现以下错误:
Traceback (most recent call last):
File "/home/helton/Dropbox/Profilez/00Computacional/00REFACTORY97/Handlers.py", line 6, in adjustseatTubeAngle
obj.seatTubeAngle = widget.get_value()
NameError: global name 'obj' is not defined