Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1108079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:01:39+00:00 2026-05-17T02:01:39+00:00

I have a Python script which uses a glade file to define its UI,

  • 0

I have a Python script which uses a glade file to define its UI, and has a lot of repetitive widgets, each one to adjust a different numerical attribute of a certain active object. Since it is repetitive, I decided to define all the handlers in a separate file for encapsulation and readability. Here are some code excerpts:

The main file:

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()

The Handlers.py file:

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()

When I run the program, the GUI shows up properly, but when I move a slider I get this error:

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

I know a little about namespaces and scope, but I am very noob on Python and Object orienting in general, so I do not know exactely what I should do. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:01:40+00:00Added an answer on May 17, 2026 at 2:01 am

    I think you’ve forgotten the self argument all over the place.

    i.e. change this:

    class Handlers:
        def adjustbottomBracketHeight(widget):
            obj.bottomBracketHeight = widget.get_value()
    

    to

    class Handlers:
        def adjustbottomBracketHeight(obj, widget):
            obj.bottomBracketHeight = widget.get_value()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Python script which uses Curses, I have a subwin to which some
I have a Python script which uses the MySQLdb interface to load various CSV
I have the following asp script which uses python 2.5: <%@ Language = Python
I have a Python script which creates a dictionary of its own functions and
I have a Python script which uses Tkinter for the GUI. My little script
I have a python script which uses subprocess.Popen to run multiple instances of another
I have one python script which i am trying to convert and stuck in
I have a Python script which processes a .txt file which contains report usage
I have a small python script which i use everyday......it basically reads a file
I am trying to run a python script which uses a binary file (xFiles.bin.addr_patched)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.