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 8260359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:04:58+00:00 2026-06-08T03:04:58+00:00

I am writing a small application using Tkinter and Pmw. Using the Pmw NoteBook

  • 0

I am writing a small application using Tkinter and Pmw. Using the Pmw NoteBook class have an interface to allow the user to create new tabs for input.

Each of these tabs has exactly the same content (radio buttons and entry fields), so I want the content to be written in just one function. But this does not work and I do not understand why not. I get a NameError in the Traceback that does not make sense to me, as “page” has been defined for the whole class, and I can use it in other function definitions.

<type 'exceptions.NameError'>: global name 'page' is not defined

The simplest working version of what I am trying to do is (based on the NoteBook_2 example shipped with Pmw):

import Tkinter
import Pmw

class Demo:
    def __init__(self, parent):
        self.pageCounter = 0 
        self.mainframe = Tkinter.Frame(parent)
        self.mainframe.pack(fill = 'both', expand = 1)
        self.notebook = Pmw.NoteBook(self.mainframe)
        buttonbox = Pmw.ButtonBox(self.mainframe)
        buttonbox.pack(side = 'bottom', fill = 'x')
        buttonbox.add('Add Tab', command = self.insertpage)
        self.notebook.pack(fill = 'both', expand = 1, padx = 5, pady = 5)

    def insertpage(self):
        # Create a new Tab
        self.pageCounter = self.pageCounter + 1
        pageName = 'Tab%d' % (self.pageCounter)
        page = self.notebook.insert(pageName)
        self.showPageContent()

    def showPageContent(self):
        # This function should contain the content for all new Tabs
        tabContentExample = Tkinter.Label(page, text="This is the Tab Content I want to repeat\n")
        tabContentExample.pack() 

# Create demo in root window for testing.
if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root)
    widget = Demo(root)
    root.mainloop()

Can anyone give me a pointer to the solution?

  • 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-06-08T03:04:59+00:00Added an answer on June 8, 2026 at 3:04 am

    showPageContent is using the variable page which is undefined. You define it locally in another method, but it isn’t known to the showPageContent method. You either need to use self.page, or pass page to showPageContent:

    page = self.notebook.insert(pageName)
    self.showPageContent(page)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started learning Python by writing a small application using Python 3.1 and
I'm writing a small demo application in Java using Spring, that needs to have
I have been writing a small application using C# to copy a document into
I'm working on writing a small application using the WPF MediaKit , and I
I'm writing a small business application using C# (.NET 4.0, SQL CE 4.0 database).
I'm working on writing a small WSGI application using Bottle and SqlAlchemy and am
I'm writing a small application in C# (.NET 4.0). I have a datagridview, each
I'm writing a small web application using Perl, HTML::Mason and Apache. I've been using
I have been writing a small java application (my first!), that does only a
I am using the Model-View pattern on a small application I'm writing. Here's the

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.